id
int32
0
12.9k
code
sequencelengths
2
264k
1,200
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ";", "import", "java", ".", "io", ".", "ByteArrayInputStream", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "io", ".", "FilenameFilter", ";", "import", "java", ".", "io", ".", "InputStream", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "Properties", ";", "import", "java", ".", "util", ".", "regex", ".", "Pattern", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang", ".", "SystemUtils", ";", "import", "org", ".", "apache", ".", "tools", ".", "ant", ".", "taskdefs", ".", "condition", ".", "Os", ";", "import", "org", ".", "eclim", ".", "Services", ";", "import", "org", ".", "eclim", ".", "logging", ".", "Logger", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "AbstractPluginResources", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "preference", ".", "PreferenceFactory", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "preference", ".", "Preferences", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "project", ".", "ProjectManagement", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "project", ".", "ProjectNatureFactory", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "preference", ".", "OptionHandler", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "project", ".", "JavaProjectManager", ";", "import", "org", ".", "eclim", ".", "util", ".", "IOUtils", ";", "import", "org", ".", "eclim", ".", "util", ".", "StringUtils", ";", "import", "org", ".", "eclim", ".", "util", ".", "file", ".", "FileUtils", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "IPath", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "Path", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "JavaCore", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "launching", ".", "IVMInstall", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "launching", ".", "JavaRuntime", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "launching", ".", "LibraryLocation", ";", "public", "class", "PluginResources", "extends", "AbstractPluginResources", "{", "public", "static", "final", "String", "NAME", "=", "\"\"", ";", "public", "static", "final", "String", "NATURE", "=", "JavaCore", ".", "NATURE_ID", ";", "private", "static", "final", "Logger", "logger", "=", "Logger", ".", "getLogger", "(", "PluginResources", ".", "class", ")", ";", "private", "static", "final", "String", "VARIABLES", "=", "\"\"", ";", "private", "static", "final", "String", "[", "]", "SRC_LOCATIONS", "=", "{", "\"src.zip\"", ",", "\"\"", ",", "SystemUtils", ".", "JAVA_HOME", ".", "replace", "(", "'\\\\'", ",", "'/'", ")", "+", "\"/src.jar\"", ",", "SystemUtils", ".", "JAVA_HOME", ".", "replace", "(", "'\\\\'", ",", "'/'", ")", "+", "\"/src.zip\"", ",", "SystemUtils", ".", "JAVA_HOME", ".", "replace", "(", "'\\\\'", ",", "'/'", ")", "+", "\"\"", ",", "SystemUtils", ".", "JAVA_HOME", ".", "replace", "(", "'\\\\'", ",", "'/'", ")", "+", "\"/../src.zip\"", ",", "SystemUtils", ".", "JAVA_HOME", ".", "replace", "(", "'\\\\'", ",", "'/'", ")", "+", "\"\"", ",", "}", ";", "@", "Override", "public", "void", "initialize", "(", "String", "name", ")", "{", "super", ".", "initialize", "(", "name", ")", ";", "logger", ".", "debug", "(", "\"\"", ")", ";", "initializeJreSrc", "(", ")", ";", "initializeVars", "(", "VARIABLES", ")", ";", "Preferences", ".", "addOptionHandler", "(", "\"\"", ",", "new", "OptionHandler", "(", ")", ")", ";", "ProjectNatureFactory", ".", "addNature", "(", "\"java\"", ",", "NATURE", ")", ";", "ProjectManagement", ".", "addProjectManager", "(", "NATURE", ",", "new", "JavaProjectManager", "(", ")", ")", ";", "PreferenceFactory", ".", "addPreferences", "(", "NATURE", ",", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", ")", ";", "PreferenceFactory", ".", "addOptions", "(", "NATURE", ",", "\"\"", "+", "\"\"", ")", ";", "}", "@", "Override", "protected", "String", "getBundleBaseName", "(", ")", "{", "return", "\"\"", ";", "}", "protected", "void", "initializeJreSrc", "(", ")", "{", "String", "jarName", "=", "Os", ".", "isFamily", "(", "Os", ".", "FAMILY_MAC", ")", "?", "\"classes.jar\"", ":", "\"rt.jar\"", ";", "try", "{", "IVMInstall", "vm", "=", "JavaRuntime", ".", "getDefaultVMInstall", "(", ")", ";", "LibraryLocation", "[", "]", "locations", "=", "JavaRuntime", ".", "getLibraryLocations", "(", "vm", ")", ";", "LibraryLocation", "[", "]", "newLocations", "=", "new", "LibraryLocation", "[", "locations", ".", "length", "]", ";", "for", "(", "int", "ii", "=", "0", ";", "ii", "<", "locations", ".", "length", ";", "ii", "++", ")", "{", "IPath", "libraryPath", "=", "locations", "[", "ii", "]", ".", "getSystemLibraryPath", "(", ")", ";", "if", "(", "libraryPath", ".", "lastSegment", "(", ")", ".", "equals", "(", "jarName", ")", "&&", "(", "locations", "[", "ii", "]", ".", "getSystemLibrarySourcePath", "(", ")", ".", "isEmpty", "(", ")", "||", "!", "locations", "[", "ii", "]", ".", "getSystemLibrarySourcePath", "(", ")", ".", "toFile", "(", ")", ".", "exists", "(", ")", ")", ")", "{", "IPath", "jreSrc", "=", "null", ";", "logger", ".", "debug", "(", "\"\"", ",", "SystemUtils", ".", "JAVA_HOME", ")", ";", "for", "(", "int", "jj", "=", "0", ";", "jj", "<", "SRC_LOCATIONS", ".", "length", ";", "jj", "++", ")", "{", "String", "location", "=", "SRC_LOCATIONS", "[", "jj", "]", ";", "if", "(", "location", ".", "startsWith", "(", "\"/\"", ")", "||", "location", ".", "indexOf", "(", "':'", ")", "!=", "-", "1", ")", "{", "jreSrc", "=", "new", "Path", "(", "location", ")", ";", "}", "else", "{", "jreSrc", "=", "libraryPath", ".", "removeLastSegments", "(", "3", ")", ".", "append", "(", "location", ")", ";", "}", "logger", ".", "debug", "(", "\"\"", ",", "jreSrc", ")", ";", "if", "(", "jreSrc", ".", "toFile", "(", ")", ".", "exists", "(", ")", ")", "{", "break", ";", "}", "}", "if", "(", "!", "jreSrc", ".", "toFile", "(", ")", ".", "exists", "(", ")", "&&", "Os", ".", "isFamily", "(", "Os", ".", "FAMILY_WINDOWS", ")", ")", "{", "String", "path", "=", "libraryPath", ".", "toOSString", "(", ")", ".", "replaceFirst", "(", "\"\"", ",", "\"\"", ")", ";", "String", "altHome", "=", "path", ".", "replaceFirst", "(", "\"\"", ",", "\"jdk$1\"", ")", ";", "if", "(", "!", "altHome", ".", "equals", "(", "path", ")", ")", "{", "jreSrc", "=", "new", "Path", "(", "altHome", ")", ".", "append", "(", "\"src.zip\"", ")", ";", "}", "if", "(", "!", "jreSrc", ".", "toFile", "(", ")", ".", "exists", "(", ")", ")", "{", "String", "base", "=", "FileUtils", ".", "getBaseName", "(", "path", ")", ";", "final", "String", "major", "=", "base", ".", "replaceFirst", "(", "\"^jre(\\\\d)$\"", ",", "\"$1\"", ")", ";", "if", "(", "!", "major", ".", "equals", "(", "base", ")", ")", "{", "File", "dir", "=", "new", "File", "(", "FileUtils", ".", "getFullPath", "(", "path", ")", ")", ";", "String", "[", "]", "jdks", "=", "dir", ".", "list", "(", "new", "FilenameFilter", "(", ")", "{", "private", "final", "Pattern", "JDK", "=", "Pattern", ".", "compile", "(", "\"jdk\\\\d+\\\\.\"", "+", "major", "+", "\"\\\\.\\\\d+_\\\\d+\"", ")", ";", "public", "boolean", "accept", "(", "File", "dir", ",", "String", "name", ")", "{", "return", "JDK", ".", "matcher", "(", "name", ")", ".", "matches", "(", ")", ";", "}", "}", ")", ";", "for", "(", "String", "jdk", ":", "jdks", ")", "{", "jreSrc", "=", "new", "Path", "(", "dir", ".", "toString", "(", ")", ")", ".", "append", "(", "jdk", ")", ".", "append", "(", "\"src.zip\"", ")", ";", "if", "(", "jreSrc", ".", "toFile", "(", ")", ".", "exists", "(", ")", ")", "{", "break", ";", "}", "}", "}", "}", "}", "if", "(", "jreSrc", ".", "toFile", "(", ")", ".", "exists", "(", ")", ")", "{", "logger", ".", "info", "(", "\"\"", ",", "JavaRuntime", ".", "JRESRC_VARIABLE", ",", "jreSrc", ")", ";", "newLocations", "[", "ii", "]", "=", "new", "LibraryLocation", "(", "locations", "[", "ii", "]", ".", "getSystemLibraryPath", "(", ")", ",", "jreSrc", ",", "locations", "[", "ii", "]", ".", "getPackageRootPath", "(", ")", ",", "locations", "[", "ii", "]", ".", "getJavadocLocation", "(", ")", ")", ";", "}", "else", "{", "logger", ".", "debug", "(", "\"\"", "+", "SystemUtils", ".", "JAVA_HOME", ")", ";", "newLocations", "[", "ii", "]", "=", "new", "LibraryLocation", "(", "locations", "[", "ii", "]", ".", "getSystemLibraryPath", "(", ")", ",", "Path", ".", "EMPTY", ",", "locations", "[", "ii", "]", ".", "getPackageRootPath", "(", ")", ",", "locations", "[", "ii", "]", ".", "getJavadocLocation", "(", ")", ")", ";", "}", "}", "else", "{", "newLocations", "[", "ii", "]", "=", "locations", "[", "ii", "]", ";", "}", "}", "vm", ".", "setLibraryLocations", "(", "newLocations", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "logger", ".", "error", "(", "\"\"", ",", "e", ")", ";", "}", "}", "protected", "void", "initializeVars", "(", "String", "variable", ")", "{", "String", "file", "=", "\"/\"", "+", "variable", "+", "\".properties\"", ";", "logger", ".", "debug", "(", "\"\"", ",", "file", ")", ";", "InputStream", "in", "=", "null", ";", "try", "{", "in", "=", "getClass", "(", ")", ".", "getResourceAsStream", "(", "file", ")", ";", "String", "propertiesString", "=", "IOUtils", ".", "toString", "(", "in", ")", ";", "HashMap", "<", "Object", ",", "String", ">", "values", "=", "new", "HashMap", "<", "Object", ",", "String", ">", "(", ")", ";", "for", "(", "Object", "key", ":", "System", ".", "getProperties", "(", ")", ".", "keySet", "(", ")", ")", "{", "values", ".", "put", "(", "key", ",", "System", ".", "getProperty", "(", "(", "String", ")", "key", ")", ".", "replace", "(", "'\\\\'", ",", "'/'", ")", ")", ";", "}", "propertiesString", "=", "StringUtils", ".", "replacePlaceholders", "(", "propertiesString", ",", "values", ")", ";", "Properties", "properties", "=", "new", "Properties", "(", ")", ";", "properties", ".", "load", "(", "new", "ByteArrayInputStream", "(", "propertiesString", ".", "getBytes", "(", ")", ")", ")", ";", "for", "(", "Object", "key", ":", "properties", ".", "keySet", "(", ")", ")", "{", "String", "name", "=", "(", "String", ")", "key", ";", "IPath", "path", "=", "new", "Path", "(", "properties", ".", "getProperty", "(", "name", ")", ")", ";", "logger", ".", "debug", "(", "\"\"", ",", "name", ",", "path", ")", ";", "JavaCore", ".", "setClasspathVariable", "(", "name", ",", "path", ",", "null", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "logger", ".", "error", "(", "\"\"", ",", "e", ")", ";", "}", "finally", "{", "IOUtils", ".", "closeQuietly", "(", "in", ")", ";", "}", "}", "}", "</s>" ]
1,201
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "util", ";", "import", "java", ".", "util", ".", "Arrays", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang", ".", "builder", ".", "EqualsBuilder", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang", ".", "builder", ".", "HashCodeBuilder", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IType", ";", "public", "class", "TypeInfo", "{", "private", "IType", "type", ";", "private", "String", "[", "]", "typeParameters", ";", "private", "String", "[", "]", "typeArguments", ";", "public", "TypeInfo", "(", "IType", "type", ",", "String", "[", "]", "typeParameters", ",", "String", "[", "]", "typeArguments", ")", "{", "this", ".", "type", "=", "type", ";", "this", ".", "typeParameters", "=", "typeParameters", "!=", "null", "?", "typeParameters", ":", "new", "String", "[", "0", "]", ";", "this", ".", "typeArguments", "=", "typeArguments", "!=", "null", "?", "typeArguments", ":", "new", "String", "[", "0", "]", ";", "}", "public", "IType", "getType", "(", ")", "{", "return", "this", ".", "type", ";", "}", "public", "String", "[", "]", "getTypeParameters", "(", ")", "{", "return", "this", ".", "typeParameters", ";", "}", "public", "String", "[", "]", "getTypeArguments", "(", ")", "{", "return", "this", ".", "typeArguments", ";", "}", "public", "boolean", "equals", "(", "Object", "other", ")", "{", "if", "(", "!", "(", "other", "instanceof", "TypeInfo", ")", ")", "{", "return", "false", ";", "}", "if", "(", "this", "==", "other", ")", "{", "return", "true", ";", "}", "TypeInfo", "result", "=", "(", "TypeInfo", ")", "other", ";", "boolean", "equal", "=", "new", "EqualsBuilder", "(", ")", ".", "append", "(", "getType", "(", ")", ",", "result", ".", "getType", "(", ")", ")", ".", "isEquals", "(", ")", ";", "return", "equal", ";", "}", "public", "int", "hashCode", "(", ")", "{", "return", "new", "HashCodeBuilder", "(", "24", ",", "56", ")", ".", "append", "(", "type", ")", ".", "toHashCode", "(", ")", ";", "}", "public", "String", "toString", "(", ")", "{", "return", "new", "StringBuffer", "(", ")", ".", "append", "(", "type", "!=", "null", "?", "type", ".", "getElementName", "(", ")", ":", "\"null\"", ")", ".", "append", "(", "\":\"", ")", ".", "append", "(", "\"", "params:", "\"", ")", ".", "append", "(", "Arrays", ".", "toString", "(", "typeParameters", ")", ")", ".", "append", "(", "\"", "args:", "\"", ")", ".", "append", "(", "Arrays", ".", "toString", "(", "typeArguments", ")", ")", ".", "toString", "(", ")", ";", "}", "}", "</s>" ]
1,202
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "util", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "Flags", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IMethod", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IType", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "Signature", ";", "public", "class", "MethodUtils", "{", "private", "static", "final", "String", "VARARGS", "=", "\"...\"", ";", "public", "static", "boolean", "containsMethod", "(", "TypeInfo", "typeInfo", ",", "IMethod", "method", ")", "throws", "Exception", "{", "IType", "type", "=", "typeInfo", ".", "getType", "(", ")", ";", "String", "signature", "=", "getMinimalMethodSignature", "(", "method", ",", "typeInfo", ")", ";", "if", "(", "method", ".", "isConstructor", "(", ")", ")", "{", "signature", "=", "signature", ".", "replaceFirst", "(", "method", ".", "getDeclaringType", "(", ")", ".", "getElementName", "(", ")", ",", "type", ".", "getElementName", "(", ")", ")", ";", "}", "IMethod", "[", "]", "methods", "=", "type", ".", "getMethods", "(", ")", ";", "for", "(", "int", "ii", "=", "0", ";", "ii", "<", "methods", ".", "length", ";", "ii", "++", ")", "{", "String", "methodSig", "=", "getMinimalMethodSignature", "(", "methods", "[", "ii", "]", ",", "typeInfo", ")", ";", "if", "(", "methodSig", ".", "equals", "(", "signature", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}", "public", "static", "IMethod", "getMethod", "(", "TypeInfo", "typeInfo", ",", "IMethod", "method", ")", "throws", "Exception", "{", "IType", "type", "=", "typeInfo", ".", "getType", "(", ")", ";", "String", "signature", "=", "getMinimalMethodSignature", "(", "method", ",", "typeInfo", ")", ";", "if", "(", "method", ".", "isConstructor", "(", ")", ")", "{", "signature", "=", "signature", ".", "replaceFirst", "(", "method", ".", "getDeclaringType", "(", ")", ".", "getElementName", "(", ")", ",", "type", ".", "getElementName", "(", ")", ")", ";", "}", "IMethod", "[", "]", "methods", "=", "type", ".", "getMethods", "(", ")", ";", "for", "(", "int", "ii", "=", "0", ";", "ii", "<", "methods", ".", "length", ";", "ii", "++", ")", "{", "String", "methodSig", "=", "getMinimalMethodSignature", "(", "methods", "[", "ii", "]", ",", "typeInfo", ")", ";", "if", "(", "methodSig", ".", "equals", "(", "signature", ")", ")", "{", "return", "methods", "[", "ii", "]", ";", "}", "}", "return", "null", ";", "}", "public", "static", "IMethod", "getMethodAfter", "(", "IType", "type", ",", "IMethod", "method", ")", "throws", "Exception", "{", "if", "(", "type", "==", "null", "||", "method", "==", "null", ")", "{", "return", "null", ";", "}", "IMethod", "[", "]", "all", "=", "type", ".", "getMethods", "(", ")", ";", "for", "(", "int", "ii", "=", "0", ";", "ii", "<", "all", ".", "length", ";", "ii", "++", ")", "{", "if", "(", "all", "[", "ii", "]", ".", "equals", "(", "method", ")", "&&", "ii", "<", "all", ".", "length", "-", "1", ")", "{", "return", "all", "[", "ii", "+", "1", "]", ";", "}", "}", "return", "null", ";", "}", "public", "static", "String", "getMethodSignature", "(", "IMethod", "method", ",", "TypeInfo", "typeInfo", ")", "throws", "Exception", "{", "int", "flags", "=", "method", ".", "getFlags", "(", ")", ";", "StringBuffer", "buffer", "=", "new", "StringBuffer", "(", ")", ";", "if", "(", "method", ".", "getDeclaringType", "(", ")", ".", "isInterface", "(", ")", ")", "{", "buffer", ".", "append", "(", "\"public", "\"", ")", ";", "}", "else", "{", "buffer", ".", "append", "(", "Flags", ".", "isPublic", "(", "method", ".", "getFlags", "(", ")", ")", "?", "\"public", "\"", ":", "\"protected", "\"", ")", ";", "}", "buffer", ".", "append", "(", "Flags", ".", "isAbstract", "(", "flags", ")", "?", "\"abstract", "\"", ":", "\"\"", ")", ";", "if", "(", "!", "method", ".", "isConstructor", "(", ")", ")", "{", "String", "name", "=", "Signature", ".", "getSignatureSimpleName", "(", "method", ".", "getReturnType", "(", ")", ")", ";", "buffer", ".", "append", "(", "TypeUtils", ".", "replaceTypeParams", "(", "name", ",", "typeInfo", ")", ")", ".", "append", "(", "'", "'", ")", ";", "}", "buffer", ".", "append", "(", "method", ".", "getElementName", "(", ")", ")", ".", "append", "(", "\"(\"", ")", ".", "append", "(", "getMethodParameters", "(", "method", ",", "typeInfo", ",", "true", ")", ")", ".", "append", "(", "')'", ")", ";", "String", "[", "]", "exceptions", "=", "method", ".", "getExceptionTypes", "(", ")", ";", "if", "(", "exceptions", ".", "length", ">", "0", ")", "{", "buffer", ".", "append", "(", "\"ntthrows", "\"", ")", ".", "append", "(", "getMethodThrows", "(", "method", ")", ")", ";", "}", "return", "buffer", ".", "toString", "(", ")", ";", "}", "public", "static", "String", "getMinimalMethodSignature", "(", "IMethod", "method", ",", "TypeInfo", "typeInfo", ")", "throws", "Exception", "{", "StringBuffer", "buffer", "=", "new", "StringBuffer", "(", ")", ";", "buffer", ".", "append", "(", "method", ".", "getElementName", "(", ")", ")", ".", "append", "(", "'('", ")", ".", "append", "(", "getMethodParameters", "(", "method", ",", "typeInfo", ",", "false", ")", ")", ".", "append", "(", "')'", ")", ";", "return", "buffer", ".", "toString", "(", ")", ";", "}", "public", "static", "String", "getMethodParameters", "(", "IMethod", "method", ",", "TypeInfo", "typeInfo", ",", "boolean", "includeNames", ")", "throws", "Exception", "{", "StringBuffer", "buffer", "=", "new", "StringBuffer", "(", ")", ";", "String", "[", "]", "paramTypes", "=", "method", ".", "getParameterTypes", "(", ")", ";", "String", "[", "]", "paramNames", "=", "null", ";", "if", "(", "includeNames", ")", "{", "paramNames", "=", "method", ".", "getParameterNames", "(", ")", ";", "}", "boolean", "varargs", "=", "false", ";", "for", "(", "int", "ii", "=", "0", ";", "ii", "<", "paramTypes", ".", "length", ";", "ii", "++", ")", "{", "if", "(", "ii", "!=", "0", ")", "{", "buffer", ".", "append", "(", "includeNames", "?", "\",", "\"", ":", "\",\"", ")", ";", "}", "String", "type", "=", "paramTypes", "[", "ii", "]", ";", "if", "(", "ii", "==", "paramTypes", ".", "length", "-", "1", "&&", "Signature", ".", "getTypeSignatureKind", "(", "type", ")", "==", "Signature", ".", "ARRAY_TYPE_SIGNATURE", "&&", "Flags", ".", "isVarargs", "(", "method", ".", "getFlags", "(", ")", ")", ")", "{", "type", "=", "Signature", ".", "getElementType", "(", "paramTypes", "[", "ii", "]", ")", ";", "varargs", "=", "true", ";", "}", "type", "=", "Signature", ".", "getSignatureSimpleName", "(", "type", ")", ";", "type", "=", "type", ".", "replaceAll", "(", "\"\"", ",", "\"\"", ")", ";", "type", "=", "TypeUtils", ".", "replaceTypeParams", "(", "type", ",", "typeInfo", ")", ";", "buffer", ".", "append", "(", "type", ")", ";", "if", "(", "varargs", ")", "{", "buffer", ".", "append", "(", "VARARGS", ")", ";", "}", "if", "(", "includeNames", ")", "{", "buffer", ".", "append", "(", "'", "'", ")", ".", "append", "(", "paramNames", "[", "ii", "]", ")", ";", "}", "}", "return", "buffer", ".", "toString", "(", ")", ";", "}", "public", "static", "String", "getMethodThrows", "(", "IMethod", "method", ")", "throws", "Exception", "{", "String", "[", "]", "exceptions", "=", "method", ".", "getExceptionTypes", "(", ")", ";", "if", "(", "exceptions", ".", "length", ">", "0", ")", "{", "StringBuffer", "buffer", "=", "new", "StringBuffer", "(", ")", ";", "for", "(", "int", "ii", "=", "0", ";", "ii", "<", "exceptions", ".", "length", ";", "ii", "++", ")", "{", "if", "(", "ii", "!=", "0", ")", "{", "buffer", ".", "append", "(", "\",", "\"", ")", ";", "}", "buffer", ".", "append", "(", "Signature", ".", "getSignatureSimpleName", "(", "exceptions", "[", "ii", "]", ")", ")", ";", "}", "return", "buffer", ".", "toString", "(", ")", ";", "}", "return", "null", ";", "}", "}", "</s>" ]
1,203
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "util", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "eclim", ".", "logging", ".", "Logger", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "search", ".", "SearchRequestor", ";", "import", "org", ".", "eclim", ".", "util", ".", "StringUtils", ";", "import", "org", ".", "eclim", ".", "util", ".", "file", ".", "Position", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "Flags", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "ICompilationUnit", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IImportDeclaration", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IJavaElement", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IJavaProject", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IMethod", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IPackageDeclaration", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "ISourceRange", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "ISourceReference", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IType", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "ITypeParameter", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "Signature", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "search", ".", "IJavaSearchConstants", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "search", ".", "IJavaSearchScope", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "search", ".", "SearchEngine", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "search", ".", "SearchMatch", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "search", ".", "SearchParticipant", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "search", ".", "SearchPattern", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "core", ".", "CompilationUnit", ";", "public", "class", "TypeUtils", "{", "private", "static", "final", "Logger", "logger", "=", "Logger", ".", "getLogger", "(", "TypeUtils", ".", "class", ")", ";", "public", "static", "IType", "getType", "(", "ICompilationUnit", "src", ",", "int", "offset", ")", "throws", "Exception", "{", "IJavaElement", "element", "=", "src", ".", "getElementAt", "(", "offset", ")", ";", "IType", "type", "=", "null", ";", "if", "(", "element", "==", "null", ")", "{", "type", "=", "(", "(", "CompilationUnit", ")", "src", ")", ".", "getTypeRoot", "(", ")", ".", "findPrimaryType", "(", ")", ";", "}", "else", "if", "(", "element", "!=", "null", "&&", "element", ".", "getElementType", "(", ")", "==", "IJavaElement", ".", "TYPE", ")", "{", "type", "=", "(", "IType", ")", "element", ";", "}", "else", "{", "element", "=", "element", ".", "getParent", "(", ")", ";", "if", "(", "element", ".", "getElementType", "(", ")", "==", "IJavaElement", ".", "IMPORT_CONTAINER", ")", "{", "element", "=", "element", ".", "getParent", "(", ")", ";", "}", "if", "(", "element", ".", "getElementType", "(", ")", "==", "IJavaElement", ".", "COMPILATION_UNIT", ")", "{", "element", "=", "(", "(", "CompilationUnit", ")", "element", ")", ".", "getTypeRoot", "(", ")", ".", "findPrimaryType", "(", ")", ";", "}", "type", "=", "(", "IType", ")", "element", ";", "}", "return", "type", ";", "}", "public", "static", "Position", "getPosition", "(", "IType", "type", ",", "ISourceReference", "reference", ")", "throws", "Exception", "{", "ISourceRange", "range", "=", "reference", ".", "getSourceRange", "(", ")", ";", "return", "Position", ".", "fromOffset", "(", "type", ".", "getResource", "(", ")", ".", "getLocation", "(", ")", ".", "toOSString", "(", ")", ",", "null", ",", "range", ".", "getOffset", "(", ")", ",", "range", ".", "getLength", "(", ")", ")", ";", "}", "public", "static", "String", "getTypeSignature", "(", "TypeInfo", "typeInfo", ")", "throws", "Exception", "{", "StringBuffer", "buffer", "=", "new", "StringBuffer", "(", ")", ";", "IType", "type", "=", "typeInfo", ".", "getType", "(", ")", ";", "int", "flags", "=", "type", ".", "getFlags", "(", ")", ";", "if", "(", "Flags", ".", "isPublic", "(", "flags", ")", ")", "{", "buffer", ".", "append", "(", "\"public", "\"", ")", ";", "}", "buffer", ".", "append", "(", "type", ".", "isClass", "(", ")", "?", "\"class", "\"", ":", "\"interface", "\"", ")", ";", "IJavaElement", "parent", "=", "type", ".", "getParent", "(", ")", ";", "if", "(", "parent", ".", "getElementType", "(", ")", "==", "IJavaElement", ".", "TYPE", ")", "{", "buffer", ".", "append", "(", "type", ".", "getParent", "(", ")", ".", "getElementName", "(", ")", ")", ".", "append", "(", "'.'", ")", ";", "}", "else", "if", "(", "parent", ".", "getElementType", "(", ")", "==", "IJavaElement", ".", "CLASS_FILE", ")", "{", "int", "index", "=", "parent", ".", "getElementName", "(", ")", ".", "indexOf", "(", "'$'", ")", ";", "if", "(", "index", "!=", "-", "1", ")", "{", "buffer", ".", "append", "(", "parent", ".", "getElementName", "(", ")", ".", "substring", "(", "0", ",", "index", ")", ")", ".", "append", "(", "'.'", ")", ";", "}", "}", "buffer", ".", "append", "(", "type", ".", "getElementName", "(", ")", ")", ";", "String", "[", "]", "params", "=", "typeInfo", ".", "getTypeParameters", "(", ")", ";", "String", "[", "]", "args", "=", "typeInfo", ".", "getTypeArguments", "(", ")", ";", "if", "(", "params", "!=", "null", "&&", "params", ".", "length", ">", "0", "&&", "args", "!=", "null", "&&", "args", ".", "length", ">", "0", ")", "{", "buffer", ".", "append", "(", "'<'", ")", ";", "for", "(", "int", "ii", "=", "0", ";", "ii", "<", "args", ".", "length", ";", "ii", "++", ")", "{", "if", "(", "ii", ">", "0", ")", "{", "buffer", ".", "append", "(", "','", ")", ";", "}", "buffer", ".", "append", "(", "args", "[", "ii", "]", ")", ";", "}", "buffer", ".", "append", "(", "'>'", ")", ";", "}", "return", "buffer", ".", "toString", "(", ")", ";", "}", "public", "static", "TypeInfo", "getSuperTypeContainingMethod", "(", "IType", "type", ",", "IMethod", "method", ")", "throws", "Exception", "{", "TypeInfo", "[", "]", "types", "=", "getSuperTypes", "(", "type", ")", ";", "for", "(", "TypeInfo", "info", ":", "types", ")", "{", "IMethod", "[", "]", "methods", "=", "info", ".", "getType", "(", ")", ".", "getMethods", "(", ")", ";", "for", "(", "IMethod", "m", ":", "methods", ")", "{", "if", "(", "m", ".", "isSimilar", "(", "method", ")", ")", "{", "return", "info", ";", "}", "}", "}", "return", "null", ";", "}", "public", "static", "Object", "[", "]", "getSuperTypeContainingMethod", "(", "IType", "type", ",", "String", "signature", ")", "throws", "Exception", "{", "TypeInfo", "[", "]", "types", "=", "getSuperTypes", "(", "type", ")", ";", "for", "(", "TypeInfo", "info", ":", "types", ")", "{", "IMethod", "[", "]", "methods", "=", "info", ".", "getType", "(", ")", ".", "getMethods", "(", ")", ";", "for", "(", "IMethod", "method", ":", "methods", ")", "{", "String", "sig", "=", "MethodUtils", ".", "getMinimalMethodSignature", "(", "method", ",", "info", ")", ";", "if", "(", "sig", ".", "equals", "(", "signature", ")", ")", "{", "return", "new", "Object", "[", "]", "{", "info", ",", "method", "}", ";", "}", "}", "}", "return", "null", ";", "}", "public", "static", "String", "getBaseTypeFromGeneric", "(", "IType", "type", ",", "String", "typeSignature", ")", "throws", "Exception", "{", "int", "arrayCount", "=", "Signature", ".", "getArrayCount", "(", "typeSignature", ")", ";", "if", "(", "arrayCount", ">", "0", ")", "{", "for", "(", "int", "ii", "=", "0", ";", "ii", "<", "arrayCount", ";", "ii", "++", ")", "{", "typeSignature", "=", "Signature", ".", "getElementType", "(", "typeSignature", ")", ";", "}", "}", "String", "result", "=", "null", ";", "ITypeParameter", "param", "=", "type", ".", "getTypeParameter", "(", "Signature", ".", "getSignatureSimpleName", "(", "typeSignature", ")", ")", ";", "if", "(", "param", ".", "exists", "(", ")", ")", "{", "result", "=", "param", ".", "getBounds", "(", ")", "[", "0", "]", ";", "}", "else", "{", "result", "=", "Signature", ".", "getSignatureSimpleName", "(", "Signature", ".", "getTypeErasure", "(", "typeSignature", ")", ")", ";", "}", "if", "(", "arrayCount", ">", "0", ")", "{", "for", "(", "int", "ii", "=", "0", ";", "ii", "<", "arrayCount", ";", "ii", "++", ")", "{", "result", "=", "result", "+", "\"[]\"", ";", "}", "}", "return", "result", ";", "}", "public", "static", "IType", "findUnqualifiedType", "(", "ICompilationUnit", "src", ",", "String", "typeName", ")", "throws", "Exception", "{", "String", "name", "=", "\".\"", "+", "typeName", ";", "int", "index", "=", "name", ".", "indexOf", "(", "'<'", ")", ";", "if", "(", "index", "!=", "-", "1", ")", "{", "name", "=", "name", ".", "substring", "(", "0", ",", "index", ")", ";", "}", "IImportDeclaration", "[", "]", "imports", "=", "src", ".", "getImports", "(", ")", ";", "for", "(", "IImportDeclaration", "decl", ":", "imports", ")", "{", "if", "(", "decl", ".", "getElementName", "(", ")", ".", "endsWith", "(", "name", ")", ")", "{", "return", "src", ".", "getJavaProject", "(", ")", ".", "findType", "(", "decl", ".", "getElementName", "(", ")", ")", ";", "}", "}", "IPackageDeclaration", "[", "]", "packages", "=", "src", ".", "getPackageDeclarations", "(", ")", ";", "if", "(", "packages", "!=", "null", "&&", "packages", ".", "length", ">", "0", ")", "{", "name", "=", "packages", "[", "0", "]", ".", "getElementName", "(", ")", "+", "name", ";", "}", "else", "{", "name", "=", "typeName", ";", "}", "IType", "type", "=", "src", ".", "getJavaProject", "(", ")", ".", "findType", "(", "name", ")", ";", "if", "(", "type", "==", "null", ")", "{", "type", "=", "src", ".", "getJavaProject", "(", ")", ".", "findType", "(", "\"java.lang.\"", "+", "typeName", ")", ";", "}", "return", "type", ";", "}", "public", "static", "TypeInfo", "[", "]", "getSuperTypes", "(", "IType", "type", ")", "throws", "Exception", "{", "return", "getSuperTypes", "(", "type", ",", "false", ")", ";", "}", "public", "static", "TypeInfo", "[", "]", "getSuperTypes", "(", "IType", "type", ",", "boolean", "returnNotFound", ")", "throws", "Exception", "{", "TypeInfo", "[", "]", "interfaces", "=", "getInterfaces", "(", "type", ",", "returnNotFound", ")", ";", "TypeInfo", "[", "]", "superClasses", "=", "getSuperClasses", "(", "type", ",", "returnNotFound", ")", ";", "TypeInfo", "[", "]", "types", "=", "new", "TypeInfo", "[", "interfaces", ".", "length", "+", "superClasses", ".", "length", "]", ";", "System", ".", "arraycopy", "(", "interfaces", ",", "0", ",", "types", ",", "0", ",", "interfaces", ".", "length", ")", ";", "System", ".", "arraycopy", "(", "superClasses", ",", "0", ",", "types", ",", "interfaces", ".", "length", ",", "superClasses", ".", "length", ")", ";", "return", "types", ";", "}", "public", "static", "TypeInfo", "[", "]", "getSuperClasses", "(", "IType", "type", ")", "throws", "Exception", "{", "return", "getSuperClasses", "(", "type", ",", "false", ")", ";", "}", "public", "static", "TypeInfo", "[", "]", "getSuperClasses", "(", "IType", "type", ",", "boolean", "returnNotFound", ")", "throws", "Exception", "{", "ArrayList", "<", "TypeInfo", ">", "types", "=", "new", "ArrayList", "<", "TypeInfo", ">", "(", ")", ";", "getSuperClasses", "(", "type", ",", "types", ",", "returnNotFound", ",", "null", ")", ";", "IType", "objectType", "=", "type", ".", "getJavaProject", "(", ")", ".", "findType", "(", "\"\"", ")", ";", "TypeInfo", "objectTypeInfo", "=", "new", "TypeInfo", "(", "objectType", ",", "null", ",", "null", ")", ";", "if", "(", "!", "types", ".", "contains", "(", "objectTypeInfo", ")", ")", "{", "types", ".", "add", "(", "objectTypeInfo", ")", ";", "}", "return", "(", "TypeInfo", "[", "]", ")", "types", ".", "toArray", "(", "new", "TypeInfo", "[", "types", ".", "size", "(", ")", "]", ")", ";", "}", "public", "static", "TypeInfo", "[", "]", "getInterfaces", "(", "IType", "type", ")", "throws", "Exception", "{", "return", "getInterfaces", "(", "type", ",", "false", ")", ";", "}", "public", "static", "TypeInfo", "[", "]", "getInterfaces", "(", "IType", "type", ",", "boolean", "returnNotFound", ")", "throws", "Exception", "{", "ArrayList", "<", "TypeInfo", ">", "types", "=", "new", "ArrayList", "<", "TypeInfo", ">", "(", ")", ";", "getInterfaces", "(", "type", ",", "types", ",", "returnNotFound", ",", "null", ")", ";", "return", "(", "TypeInfo", "[", "]", ")", "types", ".", "toArray", "(", "new", "TypeInfo", "[", "types", ".", "size", "(", ")", "]", ")", ";", "}", "public", "static", "void", "getSuperClasses", "(", "IType", "type", ",", "List", "<", "TypeInfo", ">", "superclasses", ",", "boolean", "includeNotFound", ",", "TypeInfo", "baseType", ")", "throws", "Exception", "{", "TypeInfo", "superclassInfo", "=", "getSuperClass", "(", "type", ",", "baseType", ")", ";", "if", "(", "superclassInfo", "!=", "null", ")", "{", "if", "(", "baseType", "==", "null", "||", "baseType", ".", "getTypeArguments", "(", ")", ".", "length", "!=", "superclassInfo", ".", "getTypeArguments", "(", ")", ".", "length", ")", "{", "baseType", "=", "superclassInfo", ";", "}", "}", "if", "(", "superclassInfo", "!=", "null", "&&", "!", "superclasses", ".", "contains", "(", "superclassInfo", ")", ")", "{", "superclasses", ".", "add", "(", "superclassInfo", ")", ";", "getSuperClasses", "(", "superclassInfo", ".", "getType", "(", ")", ",", "superclasses", ",", "includeNotFound", ",", "baseType", ")", ";", "}", "else", "if", "(", "superclassInfo", "==", "null", "&&", "includeNotFound", ")", "{", "String", "typeName", "=", "type", ".", "getSuperclassName", "(", ")", ";", "if", "(", "typeName", "!=", "null", ")", "{", "try", "{", "IType", "superclass", "=", "type", ".", "getType", "(", "typeName", ")", ";", "superclassInfo", "=", "new", "TypeInfo", "(", "superclass", ",", "null", ",", "null", ")", ";", "if", "(", "!", "superclasses", ".", "contains", "(", "superclassInfo", ")", ")", "{", "superclasses", ".", "add", "(", "superclassInfo", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "logger", ".", "warn", "(", "\"\"", "+", "typeName", "+", "\"'\"", ",", "e", ")", ";", "}", "}", "}", "}", "public", "static", "TypeInfo", "getSuperClass", "(", "IType", "type", ")", "throws", "Exception", "{", "return", "getSuperClass", "(", "type", ",", "null", ")", ";", "}", "private", "static", "TypeInfo", "getSuperClass", "(", "IType", "type", ",", "TypeInfo", "baseType", ")", "throws", "Exception", "{", "String", "superclassSig", "=", "type", ".", "getSuperclassTypeSignature", "(", ")", ";", "if", "(", "superclassSig", "!=", "null", ")", "{", "String", "qualifier", "=", "Signature", ".", "getSignatureQualifier", "(", "superclassSig", ")", ";", "qualifier", "=", "(", "qualifier", "!=", "null", "&&", "!", "qualifier", ".", "equals", "(", "StringUtils", ".", "EMPTY", ")", ")", "?", "qualifier", "+", "'.'", ":", "StringUtils", ".", "EMPTY", ";", "String", "superclass", "=", "qualifier", "+", "Signature", ".", "getSignatureSimpleName", "(", "superclassSig", ")", ";", "String", "[", "]", "args", "=", "Signature", ".", "getTypeArguments", "(", "superclassSig", ")", ";", "String", "[", "]", "typeArgs", "=", "new", "String", "[", "args", ".", "length", "]", ";", "for", "(", "int", "ii", "=", "0", ";", "ii", "<", "args", ".", "length", ";", "ii", "++", ")", "{", "typeArgs", "[", "ii", "]", "=", "Signature", ".", "getSignatureSimpleName", "(", "args", "[", "ii", "]", ")", ";", "}", "if", "(", "baseType", "!=", "null", "&&", "baseType", ".", "getTypeArguments", "(", ")", ".", "length", "==", "typeArgs", ".", "length", ")", "{", "typeArgs", "=", "baseType", ".", "getTypeArguments", "(", ")", ";", "}", "String", "[", "]", "[", "]", "types", "=", "type", ".", "resolveType", "(", "superclass", ")", ";", "if", "(", "types", "!=", "null", ")", "{", "for", "(", "String", "[", "]", "typeInfo", ":", "types", ")", "{", "String", "typeName", "=", "typeInfo", "[", "0", "]", "+", "\".\"", "+", "typeInfo", "[", "1", "]", ";", "IType", "found", "=", "type", ".", "getJavaProject", "(", ")", ".", "findType", "(", "typeName", ")", ";", "if", "(", "found", "!=", "null", ")", "{", "ITypeParameter", "[", "]", "params", "=", "found", ".", "getTypeParameters", "(", ")", ";", "String", "[", "]", "typeParams", "=", "new", "String", "[", "params", ".", "length", "]", ";", "for", "(", "int", "ii", "=", "0", ";", "ii", "<", "params", ".", "length", ";", "ii", "++", ")", "{", "typeParams", "[", "ii", "]", "=", "params", "[", "ii", "]", ".", "getElementName", "(", ")", ";", "}", "return", "new", "TypeInfo", "(", "found", ",", "typeParams", ",", "typeArgs", ")", ";", "}", "}", "}", "else", "{", "IType", "found", "=", "type", ".", "getJavaProject", "(", ")", ".", "findType", "(", "superclass", ")", ";", "if", "(", "found", "!=", "null", ")", "{", "return", "new", "TypeInfo", "(", "found", ",", "null", ",", "typeArgs", ")", ";", "}", "}", "}", "return", "null", ";", "}", "public", "static", "IType", "[", "]", "getSuperInterfaces", "(", "IType", "type", ")", "throws", "Exception", "{", "String", "[", "]", "parents", "=", "type", ".", "getSuperInterfaceNames", "(", ")", ";", "ArrayList", "<", "IType", ">", "interfaces", "=", "new", "ArrayList", "<", "IType", ">", "(", "parents", ".", "length", ")", ";", "for", "(", "String", "parent", ":", "parents", ")", "{", "String", "[", "]", "[", "]", "types", "=", "type", ".", "resolveType", "(", "parent", ")", ";", "if", "(", "types", "!=", "null", ")", "{", "for", "(", "String", "[", "]", "typeInfo", ":", "types", ")", "{", "String", "typeName", "=", "typeInfo", "[", "0", "]", "+", "\".\"", "+", "typeInfo", "[", "1", "]", ";", "IType", "found", "=", "type", ".", "getJavaProject", "(", ")", ".", "findType", "(", "typeName", ")", ";", "if", "(", "found", "!=", "null", ")", "{", "interfaces", ".", "add", "(", "found", ")", ";", "}", "}", "}", "else", "{", "IType", "found", "=", "type", ".", "getJavaProject", "(", ")", ".", "findType", "(", "parent", ")", ";", "if", "(", "found", "!=", "null", ")", "{", "interfaces", ".", "add", "(", "found", ")", ";", "}", "}", "}", "return", "interfaces", ".", "toArray", "(", "new", "IType", "[", "interfaces", ".", "size", "(", ")", "]", ")", ";", "}", "public", "static", "void", "getInterfaces", "(", "IType", "type", ",", "List", "<", "TypeInfo", ">", "interfaces", ",", "boolean", "includeNotFound", ",", "TypeInfo", "baseType", ")", "throws", "Exception", "{", "String", "[", "]", "parentSigs", "=", "type", ".", "getSuperInterfaceTypeSignatures", "(", ")", ";", "for", "(", "String", "parentSig", ":", "parentSigs", ")", "{", "String", "parent", "=", "Signature", ".", "getSignatureSimpleName", "(", "parentSig", ")", ";", "String", "[", "]", "args", "=", "Signature", ".", "getTypeArguments", "(", "parentSig", ")", ";", "String", "[", "]", "typeArgs", "=", "new", "String", "[", "args", ".", "length", "]", ";", "for", "(", "int", "ii", "=", "0", ";", "ii", "<", "args", ".", "length", ";", "ii", "++", ")", "{", "typeArgs", "[", "ii", "]", "=", "Signature", ".", "getSignatureSimpleName", "(", "args", "[", "ii", "]", ")", ";", "}", "if", "(", "baseType", "!=", "null", "&&", "baseType", ".", "getTypeArguments", "(", ")", ".", "length", "==", "typeArgs", ".", "length", ")", "{", "typeArgs", "=", "baseType", ".", "getTypeArguments", "(", ")", ";", "}", "IType", "found", "=", "null", ";", "String", "[", "]", "[", "]", "types", "=", "type", ".", "resolveType", "(", "parent", ")", ";", "if", "(", "types", "!=", "null", ")", "{", "for", "(", "String", "[", "]", "typeInfo", ":", "types", ")", "{", "String", "typeName", "=", "typeInfo", "[", "0", "]", "+", "\".\"", "+", "typeInfo", "[", "1", "]", ";", "found", "=", "type", ".", "getJavaProject", "(", ")", ".", "findType", "(", "typeName", ")", ";", "}", "}", "else", "{", "found", "=", "type", ".", "getJavaProject", "(", ")", ".", "findType", "(", "parent", ")", ";", "}", "if", "(", "found", "!=", "null", ")", "{", "ITypeParameter", "[", "]", "params", "=", "found", ".", "getTypeParameters", "(", ")", ";", "String", "[", "]", "typeParams", "=", "new", "String", "[", "params", ".", "length", "]", ";", "for", "(", "int", "ii", "=", "0", ";", "ii", "<", "params", ".", "length", ";", "ii", "++", ")", "{", "typeParams", "[", "ii", "]", "=", "params", "[", "ii", "]", ".", "getElementName", "(", ")", ";", "}", "TypeInfo", "typeInfo", "=", "new", "TypeInfo", "(", "found", ",", "typeParams", ",", "typeArgs", ")", ";", "if", "(", "!", "interfaces", ".", "contains", "(", "typeInfo", ")", ")", "{", "interfaces", ".", "add", "(", "typeInfo", ")", ";", "if", "(", "baseType", "==", "null", "||", "baseType", ".", "getTypeArguments", "(", ")", ".", "length", "!=", "typeInfo", ".", "getTypeArguments", "(", ")", ".", "length", ")", "{", "baseType", "=", "typeInfo", ";", "}", "getInterfaces", "(", "found", ",", "interfaces", ",", "includeNotFound", ",", "baseType", ")", ";", "}", "}", "else", "if", "(", "found", "==", "null", "&&", "includeNotFound", ")", "{", "String", "typeName", "=", "parent", ";", "if", "(", "typeName", "!=", "null", ")", "{", "try", "{", "found", "=", "type", ".", "getType", "(", "typeName", ")", ";", "TypeInfo", "typeInfo", "=", "new", "TypeInfo", "(", "found", ",", "null", ",", "typeArgs", ")", ";", "if", "(", "!", "interfaces", ".", "contains", "(", "typeInfo", ")", ")", "{", "interfaces", ".", "add", "(", "typeInfo", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "logger", ".", "warn", "(", "\"\"", "+", "typeName", "+", "\"'\"", ",", "e", ")", ";", "}", "}", "}", "else", "if", "(", "found", "==", "null", ")", "{", "logger", ".", "warn", "(", "\"\"", ",", "parent", ",", "type", ".", "getFullyQualifiedName", "(", ")", ")", ";", "}", "}", "TypeInfo", "superclassInfo", "=", "getSuperClass", "(", "type", ")", ";", "if", "(", "superclassInfo", "!=", "null", ")", "{", "getInterfaces", "(", "superclassInfo", ".", "getType", "(", ")", ",", "interfaces", ",", "includeNotFound", ",", "superclassInfo", ")", ";", "}", "}", "public", "static", "String", "replaceTypeParams", "(", "String", "type", ",", "TypeInfo", "typeInfo", ")", "{", "if", "(", "typeInfo", "!=", "null", ")", "{", "String", "[", "]", "params", "=", "typeInfo", ".", "getTypeParameters", "(", ")", ";", "String", "[", "]", "args", "=", "typeInfo", ".", "getTypeArguments", "(", ")", ";", "if", "(", "params", "!=", "null", "&&", "params", ".", "length", "==", "args", ".", "length", ")", "{", "for", "(", "int", "ii", "=", "0", ";", "ii", "<", "params", ".", "length", ";", "ii", "++", ")", "{", "type", "=", "type", ".", "replaceAll", "(", "\"\\\\b\"", "+", "params", "[", "ii", "]", "+", "\"\\\\b\"", ",", "args", "[", "ii", "]", ")", ";", "}", "}", "}", "return", "type", ";", "}", "public", "static", "IType", "[", "]", "findTypes", "(", "IJavaProject", "javaProject", ",", "String", "name", ")", "throws", "Exception", "{", "SearchPattern", "pattern", "=", "SearchPattern", ".", "createPattern", "(", "name", ",", "IJavaSearchConstants", ".", "TYPE", ",", "IJavaSearchConstants", ".", "DECLARATIONS", ",", "SearchPattern", ".", "R_EXACT_MATCH", "|", "SearchPattern", ".", "R_CASE_SENSITIVE", ")", ";", "IJavaSearchScope", "scope", "=", "SearchEngine", ".", "createJavaSearchScope", "(", "new", "IJavaElement", "[", "]", "{", "javaProject", "}", ")", ";", "SearchRequestor", "requestor", "=", "new", "SearchRequestor", "(", ")", ";", "SearchEngine", "engine", "=", "new", "SearchEngine", "(", ")", ";", "SearchParticipant", "[", "]", "participants", "=", "new", "SearchParticipant", "[", "]", "{", "SearchEngine", ".", "getDefaultSearchParticipant", "(", ")", "}", ";", "engine", ".", "search", "(", "pattern", ",", "participants", ",", "scope", ",", "requestor", ",", "null", ")", ";", "ArrayList", "<", "IType", ">", "types", "=", "new", "ArrayList", "<", "IType", ">", "(", ")", ";", "if", "(", "requestor", ".", "getMatches", "(", ")", ".", "size", "(", ")", ">", "0", ")", "{", "for", "(", "SearchMatch", "match", ":", "requestor", ".", "getMatches", "(", ")", ")", "{", "if", "(", "match", ".", "getAccuracy", "(", ")", "!=", "SearchMatch", ".", "A_ACCURATE", ")", "{", "continue", ";", "}", "IJavaElement", "element", "=", "(", "IJavaElement", ")", "match", ".", "getElement", "(", ")", ";", "if", "(", "element", ".", "getElementType", "(", ")", "==", "IJavaElement", ".", "TYPE", ")", "{", "types", ".", "add", "(", "(", "IType", ")", "element", ")", ";", "}", "}", "}", "return", "types", ".", "toArray", "(", "new", "IType", "[", "types", ".", "size", "(", ")", "]", ")", ";", "}", "}", "</s>" ]
1,204
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "util", ";", "import", "java", ".", "io", ".", "BufferedReader", ";", "import", "java", ".", "io", ".", "InputStreamReader", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Hashtable", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "java", ".", "util", ".", "regex", ".", "Matcher", ";", "import", "java", ".", "util", ".", "regex", ".", "Pattern", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang", ".", "StringUtils", ";", "import", "org", ".", "apache", ".", "commons", ".", "vfs", ".", "FileObject", ";", "import", "org", ".", "apache", ".", "commons", ".", "vfs", ".", "FileSystemManager", ";", "import", "org", ".", "apache", ".", "commons", ".", "vfs", ".", "VFS", ";", "import", "org", ".", "eclim", ".", "Services", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "preference", ".", "Preferences", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "project", ".", "ProjectNatureFactory", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "util", ".", "ProjectUtils", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "PluginResources", ";", "import", "org", ".", "eclim", ".", "util", ".", "IOUtils", ";", "import", "org", ".", "eclim", ".", "util", ".", "file", ".", "FileUtils", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "IProject", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "ResourcesPlugin", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "IConfigurationElement", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "IPath", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "IStatus", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "Path", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "Platform", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IBuffer", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IClassFile", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "ICompilationUnit", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IField", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IImportDeclaration", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IJavaElement", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IJavaProject", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IMethod", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IPackageDeclaration", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IType", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "JavaCore", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "Signature", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "compiler", ".", "IProblem", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "formatter", ".", "IndentManipulation", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "core", ".", "DocumentAdapter", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "corext", ".", "codemanipulation", ".", "StubUtility", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "formatter", ".", "DefaultCodeFormatter", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "ui", ".", "JavaPlugin", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "ui", ".", "text", ".", "correction", ".", "ContributedProcessorDescriptor", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "ui", ".", "JavaUI", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "ui", ".", "text", ".", "java", ".", "IQuickAssistProcessor", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "ui", ".", "text", ".", "java", ".", "IQuickFixProcessor", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "text", ".", "Document", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "text", ".", "IDocument", ";", "import", "org", ".", "eclipse", ".", "text", ".", "edits", ".", "TextEdit", ";", "public", "class", "JavaUtils", "{", "public", "static", "final", "String", "JAVA_LANG", "=", "\"java.lang\"", ";", "private", "static", "final", "Pattern", "PACKAGE_LINE", "=", "Pattern", ".", "compile", "(", "\"\"", ")", ";", "private", "static", "final", "Pattern", "TRAILING_WHITESPACE", "=", "Pattern", ".", "compile", "(", "\"[", "t]+$\"", ",", "Pattern", ".", "MULTILINE", ")", ";", "private", "static", "ContributedProcessorDescriptor", "[", "]", "correctionProcessors", ";", "private", "static", "ContributedProcessorDescriptor", "[", "]", "assistProcessors", ";", "public", "static", "IJavaProject", "getJavaProject", "(", "String", "project", ")", "throws", "Exception", "{", "return", "getJavaProject", "(", "ProjectUtils", ".", "getProject", "(", "project", ",", "true", ")", ")", ";", "}", "public", "static", "IJavaProject", "getJavaProject", "(", "IProject", "project", ")", "throws", "Exception", "{", "if", "(", "ProjectUtils", ".", "getPath", "(", "project", ")", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "Services", ".", "getMessage", "(", "\"\"", ",", "project", ".", "getName", "(", ")", ")", ")", ";", "}", "if", "(", "!", "project", ".", "hasNature", "(", "PluginResources", ".", "NATURE", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "Services", ".", "getMessage", "(", "\"\"", ",", "project", ".", "getName", "(", ")", ",", "ProjectNatureFactory", ".", "getAliasForNature", "(", "PluginResources", ".", "NATURE", ")", ")", ")", ";", "}", "IJavaProject", "javaProject", "=", "JavaCore", ".", "create", "(", "project", ")", ";", "if", "(", "javaProject", "==", "null", "||", "!", "javaProject", ".", "exists", "(", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "Services", ".", "getMessage", "(", "\"\"", ",", "project", ")", ")", ";", "}", "return", "javaProject", ";", "}", "public", "static", "ICompilationUnit", "getCompilationUnit", "(", "String", "project", ",", "String", "file", ")", "throws", "Exception", "{", "IJavaProject", "javaProject", "=", "getJavaProject", "(", "project", ")", ";", "return", "getCompilationUnit", "(", "javaProject", ",", "file", ")", ";", "}", "public", "static", "ICompilationUnit", "getCompilationUnit", "(", "String", "file", ")", "throws", "Exception", "{", "IProject", "[", "]", "projects", "=", "ResourcesPlugin", ".", "getWorkspace", "(", ")", ".", "getRoot", "(", ")", ".", "getProjects", "(", ")", ";", "for", "(", "int", "ii", "=", "0", ";", "ii", "<", "projects", ".", "length", ";", "ii", "++", ")", "{", "IJavaProject", "javaProject", "=", "getJavaProject", "(", "projects", "[", "ii", "]", ")", ";", "ICompilationUnit", "src", "=", "JavaCore", ".", "createCompilationUnitFrom", "(", "ProjectUtils", ".", "getFile", "(", "javaProject", ".", "getProject", "(", ")", ",", "file", ")", ")", ";", "if", "(", "src", "!=", "null", "&&", "src", ".", "exists", "(", ")", ")", "{", "return", "src", ";", "}", "}", "throw", "new", "IllegalArgumentException", "(", "Services", ".", "getMessage", "(", "\"\"", ",", "file", ",", "\".classpath\"", ")", ")", ";", "}", "public", "static", "ICompilationUnit", "getCompilationUnit", "(", "IJavaProject", "project", ",", "String", "file", ")", "throws", "Exception", "{", "ICompilationUnit", "src", "=", "JavaCore", ".", "createCompilationUnitFrom", "(", "ProjectUtils", ".", "getFile", "(", "project", ".", "getProject", "(", ")", ",", "file", ")", ")", ";", "if", "(", "src", "==", "null", "||", "!", "src", ".", "exists", "(", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "Services", ".", "getMessage", "(", "\"\"", ",", "file", ",", "\".classpath\"", ")", ")", ";", "}", "return", "src", ";", "}", "public", "static", "ICompilationUnit", "findCompilationUnit", "(", "String", "project", ",", "String", "file", ")", "throws", "Exception", "{", "IPath", "path", "=", "Path", ".", "fromOSString", "(", "file", ")", ";", "IJavaProject", "javaProject", "=", "getJavaProject", "(", "project", ")", ";", "javaProject", ".", "open", "(", "null", ")", ";", "ICompilationUnit", "src", "=", "(", "ICompilationUnit", ")", "javaProject", ".", "findElement", "(", "path", ")", ";", "return", "src", ";", "}", "public", "static", "ICompilationUnit", "findCompilationUnit", "(", "String", "file", ")", "throws", "Exception", "{", "IPath", "path", "=", "Path", ".", "fromOSString", "(", "file", ")", ";", "IProject", "[", "]", "projects", "=", "ResourcesPlugin", ".", "getWorkspace", "(", ")", ".", "getRoot", "(", ")", ".", "getProjects", "(", ")", ";", "for", "(", "IProject", "project", ":", "projects", ")", "{", "if", "(", "project", ".", "hasNature", "(", "JavaCore", ".", "NATURE_ID", ")", ")", "{", "IJavaProject", "javaProject", "=", "getJavaProject", "(", "project", ")", ";", "javaProject", ".", "open", "(", "null", ")", ";", "ICompilationUnit", "src", "=", "(", "ICompilationUnit", ")", "javaProject", ".", "findElement", "(", "path", ")", ";", "if", "(", "src", "!=", "null", ")", "{", "return", "src", ";", "}", "}", "}", "return", "null", ";", "}", "public", "static", "IClassFile", "findClassFile", "(", "IJavaProject", "project", ",", "String", "path", ")", "throws", "Exception", "{", "if", "(", "path", ".", "startsWith", "(", "\"/\"", ")", "||", "path", ".", "toLowerCase", "(", ")", ".", "startsWith", "(", "\"jar:\"", ")", "||", "path", ".", "toLowerCase", "(", ")", ".", "startsWith", "(", "\"zip:\"", ")", ")", "{", "FileSystemManager", "fsManager", "=", "VFS", ".", "getManager", "(", ")", ";", "FileObject", "file", "=", "fsManager", ".", "resolveFile", "(", "path", ")", ";", "if", "(", "file", ".", "exists", "(", ")", ")", "{", "BufferedReader", "in", "=", "null", ";", "try", "{", "in", "=", "new", "BufferedReader", "(", "new", "InputStreamReader", "(", "file", ".", "getContent", "(", ")", ".", "getInputStream", "(", ")", ")", ")", ";", "String", "pack", "=", "null", ";", "String", "line", "=", "null", ";", "while", "(", "(", "line", "=", "in", ".", "readLine", "(", ")", ")", "!=", "null", ")", "{", "Matcher", "matcher", "=", "PACKAGE_LINE", ".", "matcher", "(", "line", ")", ";", "if", "(", "matcher", ".", "matches", "(", ")", ")", "{", "pack", "=", "matcher", ".", "group", "(", "1", ")", ";", "break", ";", "}", "}", "if", "(", "pack", "!=", "null", ")", "{", "String", "name", "=", "pack", "+", "'.'", "+", "FileUtils", ".", "getFileName", "(", "file", ".", "getName", "(", ")", ".", "getPath", "(", ")", ")", ";", "IType", "type", "=", "project", ".", "findType", "(", "name", ")", ";", "if", "(", "type", "!=", "null", ")", "{", "return", "type", ".", "getClassFile", "(", ")", ";", "}", "}", "}", "finally", "{", "IOUtils", ".", "closeQuietly", "(", "in", ")", ";", "}", "}", "}", "return", "null", ";", "}", "public", "static", "IJavaElement", "getPrimaryElement", "(", "IJavaElement", "element", ")", "{", "IJavaElement", "parent", "=", "element", ";", "while", "(", "parent", ".", "getElementType", "(", ")", "!=", "IJavaElement", ".", "COMPILATION_UNIT", "&&", "parent", ".", "getElementType", "(", ")", "!=", "IJavaElement", ".", "CLASS_FILE", ")", "{", "parent", "=", "parent", ".", "getParent", "(", ")", ";", "}", "return", "parent", ";", "}", "public", "static", "IDocument", "getDocument", "(", "ICompilationUnit", "src", ")", "throws", "Exception", "{", "IBuffer", "buffer", "=", "src", ".", "getBuffer", "(", ")", ";", "if", "(", "buffer", "instanceof", "IDocument", ")", "{", "return", "(", "IDocument", ")", "buffer", ";", "}", "return", "new", "DocumentAdapter", "(", "buffer", ")", ";", "}", "public", "static", "String", "getFullyQualifiedName", "(", "IJavaElement", "element", ")", "{", "IJavaElement", "parent", "=", "element", ";", "while", "(", "parent", ".", "getElementType", "(", ")", "!=", "IJavaElement", ".", "COMPILATION_UNIT", "&&", "parent", ".", "getElementType", "(", ")", "!=", "IJavaElement", ".", "CLASS_FILE", ")", "{", "parent", "=", "parent", ".", "getParent", "(", ")", ";", "}", "StringBuffer", "elementName", "=", "new", "StringBuffer", "(", ")", ".", "append", "(", "parent", ".", "getParent", "(", ")", ".", "getElementName", "(", ")", ")", ".", "append", "(", "'.'", ")", ".", "append", "(", "FileUtils", ".", "getFileName", "(", "parent", ".", "getElementName", "(", ")", ")", ")", ";", "switch", "(", "element", ".", "getElementType", "(", ")", ")", "{", "case", "IJavaElement", ".", "FIELD", ":", "IField", "field", "=", "(", "IField", ")", "element", ";", "elementName", ".", "append", "(", "'#'", ")", ".", "append", "(", "field", ".", "getElementName", "(", ")", ")", ";", "break", ";", "case", "IJavaElement", ".", "METHOD", ":", "IMethod", "method", "=", "(", "IMethod", ")", "element", ";", "elementName", ".", "append", "(", "'#'", ")", ".", "append", "(", "method", ".", "getElementName", "(", ")", ")", ".", "append", "(", "'('", ")", ";", "String", "[", "]", "parameters", "=", "method", ".", "getParameterTypes", "(", ")", ";", "for", "(", "int", "ii", "=", "0", ";", "ii", "<", "parameters", ".", "length", ";", "ii", "++", ")", "{", "if", "(", "ii", "!=", "0", ")", "{", "elementName", ".", "append", "(", "\",", "\"", ")", ";", "}", "elementName", ".", "append", "(", "Signature", ".", "toString", "(", "parameters", "[", "ii", "]", ")", ".", "replace", "(", "'/'", ",", "'.'", ")", ")", ";", "}", "elementName", ".", "append", "(", "')'", ")", ";", "break", ";", "}", "return", "elementName", ".", "toString", "(", ")", ";", "}", "public", "static", "String", "getCompilationUnitRelativeTypeName", "(", "ICompilationUnit", "src", ",", "IType", "type", ")", "throws", "Exception", "{", "String", "typeName", "=", "type", ".", "getFullyQualifiedName", "(", ")", ".", "replace", "(", "'$'", ",", "'.'", ")", ";", "if", "(", "JavaUtils", ".", "containsImport", "(", "src", ",", "type", ")", ")", "{", "typeName", "=", "type", ".", "getElementName", "(", ")", ";", "int", "parentType", "=", "type", ".", "getParent", "(", ")", ".", "getElementType", "(", ")", ";", "if", "(", "parentType", "==", "IJavaElement", ".", "TYPE", ")", "{", "typeName", "=", "type", ".", "getParent", "(", ")", ".", "getElementName", "(", ")", "+", "'.'", "+", "typeName", ";", "}", "else", "if", "(", "parentType", "==", "IJavaElement", ".", "CLASS_FILE", ")", "{", "String", "parentName", "=", "type", ".", "getParent", "(", ")", ".", "getElementName", "(", ")", ";", "int", "index", "=", "parentName", ".", "indexOf", "(", "'$'", ")", ";", "if", "(", "index", "!=", "-", "1", ")", "{", "parentName", "=", "parentName", ".", "substring", "(", "0", ",", "index", ")", ";", "typeName", "=", "parentName", "+", "'.'", "+", "typeName", ";", "}", "}", "}", "else", "{", "typeName", "=", "type", ".", "getFullyQualifiedName", "(", ")", ".", "replace", "(", "'$'", ",", "'.'", ")", ";", "}", "return", "typeName", ";", "}", "public", "static", "boolean", "containsImport", "(", "ICompilationUnit", "src", ",", "String", "type", ")", "throws", "Exception", "{", "return", "containsImport", "(", "src", ",", "src", ".", "getType", "(", "type", ")", ")", ";", "}", "public", "static", "boolean", "containsImport", "(", "ICompilationUnit", "src", ",", "IType", "type", ")", "throws", "Exception", "{", "String", "typePkg", "=", "type", ".", "getPackageFragment", "(", ")", ".", "getElementName", "(", ")", ";", "IPackageDeclaration", "[", "]", "packages", "=", "src", ".", "getPackageDeclarations", "(", ")", ";", "String", "pkg", "=", "packages", ".", "length", ">", "0", "?", "packages", "[", "0", "]", ".", "getElementName", "(", ")", ":", "null", ";", "if", "(", "(", "pkg", "==", "null", "&&", "typePkg", "==", "null", ")", "||", "(", "pkg", "!=", "null", "&&", "pkg", ".", "equals", "(", "typePkg", ")", ")", ")", "{", "return", "true", ";", "}", "if", "(", "JAVA_LANG", ".", "equals", "(", "typePkg", ")", ")", "{", "return", "true", ";", "}", "typePkg", "=", "typePkg", "+", "\".*\"", ";", "String", "typeName", "=", "type", ".", "getFullyQualifiedName", "(", ")", ".", "replace", "(", "'$'", ",", "'.'", ")", ";", "IImportDeclaration", "[", "]", "imports", "=", "src", ".", "getImports", "(", ")", ";", "for", "(", "int", "ii", "=", "0", ";", "ii", "<", "imports", ".", "length", ";", "ii", "++", ")", "{", "String", "name", "=", "imports", "[", "ii", "]", ".", "getElementName", "(", ")", ";", "if", "(", "name", ".", "equals", "(", "typeName", ")", "||", "name", ".", "equals", "(", "typePkg", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}", "public", "static", "void", "format", "(", "ICompilationUnit", "src", ",", "int", "kind", ",", "int", "offset", ",", "int", "length", ")", "throws", "Exception", "{", "IBuffer", "buffer", "=", "src", ".", "getBuffer", "(", ")", ";", "String", "contents", "=", "buffer", ".", "getContents", "(", ")", ";", "String", "delimiter", "=", "StubUtility", ".", "getLineDelimiterUsed", "(", "src", ")", ";", "DefaultCodeFormatter", "formatter", "=", "new", "DefaultCodeFormatter", "(", "src", ".", "getJavaProject", "(", ")", ".", "getOptions", "(", "true", ")", ")", ";", "while", "(", "offset", ">", "0", "&&", "!", "IndentManipulation", ".", "isLineDelimiterChar", "(", "buffer", ".", "getChar", "(", "offset", "-", "1", ")", ")", ")", "{", "offset", "--", ";", "length", "++", ";", "}", "while", "(", "(", "offset", "+", "length", ")", "<", "contents", ".", "length", "(", ")", "&&", "IndentManipulation", ".", "isLineDelimiterChar", "(", "buffer", ".", "getChar", "(", "offset", "+", "length", ")", ")", ")", "{", "length", "++", ";", "}", "TextEdit", "edits", "=", "formatter", ".", "format", "(", "kind", ",", "contents", ",", "offset", ",", "length", ",", "0", ",", "delimiter", ")", ";", "if", "(", "edits", "!=", "null", ")", "{", "int", "oldLength", "=", "contents", ".", "length", "(", ")", ";", "Document", "document", "=", "new", "Document", "(", "contents", ")", ";", "edits", ".", "apply", "(", "document", ")", ";", "String", "formatted", "=", "document", ".", "get", "(", ")", ";", "length", "+=", "formatted", ".", "length", "(", ")", "-", "oldLength", ";", "if", "(", "offset", "<", "(", "offset", "+", "length", ")", ")", "{", "String", "pre", "=", "formatted", ".", "substring", "(", "0", ",", "offset", ")", ";", "StringBuffer", "section", "=", "new", "StringBuffer", "(", "formatted", ".", "substring", "(", "offset", ",", "offset", "+", "length", ")", ")", ";", "StringBuffer", "post", "=", "new", "StringBuffer", "(", "formatted", ".", "substring", "(", "offset", "+", "length", ")", ")", ";", "while", "(", "!", "section", ".", "toString", "(", ")", ".", "endsWith", "(", "delimiter", ")", "&&", "post", ".", "length", "(", ")", ">", "0", ")", "{", "section", ".", "append", "(", "post", ".", "charAt", "(", "0", ")", ")", ";", "post", ".", "deleteCharAt", "(", "0", ")", ";", "}", "Matcher", "matcher", "=", "TRAILING_WHITESPACE", ".", "matcher", "(", "section", ")", ";", "String", "stripped", "=", "matcher", ".", "replaceAll", "(", "StringUtils", ".", "EMPTY", ")", ";", "src", ".", "getBuffer", "(", ")", ".", "setContents", "(", "pre", "+", "stripped", "+", "post", ")", ";", "}", "else", "{", "src", ".", "getBuffer", "(", ")", ".", "setContents", "(", "formatted", ")", ";", "}", "if", "(", "src", ".", "isWorkingCopy", "(", ")", ")", "{", "src", ".", "commitWorkingCopy", "(", "false", ",", "null", ")", ";", "}", "src", ".", "save", "(", "null", ",", "false", ")", ";", "}", "}", "public", "static", "String", "getCompilerSourceCompliance", "(", "IJavaProject", "project", ")", "{", "return", "(", "String", ")", "project", ".", "getOptions", "(", "true", ")", ".", "get", "(", "JavaCore", ".", "COMPILER_SOURCE", ")", ";", "}", "@", "SuppressWarnings", "(", "{", "\"unchecked\"", ",", "\"rawtypes\"", "}", ")", "public", "static", "void", "setCompilerSourceCompliance", "(", "String", "version", ")", "throws", "Exception", "{", "Map", "<", "String", ",", "String", ">", "options", "=", "JavaCore", ".", "getOptions", "(", ")", ";", "options", ".", "put", "(", "JavaCore", ".", "COMPILER_SOURCE", ",", "version", ")", ";", "options", ".", "put", "(", "JavaCore", ".", "COMPILER_COMPLIANCE", ",", "version", ")", ";", "options", ".", "put", "(", "JavaCore", ".", "COMPILER_CODEGEN_TARGET_PLATFORM", ",", "version", ")", ";", "JavaCore", ".", "setOptions", "(", "(", "Hashtable", ")", "options", ")", ";", "}", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "static", "void", "setCompilerSourceCompliance", "(", "IJavaProject", "project", ",", "String", "version", ")", "throws", "Exception", "{", "Map", "<", "String", ",", "String", ">", "options", "=", "project", ".", "getOptions", "(", "false", ")", ";", "options", ".", "put", "(", "JavaCore", ".", "COMPILER_SOURCE", ",", "version", ")", ";", "options", ".", "put", "(", "JavaCore", ".", "COMPILER_COMPLIANCE", ",", "version", ")", ";", "options", ".", "put", "(", "JavaCore", ".", "COMPILER_CODEGEN_TARGET_PLATFORM", ",", "version", ")", ";", "project", ".", "setOptions", "(", "options", ")", ";", "}", "public", "static", "void", "loadPreferencesForTemplate", "(", "IProject", "project", ",", "Preferences", "preferences", ",", "Map", "<", "String", ",", "Object", ">", "values", ")", "throws", "Exception", "{", "Map", "<", "String", ",", "String", ">", "options", "=", "preferences", ".", "getValues", "(", "project", ")", ";", "for", "(", "String", "key", ":", "options", ".", "keySet", "(", ")", ")", "{", "String", "value", "=", "options", ".", "get", "(", "key", ")", ";", "values", ".", "put", "(", "key", ".", "replace", "(", "'.'", ",", "'_'", ")", ",", "value", ")", ";", "}", "}", "public", "static", "IProblem", "[", "]", "getProblems", "(", "ICompilationUnit", "src", ")", "throws", "Exception", "{", "return", "getProblems", "(", "src", ",", "null", ")", ";", "}", "public", "static", "IProblem", "[", "]", "getProblems", "(", "ICompilationUnit", "src", ",", "int", "[", "]", "ids", ")", "throws", "Exception", "{", "ICompilationUnit", "workingCopy", "=", "src", ".", "getWorkingCopy", "(", "null", ")", ";", "ProblemRequestor", "requestor", "=", "new", "ProblemRequestor", "(", "ids", ")", ";", "try", "{", "workingCopy", ".", "discardWorkingCopy", "(", ")", ";", "workingCopy", ".", "becomeWorkingCopy", "(", "requestor", ",", "null", ")", ";", "}", "finally", "{", "workingCopy", ".", "discardWorkingCopy", "(", ")", ";", "}", "List", "<", "IProblem", ">", "problems", "=", "requestor", ".", "getProblems", "(", ")", ";", "return", "(", "IProblem", "[", "]", ")", "problems", ".", "toArray", "(", "new", "IProblem", "[", "problems", ".", "size", "(", ")", "]", ")", ";", "}", "public", "static", "IQuickFixProcessor", "[", "]", "getQuickFixProcessors", "(", "ICompilationUnit", "src", ")", "throws", "Exception", "{", "if", "(", "correctionProcessors", "==", "null", ")", "{", "correctionProcessors", "=", "getProcessorDescriptors", "(", "\"\"", ",", "true", ")", ";", "}", "IQuickFixProcessor", "[", "]", "processors", "=", "new", "IQuickFixProcessor", "[", "correctionProcessors", ".", "length", "]", ";", "for", "(", "int", "ii", "=", "0", ";", "ii", "<", "correctionProcessors", ".", "length", ";", "ii", "++", ")", "{", "processors", "[", "ii", "]", "=", "(", "IQuickFixProcessor", ")", "correctionProcessors", "[", "ii", "]", ".", "getProcessor", "(", "src", ",", "IQuickFixProcessor", ".", "class", ")", ";", "}", "return", "processors", ";", "}", "public", "static", "IQuickAssistProcessor", "[", "]", "getQuickAssistProcessors", "(", "ICompilationUnit", "src", ")", "throws", "Exception", "{", "if", "(", "assistProcessors", "==", "null", ")", "{", "assistProcessors", "=", "getProcessorDescriptors", "(", "\"\"", ",", "false", ")", ";", "}", "IQuickAssistProcessor", "[", "]", "processors", "=", "new", "IQuickAssistProcessor", "[", "assistProcessors", ".", "length", "]", ";", "for", "(", "int", "ii", "=", "0", ";", "ii", "<", "assistProcessors", ".", "length", ";", "ii", "++", ")", "{", "processors", "[", "ii", "]", "=", "(", "IQuickAssistProcessor", ")", "assistProcessors", "[", "ii", "]", ".", "getProcessor", "(", "src", ",", "IQuickAssistProcessor", ".", "class", ")", ";", "}", "return", "processors", ";", "}", "private", "static", "ContributedProcessorDescriptor", "[", "]", "getProcessorDescriptors", "(", "String", "id", ",", "boolean", "testMarkerTypes", ")", "throws", "Exception", "{", "IConfigurationElement", "[", "]", "elements", "=", "Platform", ".", "getExtensionRegistry", "(", ")", ".", "getConfigurationElementsFor", "(", "JavaUI", ".", "ID_PLUGIN", ",", "id", ")", ";", "ArrayList", "<", "ContributedProcessorDescriptor", ">", "res", "=", "new", "ArrayList", "<", "ContributedProcessorDescriptor", ">", "(", "elements", ".", "length", ")", ";", "for", "(", "int", "ii", "=", "0", ";", "ii", "<", "elements", ".", "length", ";", "ii", "++", ")", "{", "ContributedProcessorDescriptor", "desc", "=", "new", "ContributedProcessorDescriptor", "(", "elements", "[", "ii", "]", ",", "testMarkerTypes", ")", ";", "IStatus", "status", "=", "desc", ".", "checkSyntax", "(", ")", ";", "if", "(", "status", ".", "isOK", "(", ")", ")", "{", "res", ".", "add", "(", "desc", ")", ";", "}", "else", "{", "JavaPlugin", ".", "log", "(", "status", ")", ";", "}", "}", "return", "(", "ContributedProcessorDescriptor", "[", "]", ")", "res", ".", "toArray", "(", "new", "ContributedProcessorDescriptor", "[", "res", ".", "size", "(", ")", "]", ")", ";", "}", "public", "static", "class", "ProblemRequestor", "implements", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IProblemRequestor", "{", "private", "ArrayList", "<", "IProblem", ">", "problems", "=", "new", "ArrayList", "<", "IProblem", ">", "(", ")", ";", "private", "int", "[", "]", "ids", ";", "public", "ProblemRequestor", "(", "int", "[", "]", "ids", ")", "{", "this", ".", "ids", "=", "ids", ";", "}", "public", "List", "<", "IProblem", ">", "getProblems", "(", ")", "{", "return", "problems", ";", "}", "public", "void", "acceptProblem", "(", "IProblem", "problem", ")", "{", "if", "(", "ids", "!=", "null", ")", "{", "for", "(", "int", "ii", "=", "0", ";", "ii", "<", "ids", ".", "length", ";", "ii", "++", ")", "{", "if", "(", "problem", ".", "getID", "(", ")", "==", "ids", "[", "ii", "]", ")", "{", "problems", ".", "add", "(", "problem", ")", ";", "break", ";", "}", "}", "}", "else", "{", "problems", ".", "add", "(", "problem", ")", ";", "}", "}", "public", "void", "beginReporting", "(", ")", "{", "}", "public", "void", "endReporting", "(", ")", "{", "}", "public", "boolean", "isActive", "(", ")", "{", "return", "true", ";", "}", "}", "}", "</s>" ]
1,205
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "util", ";", "import", "org", ".", "eclim", ".", "logging", ".", "Logger", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "ICompilationUnit", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IJavaElement", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "dom", ".", "AST", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "dom", ".", "ASTNode", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "dom", ".", "ASTParser", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "dom", ".", "AbstractTypeDeclaration", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "dom", ".", "CompilationUnit", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "dom", ".", "FieldDeclaration", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "dom", ".", "ImportDeclaration", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "dom", ".", "Initializer", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "dom", ".", "MethodDeclaration", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "dom", ".", "NodeFinder", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "dom", ".", "PackageDeclaration", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "text", ".", "Document", ";", "import", "org", ".", "eclipse", ".", "text", ".", "edits", ".", "TextEdit", ";", "public", "class", "ASTUtils", "{", "private", "static", "final", "Logger", "logger", "=", "Logger", ".", "getLogger", "(", "ASTUtils", ".", "class", ")", ";", "private", "ASTUtils", "(", ")", "{", "}", "public", "static", "CompilationUnit", "getCompilationUnit", "(", "ICompilationUnit", "src", ")", "throws", "Exception", "{", "return", "getCompilationUnit", "(", "src", ",", "false", ")", ";", "}", "public", "static", "CompilationUnit", "getCompilationUnit", "(", "ICompilationUnit", "src", ",", "boolean", "recordModifications", ")", "throws", "Exception", "{", "ASTParser", "parser", "=", "ASTParser", ".", "newParser", "(", "AST", ".", "JLS4", ")", ";", "parser", ".", "setSource", "(", "src", ")", ";", "CompilationUnit", "cu", "=", "(", "CompilationUnit", ")", "parser", ".", "createAST", "(", "null", ")", ";", "if", "(", "recordModifications", ")", "{", "cu", ".", "recordModifications", "(", ")", ";", "}", "return", "cu", ";", "}", "public", "static", "void", "commitCompilationUnit", "(", "ICompilationUnit", "src", ",", "CompilationUnit", "node", ")", "throws", "Exception", "{", "Document", "document", "=", "new", "Document", "(", "src", ".", "getBuffer", "(", ")", ".", "getContents", "(", ")", ")", ";", "TextEdit", "edits", "=", "node", ".", "rewrite", "(", "document", ",", "src", ".", "getJavaProject", "(", ")", ".", "getOptions", "(", "true", ")", ")", ";", "edits", ".", "apply", "(", "document", ")", ";", "src", ".", "getBuffer", "(", ")", ".", "setContents", "(", "document", ".", "get", "(", ")", ")", ";", "if", "(", "src", ".", "isWorkingCopy", "(", ")", ")", "{", "src", ".", "commitWorkingCopy", "(", "false", ",", "null", ")", ";", "}", "src", ".", "save", "(", "null", ",", "false", ")", ";", "}", "public", "static", "ASTNode", "findNode", "(", "CompilationUnit", "cu", ",", "int", "offset", ")", "throws", "Exception", "{", "NodeFinder", "finder", "=", "new", "NodeFinder", "(", "cu", ",", "offset", ",", "1", ")", ";", "return", "finder", ".", "getCoveringNode", "(", ")", ";", "}", "public", "static", "ASTNode", "findNode", "(", "CompilationUnit", "cu", ",", "int", "offset", ",", "IJavaElement", "element", ")", "throws", "Exception", "{", "ASTNode", "node", "=", "findNode", "(", "cu", ",", "offset", ")", ";", "if", "(", "node", "==", "null", ")", "{", "return", "null", ";", "}", "if", "(", "element", ".", "getElementType", "(", ")", "==", "IJavaElement", ".", "TYPE_PARAMETER", ")", "{", "element", "=", "element", ".", "getParent", "(", ")", ";", "}", "switch", "(", "element", ".", "getElementType", "(", ")", ")", "{", "case", "IJavaElement", ".", "PACKAGE_DECLARATION", ":", "node", "=", "resolveNode", "(", "node", ",", "PackageDeclaration", ".", "class", ")", ";", "break", ";", "case", "IJavaElement", ".", "IMPORT_DECLARATION", ":", "node", "=", "resolveNode", "(", "node", ",", "ImportDeclaration", ".", "class", ")", ";", "break", ";", "case", "IJavaElement", ".", "TYPE", ":", "node", "=", "resolveNode", "(", "node", ",", "AbstractTypeDeclaration", ".", "class", ")", ";", "break", ";", "case", "IJavaElement", ".", "INITIALIZER", ":", "node", "=", "resolveNode", "(", "node", ",", "Initializer", ".", "class", ")", ";", "break", ";", "case", "IJavaElement", ".", "FIELD", ":", "node", "=", "resolveNode", "(", "node", ",", "FieldDeclaration", ".", "class", ")", ";", "break", ";", "case", "IJavaElement", ".", "METHOD", ":", "node", "=", "resolveNode", "(", "node", ",", "MethodDeclaration", ".", "class", ")", ";", "break", ";", "default", ":", "logger", ".", "info", "(", "\"\"", "+", "\"\"", "+", "element", ".", "getElementType", "(", ")", ")", ";", "}", "return", "node", ";", "}", "@", "SuppressWarnings", "(", "{", "\"rawtypes\"", ",", "\"unchecked\"", "}", ")", "private", "static", "ASTNode", "resolveNode", "(", "ASTNode", "node", ",", "Class", "type", ")", "throws", "Exception", "{", "if", "(", "node", "==", "null", ")", "{", "return", "null", ";", "}", "if", "(", "type", ".", "isAssignableFrom", "(", "node", ".", "getClass", "(", ")", ")", ")", "{", "return", "node", ";", "}", "return", "resolveNode", "(", "node", ".", "getParent", "(", ")", ",", "type", ")", ";", "}", "}", "</s>" ]
1,206
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "util", ";", "import", "java", ".", "util", ".", "Comparator", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IJavaElement", ";", "public", "class", "IJavaElementComparator", "implements", "Comparator", "<", "IJavaElement", ">", "{", "public", "int", "compare", "(", "IJavaElement", "o1", ",", "IJavaElement", "o2", ")", "{", "if", "(", "o1", "==", "null", "&&", "o2", "==", "null", ")", "{", "return", "0", ";", "}", "else", "if", "(", "o2", "==", "null", ")", "{", "return", "-", "1", ";", "}", "else", "if", "(", "o1", "==", "null", ")", "{", "return", "1", ";", "}", "IJavaElement", "p1", "=", "JavaUtils", ".", "getPrimaryElement", "(", "o1", ")", ";", "IJavaElement", "p2", "=", "JavaUtils", ".", "getPrimaryElement", "(", "o2", ")", ";", "return", "p1", ".", "getElementType", "(", ")", "-", "p2", ".", "getElementType", "(", ")", ";", "}", "public", "boolean", "equals", "(", "Object", "obj", ")", "{", "if", "(", "obj", "instanceof", "IJavaElementComparator", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}", "}", "</s>" ]
1,207
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "util", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "HashSet", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Set", ";", "import", "org", ".", "eclim", ".", "logging", ".", "Logger", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "util", ".", "ProjectUtils", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "IProject", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "IPath", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IClasspathEntry", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IJavaProject", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "JavaModelException", ";", "public", "class", "ClasspathUtils", "{", "private", "static", "final", "Logger", "logger", "=", "Logger", ".", "getLogger", "(", "ClasspathUtils", ".", "class", ")", ";", "public", "static", "String", "[", "]", "getClasspath", "(", "IJavaProject", "project", ")", "throws", "Exception", "{", "HashSet", "<", "IJavaProject", ">", "visited", "=", "new", "HashSet", "<", "IJavaProject", ">", "(", ")", ";", "ArrayList", "<", "String", ">", "paths", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "collect", "(", "project", ",", "paths", ",", "visited", ",", "true", ")", ";", "return", "paths", ".", "toArray", "(", "new", "String", "[", "paths", ".", "size", "(", ")", "]", ")", ";", "}", "public", "static", "String", "[", "]", "getSrcPaths", "(", "IJavaProject", "project", ")", "throws", "Exception", "{", "ArrayList", "<", "String", ">", "paths", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "IClasspathEntry", "[", "]", "entries", "=", "project", ".", "getResolvedClasspath", "(", "true", ")", ";", "for", "(", "IClasspathEntry", "entry", ":", "entries", ")", "{", "if", "(", "entry", ".", "getEntryKind", "(", ")", "==", "IClasspathEntry", ".", "CPE_SOURCE", ")", "{", "paths", ".", "add", "(", "ProjectUtils", ".", "getFilePath", "(", "project", ".", "getProject", "(", ")", ",", "entry", ".", "getPath", "(", ")", ".", "toOSString", "(", ")", ")", ")", ";", "}", "}", "return", "paths", ".", "toArray", "(", "new", "String", "[", "paths", ".", "size", "(", ")", "]", ")", ";", "}", "private", "static", "void", "collect", "(", "IJavaProject", "javaProject", ",", "List", "<", "String", ">", "paths", ",", "Set", "<", "IJavaProject", ">", "visited", ",", "boolean", "isFirstProject", ")", "throws", "Exception", "{", "if", "(", "visited", ".", "contains", "(", "javaProject", ")", ")", "{", "return", ";", "}", "visited", ".", "add", "(", "javaProject", ")", ";", "try", "{", "IPath", "out", "=", "javaProject", ".", "getOutputLocation", "(", ")", ";", "paths", ".", "add", "(", "ProjectUtils", ".", "getFilePath", "(", "javaProject", ".", "getProject", "(", ")", ",", "out", ".", "addTrailingSeparator", "(", ")", ".", "toOSString", "(", ")", ")", ")", ";", "}", "catch", "(", "JavaModelException", "ignore", ")", "{", "}", "IProject", "project", "=", "javaProject", ".", "getProject", "(", ")", ";", "String", "name", "=", "project", ".", "getName", "(", ")", ";", "IClasspathEntry", "[", "]", "entries", "=", "null", ";", "try", "{", "entries", "=", "javaProject", ".", "getResolvedClasspath", "(", "true", ")", ";", "}", "catch", "(", "JavaModelException", "jme", ")", "{", "logger", ".", "warn", "(", "\"\"", "+", "name", ",", "jme", ")", ";", "return", ";", "}", "for", "(", "IClasspathEntry", "entry", ":", "entries", ")", "{", "switch", "(", "entry", ".", "getEntryKind", "(", ")", ")", "{", "case", "IClasspathEntry", ".", "CPE_LIBRARY", ":", "case", "IClasspathEntry", ".", "CPE_CONTAINER", ":", "case", "IClasspathEntry", ".", "CPE_VARIABLE", ":", "String", "path", "=", "entry", ".", "getPath", "(", ")", ".", "toOSString", "(", ")", ".", "replace", "(", "'\\\\'", ",", "'/'", ")", ";", "if", "(", "path", ".", "startsWith", "(", "\"/\"", "+", "name", "+", "\"/\"", ")", ")", "{", "path", "=", "ProjectUtils", ".", "getFilePath", "(", "project", ",", "path", ")", ";", "}", "paths", ".", "add", "(", "path", ")", ";", "break", ";", "case", "IClasspathEntry", ".", "CPE_PROJECT", ":", "if", "(", "isFirstProject", "||", "entry", ".", "isExported", "(", ")", ")", "{", "javaProject", "=", "JavaUtils", ".", "getJavaProject", "(", "entry", ".", "getPath", "(", ")", ".", "segment", "(", "0", ")", ")", ";", "if", "(", "javaProject", "!=", "null", ")", "{", "collect", "(", "javaProject", ",", "paths", ",", "visited", ",", "false", ")", ";", "}", "}", "break", ";", "case", "IClasspathEntry", ".", "CPE_SOURCE", ":", "IPath", "out", "=", "entry", ".", "getOutputLocation", "(", ")", ";", "if", "(", "out", "!=", "null", ")", "{", "paths", ".", "add", "(", "ProjectUtils", ".", "getFilePath", "(", "javaProject", ".", "getProject", "(", ")", ",", "out", ".", "addTrailingSeparator", "(", ")", ".", "toOSString", "(", ")", ")", ")", ";", "}", "break", ";", "}", "}", "}", "}", "</s>" ]
1,208
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "hierarchy", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "eclim", ".", "annotation", ".", "Command", ";", "import", "org", ".", "eclim", ".", "command", ".", "CommandLine", ";", "import", "org", ".", "eclim", ".", "command", ".", "Options", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "command", ".", "AbstractCommand", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "util", ".", "JavaUtils", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "util", ".", "TypeInfo", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "util", ".", "TypeUtils", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "ICompilationUnit", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IType", ";", "@", "Command", "(", "name", "=", "\"\"", ",", "options", "=", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", ")", "public", "class", "HierarchyCommand", "extends", "AbstractCommand", "{", "public", "Object", "execute", "(", "CommandLine", "commandLine", ")", "throws", "Exception", "{", "String", "project", "=", "commandLine", ".", "getValue", "(", "Options", ".", "PROJECT_OPTION", ")", ";", "String", "file", "=", "commandLine", ".", "getValue", "(", "Options", ".", "FILE_OPTION", ")", ";", "ICompilationUnit", "src", "=", "JavaUtils", ".", "getCompilationUnit", "(", "project", ",", "file", ")", ";", "int", "offset", "=", "commandLine", ".", "getIntValue", "(", "Options", ".", "OFFSET_OPTION", ")", ";", "if", "(", "offset", "!=", "-", "1", ")", "{", "offset", "=", "getOffset", "(", "commandLine", ")", ";", "}", "IType", "type", "=", "TypeUtils", ".", "getType", "(", "src", ",", "offset", ")", ";", "HierarchyNode", "hierarchy", "=", "new", "HierarchyNode", "(", "type", ",", "createChildNodes", "(", "type", ")", ")", ";", "return", "hierarchy", ";", "}", "private", "List", "<", "HierarchyNode", ">", "createChildNodes", "(", "IType", "type", ")", "throws", "Exception", "{", "ArrayList", "<", "HierarchyNode", ">", "nodes", "=", "new", "ArrayList", "<", "HierarchyNode", ">", "(", ")", ";", "TypeInfo", "parentClassInfo", "=", "TypeUtils", ".", "getSuperClass", "(", "type", ")", ";", "String", "jlo", "=", "\"\"", ";", "if", "(", "parentClassInfo", "!=", "null", ")", "{", "IType", "parentClass", "=", "parentClassInfo", ".", "getType", "(", ")", ";", "if", "(", "!", "jlo", ".", "equals", "(", "JavaUtils", ".", "getFullyQualifiedName", "(", "parentClass", ")", ")", ")", "{", "nodes", ".", "add", "(", "new", "HierarchyNode", "(", "parentClass", ",", "createChildNodes", "(", "parentClass", ")", ")", ")", ";", "}", "}", "IType", "[", "]", "parentInterfaces", "=", "TypeUtils", ".", "getSuperInterfaces", "(", "type", ")", ";", "if", "(", "parentInterfaces", ".", "length", "!=", "0", ")", "{", "for", "(", "IType", "parentInterface", ":", "parentInterfaces", ")", "{", "nodes", ".", "add", "(", "new", "HierarchyNode", "(", "parentInterface", ",", "createChildNodes", "(", "parentInterface", ")", ")", ")", ";", "}", "}", "return", "nodes", ";", "}", "}", "</s>" ]
1,209
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "hierarchy", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "util", ".", "JavaUtils", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "util", ".", "TypeInfo", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "util", ".", "TypeUtils", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IType", ";", "public", "class", "HierarchyNode", "{", "private", "String", "name", ";", "private", "String", "qualified", ";", "private", "List", "<", "HierarchyNode", ">", "children", ";", "public", "HierarchyNode", "(", "IType", "type", ",", "List", "<", "HierarchyNode", ">", "children", ")", "throws", "Exception", "{", "this", ".", "name", "=", "TypeUtils", ".", "getTypeSignature", "(", "new", "TypeInfo", "(", "type", ",", "null", ",", "null", ")", ")", ";", "this", ".", "qualified", "=", "JavaUtils", ".", "getFullyQualifiedName", "(", "type", ")", ";", "this", ".", "children", "=", "children", ";", "}", "public", "String", "getName", "(", ")", "{", "return", "this", ".", "name", ";", "}", "public", "String", "getQualified", "(", ")", "{", "return", "this", ".", "qualified", ";", "}", "public", "List", "<", "HierarchyNode", ">", "getChildren", "(", ")", "{", "return", "this", ".", "children", ";", "}", "}", "</s>" ]
1,210
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "doc", ";", "import", "java", ".", "io", ".", "StringReader", ";", "import", "java", ".", "lang", ".", "reflect", ".", "Method", ";", "import", "java", ".", "net", ".", "URI", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "regex", ".", "Matcher", ";", "import", "java", ".", "util", ".", "regex", ".", "Pattern", ";", "import", "org", ".", "eclim", ".", "annotation", ".", "Command", ";", "import", "org", ".", "eclim", ".", "command", ".", "CommandLine", ";", "import", "org", ".", "eclim", ".", "command", ".", "Options", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "command", ".", "AbstractCommand", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "util", ".", "JavaUtils", ";", "import", "org", ".", "eclim", ".", "util", ".", "IOUtils", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "ICompilationUnit", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IJavaElement", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "ITypeRoot", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "ui", ".", "text", ".", "java", ".", "hover", ".", "JavadocBrowserInformationControlInput", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "ui", ".", "text", ".", "java", ".", "hover", ".", "JavadocHover", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "ui", ".", "viewsupport", ".", "JavaElementLinks", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "internal", ".", "text", ".", "html", ".", "HTML2TextReader", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "text", ".", "IRegion", ";", "@", "Command", "(", "name", "=", "\"\"", ",", "options", "=", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", ")", "public", "class", "GetElementDocCommand", "extends", "AbstractCommand", "{", "private", "static", "final", "Pattern", "LINKS", "=", "Pattern", ".", "compile", "(", "\"\"", ")", ";", "@", "Override", "public", "Object", "execute", "(", "CommandLine", "commandLine", ")", "throws", "Exception", "{", "IJavaElement", "[", "]", "elements", "=", "null", ";", "Object", "url", "=", "commandLine", ".", "getRawValue", "(", "Options", ".", "URL_OPTION", ")", ";", "if", "(", "url", "!=", "null", ")", "{", "IJavaElement", "target", "=", "JavaElementLinks", ".", "parseURI", "(", "new", "URI", "(", "(", "String", ")", "url", ")", ")", ";", "if", "(", "target", "!=", "null", ")", "{", "elements", "=", "new", "IJavaElement", "[", "]", "{", "target", "}", ";", "}", "}", "else", "{", "String", "project", "=", "commandLine", ".", "getValue", "(", "Options", ".", "PROJECT_OPTION", ")", ";", "String", "file", "=", "commandLine", ".", "getValue", "(", "Options", ".", "FILE_OPTION", ")", ";", "int", "offset", "=", "getOffset", "(", "commandLine", ")", ";", "int", "length", "=", "commandLine", ".", "getIntValue", "(", "Options", ".", "LENGTH_OPTION", ")", ";", "ICompilationUnit", "src", "=", "JavaUtils", ".", "getCompilationUnit", "(", "project", ",", "file", ")", ";", "elements", "=", "src", ".", "codeSelect", "(", "offset", ",", "length", ")", ";", "}", "if", "(", "elements", "==", "null", "||", "elements", ".", "length", "==", "0", ")", "{", "return", "null", ";", "}", "Method", "getHoverInfo", "=", "JavadocHover", ".", "class", ".", "getDeclaredMethod", "(", "\"getHoverInfo\"", ",", "IJavaElement", "[", "]", ".", "class", ",", "ITypeRoot", ".", "class", ",", "IRegion", ".", "class", ",", "JavadocBrowserInformationControlInput", ".", "class", ")", ";", "getHoverInfo", ".", "setAccessible", "(", "true", ")", ";", "JavadocBrowserInformationControlInput", "info", "=", "(", "JavadocBrowserInformationControlInput", ")", "getHoverInfo", ".", "invoke", "(", "null", ",", "elements", ",", "null", ",", "null", ",", "null", ")", ";", "if", "(", "info", "==", "null", ")", "{", "return", "null", ";", "}", "ArrayList", "<", "HashMap", "<", "String", ",", "String", ">", ">", "links", "=", "new", "ArrayList", "<", "HashMap", "<", "String", ",", "String", ">", ">", "(", ")", ";", "Matcher", "matcher", "=", "LINKS", ".", "matcher", "(", "info", ".", "getHtml", "(", ")", ")", ";", "StringBuffer", "buffer", "=", "new", "StringBuffer", "(", ")", ";", "int", "index", "=", "0", ";", "while", "(", "matcher", ".", "find", "(", ")", ")", "{", "String", "href", "=", "matcher", ".", "group", "(", "2", ")", ";", "String", "text", "=", "matcher", ".", "group", "(", "3", ")", ";", "HashMap", "<", "String", ",", "String", ">", "link", "=", "new", "HashMap", "<", "String", ",", "String", ">", "(", ")", ";", "link", ".", "put", "(", "\"href\"", ",", "href", ")", ";", "link", ".", "put", "(", "\"text\"", ",", "text", ")", ";", "links", ".", "add", "(", "link", ")", ";", "matcher", ".", "appendReplacement", "(", "buffer", ",", "\"|$3[\"", "+", "(", "index", "++", ")", "+", "\"]|\"", ")", ";", "}", "matcher", ".", "appendTail", "(", "buffer", ")", ";", "String", "html", "=", "buffer", ".", "toString", "(", ")", ";", "String", "result", "=", "IOUtils", ".", "toString", "(", "new", "HTML2TextReader", "(", "new", "StringReader", "(", "html", ")", ",", "null", ")", ")", ";", "result", "=", "result", ".", "replaceAll", "(", "\"r\"", ",", "\"\"", ")", ";", "result", "=", "result", ".", "replaceFirst", "(", "\"nnn\"", ",", "\"nn\"", ")", ";", "HashMap", "<", "String", ",", "Object", ">", "response", "=", "new", "HashMap", "<", "String", ",", "Object", ">", "(", ")", ";", "response", ".", "put", "(", "\"text\"", ",", "result", ")", ";", "response", ".", "put", "(", "\"links\"", ",", "links", ")", ";", "return", "response", ";", "}", "}", "</s>" ]
1,211
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "doc", ";", "import", "java", ".", "net", ".", "URL", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "regex", ".", "Pattern", ";", "import", "org", ".", "eclim", ".", "annotation", ".", "Command", ";", "import", "org", ".", "eclim", ".", "command", ".", "CommandLine", ";", "import", "org", ".", "eclim", ".", "command", ".", "Options", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "util", ".", "ProjectUtils", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "include", ".", "ImportUtils", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "search", ".", "SearchCommand", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "IProject", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IJavaElement", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IType", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "search", ".", "SearchMatch", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "ui", ".", "JavaUI", ";", "@", "Command", "(", "name", "=", "\"\"", ",", "options", "=", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", ")", "public", "class", "DocSearchCommand", "extends", "SearchCommand", "{", "private", "static", "final", "Pattern", "ANDROID_JDK_URL", "=", "Pattern", ".", "compile", "(", "\"\"", ",", "Pattern", ".", "CASE_INSENSITIVE", ")", ";", "@", "Override", "public", "Object", "execute", "(", "CommandLine", "commandLine", ")", "throws", "Exception", "{", "IProject", "project", "=", "ProjectUtils", ".", "getProject", "(", "commandLine", ".", "getValue", "(", "Options", ".", "NAME_OPTION", ")", ")", ";", "String", "pattern", "=", "commandLine", ".", "getValue", "(", "Options", ".", "PATTERN_OPTION", ")", ";", "ArrayList", "<", "String", ">", "results", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "for", "(", "SearchMatch", "match", ":", "executeSearch", "(", "commandLine", ")", ")", "{", "IJavaElement", "element", "=", "(", "IJavaElement", ")", "match", ".", "getElement", "(", ")", ";", "if", "(", "element", "==", "null", ")", "{", "continue", ";", "}", "if", "(", "pattern", "!=", "null", ")", "{", "String", "name", "=", "null", ";", "switch", "(", "element", ".", "getElementType", "(", ")", ")", "{", "case", "IJavaElement", ".", "TYPE", ":", "name", "=", "(", "(", "IType", ")", "element", ")", ".", "getFullyQualifiedName", "(", ")", ";", "break", ";", "case", "IJavaElement", ".", "METHOD", ":", "case", "IJavaElement", ".", "FIELD", ":", "name", "=", "(", "(", "IType", ")", "element", ".", "getParent", "(", ")", ")", ".", "getFullyQualifiedName", "(", ")", ";", "break", ";", "}", "if", "(", "name", "!=", "null", ")", "{", "name", "=", "name", ".", "replace", "(", "'$'", ",", "'.'", ")", ";", "if", "(", "ImportUtils", ".", "isImportExcluded", "(", "project", ",", "name", ")", ")", "{", "continue", ";", "}", "}", "}", "URL", "url", "=", "JavaUI", ".", "getJavadocLocation", "(", "element", ",", "true", ")", ";", "if", "(", "url", "==", "null", ")", "{", "continue", ";", "}", "if", "(", "ANDROID_JDK_URL", ".", "matcher", "(", "url", ".", "toString", "(", ")", ")", ".", "matches", "(", ")", "&&", "!", "project", ".", "hasNature", "(", "ANDROID_NATURE", ")", ")", "{", "continue", ";", "}", "results", ".", "add", "(", "url", ".", "toString", "(", ")", ")", ";", "}", "return", "results", ";", "}", "}", "</s>" ]
1,212
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "doc", ";", "import", "java", ".", "io", ".", "BufferedReader", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "io", ".", "FileReader", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "regex", ".", "Pattern", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang", ".", "StringUtils", ";", "import", "org", ".", "eclim", ".", "Services", ";", "import", "org", ".", "eclim", ".", "annotation", ".", "Command", ";", "import", "org", ".", "eclim", ".", "command", ".", "CommandLine", ";", "import", "org", ".", "eclim", ".", "command", ".", "Options", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "command", ".", "AbstractCommand", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "preference", ".", "Preferences", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "util", ".", "ProjectUtils", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "util", ".", "ASTUtils", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "util", ".", "JavaUtils", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "util", ".", "MethodUtils", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "util", ".", "TypeInfo", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "util", ".", "TypeUtils", ";", "import", "org", ".", "eclim", ".", "util", ".", "IOUtils", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "IProject", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IAnnotation", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "ICompilationUnit", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IJavaElement", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IMethod", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IType", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "Signature", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "dom", ".", "ASTNode", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "dom", ".", "BodyDeclaration", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "dom", ".", "CompilationUnit", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "dom", ".", "Javadoc", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "dom", ".", "Name", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "dom", ".", "PackageDeclaration", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "dom", ".", "TagElement", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "dom", ".", "TextElement", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "formatter", ".", "CodeFormatter", ";", "@", "Command", "(", "name", "=", "\"\"", ",", "options", "=", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", ")", "public", "class", "CommentCommand", "extends", "AbstractCommand", "{", "private", "static", "final", "Pattern", "THROWS_PATTERN", "=", "Pattern", ".", "compile", "(", "\"\"", ")", ";", "private", "static", "final", "String", "INHERIT_DOC", "=", "\"{\"", "+", "TagElement", ".", "TAG_INHERITDOC", "+", "\"}\"", ";", "@", "Override", "public", "Object", "execute", "(", "CommandLine", "commandLine", ")", "throws", "Exception", "{", "String", "project", "=", "commandLine", ".", "getValue", "(", "Options", ".", "PROJECT_OPTION", ")", ";", "String", "file", "=", "commandLine", ".", "getValue", "(", "Options", ".", "FILE_OPTION", ")", ";", "int", "offset", "=", "getOffset", "(", "commandLine", ")", ";", "ICompilationUnit", "src", "=", "JavaUtils", ".", "getCompilationUnit", "(", "project", ",", "file", ")", ";", "IJavaElement", "element", "=", "src", ".", "getElementAt", "(", "offset", ")", ";", "if", "(", "element", ".", "getElementType", "(", ")", "==", "IJavaElement", ".", "IMPORT_DECLARATION", ")", "{", "return", "null", ";", "}", "CompilationUnit", "cu", "=", "ASTUtils", ".", "getCompilationUnit", "(", "src", ",", "true", ")", ";", "ASTNode", "node", "=", "ASTUtils", ".", "findNode", "(", "cu", ",", "offset", ",", "element", ")", ";", "if", "(", "node", "!=", "null", ")", "{", "comment", "(", "src", ",", "node", ",", "element", ")", ";", "ASTUtils", ".", "commitCompilationUnit", "(", "src", ",", "cu", ")", ";", "cu", "=", "ASTUtils", ".", "getCompilationUnit", "(", "src", ",", "true", ")", ";", "node", "=", "ASTUtils", ".", "findNode", "(", "cu", ",", "offset", ",", "element", ")", ";", "Javadoc", "javadoc", "=", "(", "node", "instanceof", "PackageDeclaration", ")", "?", "(", "(", "PackageDeclaration", ")", "node", ")", ".", "getJavadoc", "(", ")", ":", "(", "(", "BodyDeclaration", ")", "node", ")", ".", "getJavadoc", "(", ")", ";", "JavaUtils", ".", "format", "(", "src", ",", "CodeFormatter", ".", "K_COMPILATION_UNIT", ",", "javadoc", ".", "getStartPosition", "(", ")", ",", "javadoc", ".", "getLength", "(", ")", ")", ";", "}", "return", "null", ";", "}", "private", "void", "comment", "(", "ICompilationUnit", "src", ",", "ASTNode", "node", ",", "IJavaElement", "element", ")", "throws", "Exception", "{", "Javadoc", "javadoc", "=", "null", ";", "boolean", "isNew", "=", "false", ";", "if", "(", "node", "instanceof", "PackageDeclaration", ")", "{", "javadoc", "=", "(", "(", "PackageDeclaration", ")", "node", ")", ".", "getJavadoc", "(", ")", ";", "if", "(", "javadoc", "==", "null", ")", "{", "isNew", "=", "true", ";", "javadoc", "=", "node", ".", "getAST", "(", ")", ".", "newJavadoc", "(", ")", ";", "(", "(", "PackageDeclaration", ")", "node", ")", ".", "setJavadoc", "(", "javadoc", ")", ";", "}", "}", "else", "{", "javadoc", "=", "(", "(", "BodyDeclaration", ")", "node", ")", ".", "getJavadoc", "(", ")", ";", "if", "(", "javadoc", "==", "null", ")", "{", "isNew", "=", "true", ";", "javadoc", "=", "node", ".", "getAST", "(", ")", ".", "newJavadoc", "(", ")", ";", "(", "(", "BodyDeclaration", ")", "node", ")", ".", "setJavadoc", "(", "javadoc", ")", ";", "}", "}", "switch", "(", "node", ".", "getNodeType", "(", ")", ")", "{", "case", "ASTNode", ".", "PACKAGE_DECLARATION", ":", "commentPackage", "(", "src", ",", "javadoc", ",", "element", ",", "isNew", ")", ";", "break", ";", "case", "ASTNode", ".", "ENUM_DECLARATION", ":", "case", "ASTNode", ".", "TYPE_DECLARATION", ":", "commentType", "(", "src", ",", "javadoc", ",", "element", ",", "isNew", ")", ";", "break", ";", "case", "ASTNode", ".", "METHOD_DECLARATION", ":", "commentMethod", "(", "src", ",", "javadoc", ",", "element", ",", "isNew", ")", ";", "break", ";", "default", ":", "commentOther", "(", "src", ",", "javadoc", ",", "element", ",", "isNew", ")", ";", "}", "}", "private", "void", "commentPackage", "(", "ICompilationUnit", "src", ",", "Javadoc", "javadoc", ",", "IJavaElement", "element", ",", "boolean", "isNew", ")", "throws", "Exception", "{", "IProject", "project", "=", "element", ".", "getJavaProject", "(", ")", ".", "getProject", "(", ")", ";", "String", "copyright", "=", "getPreferences", "(", ")", ".", "getValue", "(", "project", ",", "Preferences", ".", "PROJECT_COPYRIGHT_PREFERENCE", ")", ";", "if", "(", "copyright", "!=", "null", "&&", "copyright", ".", "trim", "(", ")", ".", "length", "(", ")", ">", "0", ")", "{", "File", "file", "=", "new", "File", "(", "ProjectUtils", ".", "getFilePath", "(", "project", ",", "copyright", ")", ")", ";", "if", "(", "!", "file", ".", "exists", "(", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "Services", ".", "getMessage", "(", "\"\"", ",", "file", ")", ")", ";", "}", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "List", "<", "TagElement", ">", "tags", "=", "javadoc", ".", "tags", "(", ")", ";", "tags", ".", "clear", "(", ")", ";", "BufferedReader", "reader", "=", "null", ";", "try", "{", "reader", "=", "new", "BufferedReader", "(", "new", "FileReader", "(", "file", ")", ")", ";", "String", "line", "=", "null", ";", "while", "(", "(", "line", "=", "reader", ".", "readLine", "(", ")", ")", "!=", "null", ")", "{", "addTag", "(", "javadoc", ",", "tags", ".", "size", "(", ")", ",", "null", ",", "line", ")", ";", "}", "}", "finally", "{", "IOUtils", ".", "closeQuietly", "(", "reader", ")", ";", "}", "}", "else", "{", "commentOther", "(", "src", ",", "javadoc", ",", "element", ",", "isNew", ")", ";", "}", "}", "private", "void", "commentType", "(", "ICompilationUnit", "src", ",", "Javadoc", "javadoc", ",", "IJavaElement", "element", ",", "boolean", "isNew", ")", "throws", "Exception", "{", "if", "(", "element", ".", "getParent", "(", ")", ".", "getElementType", "(", ")", "==", "IJavaElement", ".", "COMPILATION_UNIT", ")", "{", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "List", "<", "TagElement", ">", "tags", "=", "javadoc", ".", "tags", "(", ")", ";", "IProject", "project", "=", "element", ".", "getJavaProject", "(", ")", ".", "getProject", "(", ")", ";", "if", "(", "isNew", ")", "{", "addTag", "(", "javadoc", ",", "tags", ".", "size", "(", ")", ",", "null", ",", "null", ")", ";", "addTag", "(", "javadoc", ",", "tags", ".", "size", "(", ")", ",", "null", ",", "null", ")", ";", "addTag", "(", "javadoc", ",", "tags", ".", "size", "(", ")", ",", "TagElement", ".", "TAG_AUTHOR", ",", "getAuthor", "(", "project", ")", ")", ";", "String", "version", "=", "getPreferences", "(", ")", ".", "getValue", "(", "project", ",", "\"\"", ")", ";", "if", "(", "version", "!=", "null", "&&", "!", "StringUtils", ".", "EMPTY", ".", "equals", "(", "version", ".", "trim", "(", ")", ")", ")", "{", "version", "=", "StringUtils", ".", "replace", "(", "version", ",", "\"\\\\$\"", ",", "\"$\"", ")", ";", "addTag", "(", "javadoc", ",", "tags", ".", "size", "(", ")", ",", "TagElement", ".", "TAG_VERSION", ",", "version", ")", ";", "}", "}", "else", "{", "int", "index", "=", "-", "1", ";", "String", "author", "=", "getAuthor", "(", "project", ")", ";", "for", "(", "int", "ii", "=", "0", ";", "ii", "<", "tags", ".", "size", "(", ")", ";", "ii", "++", ")", "{", "TagElement", "tag", "=", "(", "TagElement", ")", "tags", ".", "get", "(", "ii", ")", ";", "if", "(", "TagElement", ".", "TAG_AUTHOR", ".", "equals", "(", "tag", ".", "getTagName", "(", ")", ")", ")", "{", "String", "authorText", "=", "tag", ".", "fragments", "(", ")", ".", "size", "(", ")", ">", "0", "?", "(", "(", "TextElement", ")", "tag", ".", "fragments", "(", ")", ".", "get", "(", "0", ")", ")", ".", "getText", "(", ")", ":", "null", ";", "if", "(", "authorText", "!=", "null", "&&", "author", ".", "trim", "(", ")", ".", "equals", "(", "authorText", ".", "trim", "(", ")", ")", ")", "{", "index", "=", "-", "1", ";", "break", ";", "}", "index", "=", "ii", "+", "1", ";", "}", "else", "if", "(", "tag", ".", "getTagName", "(", ")", "!=", "null", ")", "{", "if", "(", "index", "==", "-", "1", ")", "{", "index", "=", "ii", ";", "}", "}", "}", "if", "(", "index", ">", "-", "1", ")", "{", "TagElement", "authorTag", "=", "javadoc", ".", "getAST", "(", ")", ".", "newTagElement", "(", ")", ";", "TextElement", "authorText", "=", "javadoc", ".", "getAST", "(", ")", ".", "newTextElement", "(", ")", ";", "authorText", ".", "setText", "(", "author", ")", ";", "authorTag", ".", "setTagName", "(", "TagElement", ".", "TAG_AUTHOR", ")", ";", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "List", "<", "ASTNode", ">", "fragments", "=", "authorTag", ".", "fragments", "(", ")", ";", "fragments", ".", "add", "(", "authorText", ")", ";", "tags", ".", "add", "(", "index", ",", "authorTag", ")", ";", "}", "boolean", "versionExists", "=", "false", ";", "for", "(", "int", "ii", "=", "0", ";", "ii", "<", "tags", ".", "size", "(", ")", ";", "ii", "++", ")", "{", "TagElement", "tag", "=", "(", "TagElement", ")", "tags", ".", "get", "(", "ii", ")", ";", "if", "(", "TagElement", ".", "TAG_VERSION", ".", "equals", "(", "tag", ".", "getTagName", "(", ")", ")", ")", "{", "versionExists", "=", "true", ";", "break", ";", "}", "}", "if", "(", "!", "versionExists", ")", "{", "String", "version", "=", "getPreferences", "(", ")", ".", "getValue", "(", "project", ",", "\"\"", ")", ";", "version", "=", "StringUtils", ".", "replace", "(", "version", ",", "\"\\\\$\"", ",", "\"$\"", ")", ";", "addTag", "(", "javadoc", ",", "tags", ".", "size", "(", ")", ",", "TagElement", ".", "TAG_VERSION", ",", "version", ")", ";", "}", "}", "}", "else", "{", "commentOther", "(", "src", ",", "javadoc", ",", "element", ",", "isNew", ")", ";", "}", "}", "private", "void", "commentMethod", "(", "ICompilationUnit", "src", ",", "Javadoc", "javadoc", ",", "IJavaElement", "element", ",", "boolean", "isNew", ")", "throws", "Exception", "{", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "List", "<", "TagElement", ">", "tags", "=", "javadoc", ".", "tags", "(", ")", ";", "IMethod", "method", "=", "(", "IMethod", ")", "element", ";", "IType", "type", "=", "method", ".", "getDeclaringType", "(", ")", ";", "boolean", "hasOverride", "=", "false", ";", "IAnnotation", "[", "]", "annotations", "=", "method", ".", "getAnnotations", "(", ")", ";", "for", "(", "IAnnotation", "annotation", ":", "annotations", ")", "{", "for", "(", "String", "[", "]", "result", ":", "type", ".", "resolveType", "(", "annotation", ".", "getElementName", "(", ")", ")", ")", "{", "if", "(", "result", "[", "0", "]", ".", "equals", "(", "\"java.lang\"", ")", "&&", "result", "[", "1", "]", ".", "equals", "(", "\"Override\"", ")", ")", "{", "hasOverride", "=", "true", ";", "break", ";", "}", "}", "}", "if", "(", "isNew", ")", "{", "IType", "parentType", "=", "null", ";", "TypeInfo", "[", "]", "types", "=", "TypeUtils", ".", "getSuperTypes", "(", "type", ")", ";", "for", "(", "TypeInfo", "info", ":", "types", ")", "{", "if", "(", "MethodUtils", ".", "containsMethod", "(", "info", ",", "method", ")", ")", "{", "parentType", "=", "info", ".", "getType", "(", ")", ";", "break", ";", "}", "}", "if", "(", "parentType", "!=", "null", ")", "{", "if", "(", "!", "hasOverride", ")", "{", "addTag", "(", "javadoc", ",", "tags", ".", "size", "(", ")", ",", "null", ",", "INHERIT_DOC", ")", ";", "String", "typeName", "=", "JavaUtils", ".", "getCompilationUnitRelativeTypeName", "(", "src", ",", "parentType", ")", ";", "StringBuffer", "signature", "=", "new", "StringBuffer", "(", ")", ";", "signature", ".", "append", "(", "typeName", ")", ".", "append", "(", "'#'", ")", ".", "append", "(", "MethodUtils", ".", "getMinimalMethodSignature", "(", "method", ",", "null", ")", ")", ";", "addTag", "(", "javadoc", ",", "tags", ".", "size", "(", ")", ",", "TagElement", ".", "TAG_SEE", ",", "signature", ".", "toString", "(", ")", ")", ";", "}", "}", "else", "{", "addTag", "(", "javadoc", ",", "tags", ".", "size", "(", ")", ",", "null", ",", "null", ")", ";", "addTag", "(", "javadoc", ",", "tags", ".", "size", "(", ")", ",", "null", ",", "null", ")", ";", "}", "}", "boolean", "update", "=", "true", ";", "for", "(", "TagElement", "tag", ":", "tags", ")", "{", "if", "(", "tag", ".", "getTagName", "(", ")", "==", "null", "&&", "tag", ".", "fragments", "(", ")", ".", "size", "(", ")", ">", "0", ")", "{", "if", "(", "INHERIT_DOC", ".", "equals", "(", "tag", ".", "fragments", "(", ")", ".", "get", "(", "0", ")", ".", "toString", "(", ")", ")", ")", "{", "update", "=", "false", ";", "break", ";", "}", "}", "}", "if", "(", "update", ")", "{", "addUpdateParamTags", "(", "javadoc", ",", "method", ",", "isNew", ")", ";", "addUpdateReturnTag", "(", "javadoc", ",", "method", ",", "isNew", ")", ";", "addUpdateThrowsTags", "(", "javadoc", ",", "method", ",", "isNew", ")", ";", "}", "}", "private", "void", "commentOther", "(", "ICompilationUnit", "src", ",", "Javadoc", "javadoc", ",", "IJavaElement", "element", ",", "boolean", "isNew", ")", "throws", "Exception", "{", "if", "(", "isNew", ")", "{", "addTag", "(", "javadoc", ",", "0", ",", "null", ",", "null", ")", ";", "}", "}", "private", "void", "addUpdateParamTags", "(", "Javadoc", "javadoc", ",", "IMethod", "method", ",", "boolean", "isNew", ")", "throws", "Exception", "{", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "List", "<", "TagElement", ">", "tags", "=", "javadoc", ".", "tags", "(", ")", ";", "String", "[", "]", "params", "=", "method", ".", "getParameterNames", "(", ")", ";", "if", "(", "isNew", ")", "{", "for", "(", "int", "ii", "=", "0", ";", "ii", "<", "params", ".", "length", ";", "ii", "++", ")", "{", "addTag", "(", "javadoc", ",", "tags", ".", "size", "(", ")", ",", "TagElement", ".", "TAG_PARAM", ",", "params", "[", "ii", "]", ")", ";", "}", "}", "else", "{", "int", "index", "=", "0", ";", "HashMap", "<", "String", ",", "TagElement", ">", "current", "=", "new", "HashMap", "<", "String", ",", "TagElement", ">", "(", ")", ";", "for", "(", "int", "ii", "=", "0", ";", "ii", "<", "tags", ".", "size", "(", ")", ";", "ii", "++", ")", "{", "TagElement", "tag", "=", "(", "TagElement", ")", "tags", ".", "get", "(", "ii", ")", ";", "if", "(", "TagElement", ".", "TAG_PARAM", ".", "equals", "(", "tag", ".", "getTagName", "(", ")", ")", ")", "{", "if", "(", "current", ".", "size", "(", ")", "==", "0", ")", "{", "index", "=", "ii", ";", "}", "Object", "element", "=", "tag", ".", "fragments", "(", ")", ".", "size", "(", ")", ">", "0", "?", "tag", ".", "fragments", "(", ")", ".", "get", "(", "0", ")", ":", "null", ";", "if", "(", "element", "!=", "null", "&&", "element", "instanceof", "Name", ")", "{", "String", "name", "=", "(", "(", "Name", ")", "element", ")", ".", "getFullyQualifiedName", "(", ")", ";", "current", ".", "put", "(", "name", ",", "tag", ")", ";", "}", "else", "{", "current", ".", "put", "(", "String", ".", "valueOf", "(", "ii", ")", ",", "tag", ")", ";", "}", "}", "else", "{", "if", "(", "current", ".", "size", "(", ")", ">", "0", ")", "{", "break", ";", "}", "if", "(", "tag", ".", "getTagName", "(", ")", "==", "null", ")", "{", "index", "=", "ii", "+", "1", ";", "}", "}", "}", "if", "(", "current", ".", "size", "(", ")", ">", "0", ")", "{", "for", "(", "int", "ii", "=", "0", ";", "ii", "<", "params", ".", "length", ";", "ii", "++", ")", "{", "if", "(", "current", ".", "containsKey", "(", "params", "[", "ii", "]", ")", ")", "{", "TagElement", "tag", "=", "(", "TagElement", ")", "current", ".", "get", "(", "params", "[", "ii", "]", ")", ";", "int", "currentIndex", "=", "tags", ".", "indexOf", "(", "tag", ")", ";", "if", "(", "currentIndex", "!=", "ii", ")", "{", "tags", ".", "remove", "(", "tag", ")", ";", "tags", ".", "add", "(", "index", "+", "ii", ",", "tag", ")", ";", "}", "current", ".", "remove", "(", "params", "[", "ii", "]", ")", ";", "}", "else", "{", "addTag", "(", "javadoc", ",", "index", "+", "ii", ",", "TagElement", ".", "TAG_PARAM", ",", "params", "[", "ii", "]", ")", ";", "}", "}", "for", "(", "TagElement", "tag", ":", "current", ".", "values", "(", ")", ")", "{", "tags", ".", "remove", "(", "tag", ")", ";", "}", "}", "else", "{", "for", "(", "int", "ii", "=", "0", ";", "ii", "<", "params", ".", "length", ";", "ii", "++", ")", "{", "addTag", "(", "javadoc", ",", "index", "+", "ii", ",", "TagElement", ".", "TAG_PARAM", ",", "params", "[", "ii", "]", ")", ";", "}", "}", "}", "}", "private", "void", "addUpdateReturnTag", "(", "Javadoc", "javadoc", ",", "IMethod", "method", ",", "boolean", "isNew", ")", "throws", "Exception", "{", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "List", "<", "TagElement", ">", "tags", "=", "javadoc", ".", "tags", "(", ")", ";", "if", "(", "!", "method", ".", "isConstructor", "(", ")", ")", "{", "String", "returnType", "=", "Signature", ".", "getSignatureSimpleName", "(", "method", ".", "getReturnType", "(", ")", ")", ";", "if", "(", "!", "\"void\"", ".", "equals", "(", "returnType", ")", ")", "{", "if", "(", "isNew", ")", "{", "addTag", "(", "javadoc", ",", "tags", ".", "size", "(", ")", ",", "TagElement", ".", "TAG_RETURN", ",", "null", ")", ";", "}", "else", "{", "int", "index", "=", "tags", ".", "size", "(", ")", ";", "for", "(", "int", "ii", "=", "tags", ".", "size", "(", ")", "-", "1", ";", "ii", ">=", "0", ";", "ii", "--", ")", "{", "TagElement", "tag", "=", "(", "TagElement", ")", "tags", ".", "get", "(", "ii", ")", ";", "if", "(", "TagElement", ".", "TAG_RETURN", ".", "equals", "(", "tag", ".", "getTagName", "(", ")", ")", ")", "{", "index", "=", "-", "1", ";", "break", ";", "}", "if", "(", "TagElement", ".", "TAG_PARAM", ".", "equals", "(", "tag", ".", "getTagName", "(", ")", ")", "||", "tag", ".", "getTagName", "(", ")", "==", "null", ")", "{", "index", "=", "ii", "+", "1", ";", "break", ";", "}", "index", "=", "ii", ";", "}", "if", "(", "index", ">", "-", "1", ")", "{", "addTag", "(", "javadoc", ",", "index", ",", "TagElement", ".", "TAG_RETURN", ",", "null", ")", ";", "}", "}", "}", "else", "{", "for", "(", "int", "ii", "=", "tags", ".", "size", "(", ")", "-", "1", ";", "ii", ">=", "0", ";", "ii", "--", ")", "{", "TagElement", "tag", "=", "(", "TagElement", ")", "tags", ".", "get", "(", "ii", ")", ";", "if", "(", "TagElement", ".", "TAG_RETURN", ".", "equals", "(", "tag", ".", "getTagName", "(", ")", ")", ")", "{", "tags", ".", "remove", "(", "tag", ")", ";", "}", "if", "(", "TagElement", ".", "TAG_PARAM", ".", "equals", "(", "tag", ".", "getTagName", "(", ")", ")", "||", "tag", ".", "getTagName", "(", ")", "==", "null", ")", "{", "break", ";", "}", "}", "}", "}", "}", "private", "void", "addUpdateThrowsTags", "(", "Javadoc", "javadoc", ",", "IMethod", "method", ",", "boolean", "isNew", ")", "throws", "Exception", "{", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "List", "<", "TagElement", ">", "tags", "=", "javadoc", ".", "tags", "(", ")", ";", "String", "[", "]", "exceptions", "=", "method", ".", "getExceptionTypes", "(", ")", ";", "if", "(", "isNew", "&&", "exceptions", ".", "length", ">", "0", ")", "{", "addTag", "(", "javadoc", ",", "tags", ".", "size", "(", ")", ",", "null", ",", "null", ")", ";", "for", "(", "int", "ii", "=", "0", ";", "ii", "<", "exceptions", ".", "length", ";", "ii", "++", ")", "{", "addTag", "(", "javadoc", ",", "tags", ".", "size", "(", ")", ",", "TagElement", ".", "TAG_THROWS", ",", "Signature", ".", "getSignatureSimpleName", "(", "exceptions", "[", "ii", "]", ")", ")", ";", "}", "}", "else", "{", "HashMap", "<", "String", ",", "TagElement", ">", "current", "=", "new", "HashMap", "<", "String", ",", "TagElement", ">", "(", ")", ";", "int", "index", "=", "tags", ".", "size", "(", ")", ";", "for", "(", "int", "ii", "=", "tags", ".", "size", "(", ")", "-", "1", ";", "ii", ">=", "0", ";", "ii", "--", ")", "{", "TagElement", "tag", "=", "(", "TagElement", ")", "tags", ".", "get", "(", "ii", ")", ";", "if", "(", "TagElement", ".", "TAG_THROWS", ".", "equals", "(", "tag", ".", "getTagName", "(", ")", ")", ")", "{", "index", "=", "index", "==", "tags", ".", "size", "(", ")", "?", "ii", "+", "1", ":", "index", ";", "Name", "name", "=", "tag", ".", "fragments", "(", ")", ".", "size", "(", ")", ">", "0", "?", "(", "Name", ")", "tag", ".", "fragments", "(", ")", ".", "get", "(", "0", ")", ":", "null", ";", "if", "(", "name", "!=", "null", ")", "{", "String", "text", "=", "name", ".", "getFullyQualifiedName", "(", ")", ";", "String", "key", "=", "THROWS_PATTERN", ".", "matcher", "(", "text", ")", ".", "replaceFirst", "(", "\"$1\"", ")", ";", "current", ".", "put", "(", "key", ",", "tag", ")", ";", "}", "else", "{", "current", ".", "put", "(", "String", ".", "valueOf", "(", "ii", ")", ",", "tag", ")", ";", "}", "}", "if", "(", "TagElement", ".", "TAG_PARAM", ".", "equals", "(", "tag", ".", "getTagName", "(", ")", ")", "||", "TagElement", ".", "TAG_RETURN", ".", "equals", "(", "tag", ".", "getTagName", "(", ")", ")", "||", "tag", ".", "getTagName", "(", ")", "==", "null", ")", "{", "break", ";", "}", "}", "for", "(", "int", "ii", "=", "0", ";", "ii", "<", "exceptions", ".", "length", ";", "ii", "++", ")", "{", "String", "name", "=", "Signature", ".", "getSignatureSimpleName", "(", "exceptions", "[", "ii", "]", ")", ";", "if", "(", "!", "current", ".", "containsKey", "(", "name", ")", ")", "{", "addTag", "(", "javadoc", ",", "index", ",", "TagElement", ".", "TAG_THROWS", ",", "name", ")", ";", "}", "else", "{", "current", ".", "remove", "(", "name", ")", ";", "}", "}", "for", "(", "TagElement", "tag", ":", "current", ".", "values", "(", ")", ")", "{", "tags", ".", "remove", "(", "tag", ")", ";", "}", "}", "}", "private", "String", "getAuthor", "(", "IProject", "project", ")", "throws", "Exception", "{", "String", "username", "=", "getPreferences", "(", ")", ".", "getValue", "(", "project", ".", "getProject", "(", ")", ",", "Preferences", ".", "USERNAME_PREFERENCE", ")", ";", "String", "email", "=", "getPreferences", "(", ")", ".", "getValue", "(", "project", ".", "getProject", "(", ")", ",", "Preferences", ".", "USEREMAIL_PREFERENCE", ")", ";", "StringBuffer", "author", "=", "new", "StringBuffer", "(", ")", ";", "if", "(", "username", "!=", "null", "&&", "username", ".", "trim", "(", ")", ".", "length", "(", ")", ">", "0", ")", "{", "author", ".", "append", "(", "username", ")", ";", "if", "(", "email", "!=", "null", "&&", "email", ".", "trim", "(", ")", ".", "length", "(", ")", ">", "0", ")", "{", "author", ".", "append", "(", "\"", "(\"", ")", ".", "append", "(", "email", ")", ".", "append", "(", "\")\"", ")", ";", "}", "}", "else", "if", "(", "email", "!=", "null", "&&", "email", ".", "trim", "(", ")", ".", "length", "(", ")", ">", "0", ")", "{", "author", ".", "append", "(", "email", ")", ";", "}", "return", "author", ".", "toString", "(", ")", ";", "}", "private", "void", "addTag", "(", "Javadoc", "javadoc", ",", "int", "index", ",", "String", "name", ",", "String", "text", ")", "throws", "Exception", "{", "TagElement", "tag", "=", "javadoc", ".", "getAST", "(", ")", ".", "newTagElement", "(", ")", ";", "tag", ".", "setTagName", "(", "name", ")", ";", "if", "(", "text", "!=", "null", ")", "{", "TextElement", "textElement", "=", "javadoc", ".", "getAST", "(", ")", ".", "newTextElement", "(", ")", ";", "textElement", ".", "setText", "(", "text", ")", ";", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "List", "<", "ASTNode", ">", "fragments", "=", "tag", ".", "fragments", "(", ")", ";", "fragments", ".", "add", "(", "textElement", ")", ";", "}", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "List", "<", "TagElement", ">", "tags", "=", "javadoc", ".", "tags", "(", ")", ";", "tags", ".", "add", "(", "index", ",", "tag", ")", ";", "}", "}", "</s>" ]
1,213
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "doc", ";", "import", "java", ".", "net", ".", "URL", ";", "import", "org", ".", "eclim", ".", "annotation", ".", "Command", ";", "import", "org", ".", "eclim", ".", "command", ".", "CommandLine", ";", "import", "org", ".", "eclim", ".", "command", ".", "Options", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "command", ".", "AbstractCommand", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "ui", ".", "actions", ".", "OpenBrowserUtil", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Display", ";", "@", "Command", "(", "name", "=", "\"\"", ",", "options", "=", "\"\"", ")", "public", "class", "DocUrlOpenCommand", "extends", "AbstractCommand", "{", "@", "Override", "public", "Object", "execute", "(", "CommandLine", "commandLine", ")", "throws", "Exception", "{", "String", "url", "=", "commandLine", ".", "getValue", "(", "Options", ".", "URL_OPTION", ")", ";", "OpenBrowserUtil", ".", "openExternal", "(", "new", "URL", "(", "url", ")", ",", "Display", ".", "getDefault", "(", ")", ")", ";", "return", "null", ";", "}", "}", "</s>" ]
1,214
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "doc", ";", "import", "java", ".", "io", ".", "File", ";", "import", "org", ".", "apache", ".", "tools", ".", "ant", ".", "BuildLogger", ";", "import", "org", ".", "apache", ".", "tools", ".", "ant", ".", "DefaultLogger", ";", "import", "org", ".", "apache", ".", "tools", ".", "ant", ".", "Project", ";", "import", "org", ".", "apache", ".", "tools", ".", "ant", ".", "taskdefs", ".", "Javadoc", ";", "import", "org", ".", "apache", ".", "tools", ".", "ant", ".", "types", ".", "FileSet", ";", "import", "org", ".", "apache", ".", "tools", ".", "ant", ".", "types", ".", "Path", ";", "import", "org", ".", "eclim", ".", "annotation", ".", "Command", ";", "import", "org", ".", "eclim", ".", "command", ".", "CommandLine", ";", "import", "org", ".", "eclim", ".", "command", ".", "Options", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "command", ".", "AbstractCommand", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "util", ".", "ProjectUtils", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "util", ".", "ClasspathUtils", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "util", ".", "JavaUtils", ";", "import", "org", ".", "eclim", ".", "util", ".", "StringUtils", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "IProject", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IJavaProject", ";", "@", "Command", "(", "name", "=", "\"javadoc\"", ",", "options", "=", "\"\"", "+", "\"\"", "+", "\"\"", ")", "public", "class", "JavadocCommand", "extends", "AbstractCommand", "{", "public", "Object", "execute", "(", "CommandLine", "commandLine", ")", "throws", "Exception", "{", "String", "projectName", "=", "commandLine", ".", "getValue", "(", "Options", ".", "PROJECT_OPTION", ")", ";", "String", "files", "=", "commandLine", ".", "getValue", "(", "Options", ".", "FILE_OPTION", ")", ";", "boolean", "debug", "=", "commandLine", ".", "hasOption", "(", "Options", ".", "DEBUG_OPTION", ")", ";", "IProject", "project", "=", "ProjectUtils", ".", "getProject", "(", "projectName", ")", ";", "IJavaProject", "javaProject", "=", "JavaUtils", ".", "getJavaProject", "(", "project", ")", ";", "String", "dest", "=", "getPreferences", "(", ")", ".", "getValue", "(", "project", ",", "\"\"", ")", ";", "String", "packageNames", "=", "getPreferences", "(", ")", ".", "getValue", "(", "project", ",", "\"\"", ")", ";", "Project", "antProject", "=", "new", "Project", "(", ")", ";", "BuildLogger", "buildLogger", "=", "new", "DefaultLogger", "(", ")", ";", "buildLogger", ".", "setMessageOutputLevel", "(", "debug", "?", "Project", ".", "MSG_DEBUG", ":", "Project", ".", "MSG_INFO", ")", ";", "buildLogger", ".", "setOutputPrintStream", "(", "getContext", "(", ")", ".", "out", ")", ";", "buildLogger", ".", "setErrorPrintStream", "(", "getContext", "(", ")", ".", "err", ")", ";", "antProject", ".", "addBuildListener", "(", "buildLogger", ")", ";", "antProject", ".", "setBasedir", "(", "ProjectUtils", ".", "getPath", "(", "project", ")", ")", ";", "Javadoc", "javadoc", "=", "new", "Javadoc", "(", ")", ";", "javadoc", ".", "setTaskName", "(", "\"javadoc\"", ")", ";", "javadoc", ".", "setProject", "(", "antProject", ")", ";", "javadoc", ".", "setDestdir", "(", "new", "File", "(", "ProjectUtils", ".", "getFilePath", "(", "project", ",", "dest", ")", ")", ")", ";", "if", "(", "packageNames", "!=", "null", "&&", "!", "packageNames", ".", "trim", "(", ")", ".", "equals", "(", "StringUtils", ".", "EMPTY", ")", ")", "{", "javadoc", ".", "setPackagenames", "(", "packageNames", ")", ";", "}", "Path", "classpath", "=", "new", "Path", "(", "antProject", ")", ";", "String", "[", "]", "paths", "=", "ClasspathUtils", ".", "getClasspath", "(", "javaProject", ")", ";", "for", "(", "String", "path", ":", "paths", ")", "{", "Path", ".", "PathElement", "pe", "=", "classpath", ".", "createPathElement", "(", ")", ";", "pe", ".", "setPath", "(", "path", ")", ";", "}", "javadoc", ".", "setClasspath", "(", "classpath", ")", ";", "if", "(", "files", "==", "null", ")", "{", "String", "sourcepath", "=", "getPreferences", "(", ")", ".", "getValue", "(", "project", ",", "\"\"", ")", ";", "if", "(", "sourcepath", "!=", "null", "&&", "!", "sourcepath", ".", "trim", "(", ")", ".", "equals", "(", "StringUtils", ".", "EMPTY", ")", ")", "{", "paths", "=", "StringUtils", ".", "split", "(", "sourcepath", ",", "\"", "\"", ")", ";", "}", "else", "{", "paths", "=", "ClasspathUtils", ".", "getSrcPaths", "(", "javaProject", ")", ";", "}", "for", "(", "String", "path", ":", "paths", ")", "{", "FileSet", "fileset", "=", "new", "FileSet", "(", ")", ";", "fileset", ".", "setProject", "(", "antProject", ")", ";", "fileset", ".", "setDir", "(", "new", "File", "(", "ProjectUtils", ".", "getFilePath", "(", "project", ",", "path", ")", ")", ")", ";", "fileset", ".", "setIncludes", "(", "\"**/*.java\"", ")", ";", "javadoc", ".", "addFileset", "(", "fileset", ")", ";", "}", "}", "else", "{", "paths", "=", "StringUtils", ".", "split", "(", "files", ")", ";", "for", "(", "String", "path", ":", "paths", ")", "{", "javadoc", ".", "addSource", "(", "new", "Javadoc", ".", "SourceFile", "(", "new", "File", "(", "ProjectUtils", ".", "getFilePath", "(", "project", ",", "path", ")", ")", ")", ")", ";", "}", "}", "javadoc", ".", "execute", "(", ")", ";", "return", "null", ";", "}", "}", "</s>" ]
1,215
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "log4j", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "eclim", ".", "Services", ";", "import", "org", ".", "eclim", ".", "annotation", ".", "Command", ";", "import", "org", ".", "eclim", ".", "command", ".", "CommandLine", ";", "import", "org", ".", "eclim", ".", "command", ".", "Error", ";", "import", "org", ".", "eclim", ".", "command", ".", "Options", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "util", ".", "ProjectUtils", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "util", ".", "JavaUtils", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IJavaProject", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IPackageFragment", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IPackageFragmentRoot", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IType", ";", "import", "org", ".", "xml", ".", "sax", ".", "Attributes", ";", "import", "org", ".", "xml", ".", "sax", ".", "Locator", ";", "import", "org", ".", "xml", ".", "sax", ".", "SAXException", ";", "import", "org", ".", "xml", ".", "sax", ".", "helpers", ".", "DefaultHandler", ";", "@", "Command", "(", "name", "=", "\"\"", ",", "options", "=", "\"\"", "+", "\"\"", ")", "public", "class", "ValidateCommand", "extends", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "command", ".", "xml", ".", "ValidateCommand", "{", "public", "Object", "execute", "(", "CommandLine", "commandLine", ")", "throws", "Exception", "{", "String", "project", "=", "commandLine", ".", "getValue", "(", "Options", ".", "PROJECT_OPTION", ")", ";", "String", "file", "=", "commandLine", ".", "getValue", "(", "Options", ".", "FILE_OPTION", ")", ";", "Log4jHandler", "handler", "=", "new", "Log4jHandler", "(", "JavaUtils", ".", "getJavaProject", "(", "project", ")", ",", "file", ")", ";", "List", "<", "Error", ">", "errors", "=", "super", ".", "validate", "(", "project", ",", "file", ",", "false", ",", "handler", ")", ";", "errors", ".", "addAll", "(", "handler", ".", "getErrors", "(", ")", ")", ";", "return", "errors", ";", "}", "private", "static", "class", "Log4jHandler", "extends", "DefaultHandler", "{", "private", "static", "final", "String", "CATEGORY", "=", "\"category\"", ";", "private", "static", "final", "String", "CLASS", "=", "\"class\"", ";", "private", "static", "final", "String", "LEVEL", "=", "\"level\"", ";", "private", "static", "final", "String", "LOGGER", "=", "\"logger\"", ";", "private", "static", "final", "String", "NAME", "=", "\"name\"", ";", "private", "static", "final", "String", "PRIORITY", "=", "\"priority\"", ";", "private", "static", "final", "String", "VALUE", "=", "\"value\"", ";", "private", "static", "final", "ArrayList", "<", "String", ">", "LEVELS", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "static", "{", "LEVELS", ".", "add", "(", "\"debug\"", ")", ";", "LEVELS", ".", "add", "(", "\"info\"", ")", ";", "LEVELS", ".", "add", "(", "\"warn\"", ")", ";", "LEVELS", ".", "add", "(", "\"fatal\"", ")", ";", "}", "private", "Locator", "locator", ";", "private", "IJavaProject", "project", ";", "private", "String", "file", ";", "private", "ArrayList", "<", "Error", ">", "errors", "=", "new", "ArrayList", "<", "Error", ">", "(", ")", ";", "public", "Log4jHandler", "(", "IJavaProject", "project", ",", "String", "file", ")", "throws", "Exception", "{", "this", ".", "project", "=", "project", ";", "this", ".", "file", "=", "ProjectUtils", ".", "getFilePath", "(", "project", ".", "getProject", "(", ")", ",", "file", ")", ";", "}", "public", "void", "setDocumentLocator", "(", "Locator", "locator", ")", "{", "super", ".", "setDocumentLocator", "(", "locator", ")", ";", "this", ".", "locator", "=", "locator", ";", "}", "public", "void", "startElement", "(", "String", "uri", ",", "String", "localName", ",", "String", "qName", ",", "Attributes", "atts", ")", "throws", "SAXException", "{", "try", "{", "if", "(", "CATEGORY", ".", "equals", "(", "localName", ")", "||", "LOGGER", ".", "equals", "(", "localName", ")", ")", "{", "String", "name", "=", "atts", ".", "getValue", "(", "NAME", ")", ";", "if", "(", "name", "!=", "null", ")", "{", "IPackageFragment", "pkg", "=", "getPackage", "(", "name", ")", ";", "if", "(", "pkg", "==", "null", ")", "{", "IType", "type", "=", "project", ".", "findType", "(", "name", ")", ";", "if", "(", "type", "==", "null", "||", "!", "type", ".", "exists", "(", ")", ")", "{", "String", "message", "=", "Services", ".", "getMessage", "(", "\"\"", ",", "name", ")", ";", "errors", ".", "add", "(", "new", "Error", "(", "message", ",", "file", ",", "locator", ".", "getLineNumber", "(", ")", ",", "1", ",", "false", ")", ")", ";", "}", "}", "}", "}", "else", "if", "(", "PRIORITY", ".", "equals", "(", "localName", ")", "||", "LEVEL", ".", "equals", "(", "localName", ")", ")", "{", "String", "value", "=", "atts", ".", "getValue", "(", "VALUE", ")", ";", "if", "(", "atts", ".", "getValue", "(", "CLASS", ")", "==", "null", "&&", "value", "!=", "null", ")", "{", "if", "(", "!", "LEVELS", ".", "contains", "(", "value", ".", "trim", "(", ")", ".", "toLowerCase", "(", ")", ")", ")", "{", "String", "message", "=", "Services", ".", "getMessage", "(", "\"\"", ",", "value", ")", ";", "errors", ".", "add", "(", "new", "Error", "(", "message", ",", "file", ",", "locator", ".", "getLineNumber", "(", ")", ",", "1", ",", "false", ")", ")", ";", "}", "}", "}", "String", "classname", "=", "atts", ".", "getValue", "(", "CLASS", ")", ";", "if", "(", "classname", "!=", "null", ")", "{", "IType", "type", "=", "project", ".", "findType", "(", "classname", ")", ";", "if", "(", "type", "==", "null", "||", "!", "type", ".", "exists", "(", ")", ")", "{", "String", "message", "=", "Services", ".", "getMessage", "(", "\"\"", ",", "project", ".", "getElementName", "(", ")", ",", "classname", ")", ";", "errors", ".", "add", "(", "new", "Error", "(", "message", ",", "file", ",", "locator", ".", "getLineNumber", "(", ")", ",", "1", ",", "false", ")", ")", ";", "}", "}", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "}", "public", "List", "<", "Error", ">", "getErrors", "(", ")", "{", "return", "errors", ";", "}", "private", "IPackageFragment", "getPackage", "(", "String", "name", ")", "throws", "Exception", "{", "IPackageFragmentRoot", "[", "]", "roots", "=", "project", ".", "getAllPackageFragmentRoots", "(", ")", ";", "for", "(", "int", "ii", "=", "0", ";", "ii", "<", "roots", ".", "length", ";", "ii", "++", ")", "{", "IPackageFragment", "fragment", "=", "roots", "[", "ii", "]", ".", "getPackageFragment", "(", "name", ")", ";", "if", "(", "fragment", "!=", "null", "&&", "fragment", ".", "exists", "(", ")", ")", "{", "return", "fragment", ";", "}", "}", "return", "null", ";", "}", "}", "}", "</s>" ]
1,216
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "complete", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "eclim", ".", "command", ".", "Error", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "include", ".", "ImportUtils", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "search", ".", "SearchRequestor", ";", "import", "org", ".", "eclim", ".", "util", ".", "file", ".", "FileOffsets", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "IProject", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "IResource", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "IStatus", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "Status", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "CompletionProposal", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "Flags", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "ICompilationUnit", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IJavaElement", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IJavaProject", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IType", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "compiler", ".", "IProblem", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "search", ".", "IJavaSearchConstants", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "search", ".", "IJavaSearchScope", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "search", ".", "SearchEngine", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "search", ".", "SearchMatch", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "search", ".", "SearchParticipant", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "search", ".", "SearchPattern", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "ui", ".", "JavaPlugin", ";", "public", "class", "CompletionProposalCollector", "extends", "org", ".", "eclipse", ".", "jdt", ".", "ui", ".", "text", ".", "java", ".", "CompletionProposalCollector", "{", "private", "ArrayList", "<", "CompletionProposal", ">", "proposals", "=", "new", "ArrayList", "<", "CompletionProposal", ">", "(", ")", ";", "private", "ArrayList", "<", "String", ">", "imports", ";", "private", "Error", "error", ";", "public", "CompletionProposalCollector", "(", "ICompilationUnit", "cu", ")", "{", "super", "(", "cu", ")", ";", "}", "public", "void", "accept", "(", "CompletionProposal", "proposal", ")", "{", "try", "{", "if", "(", "isFiltered", "(", "proposal", ")", ")", "{", "return", ";", "}", "if", "(", "proposal", ".", "getKind", "(", ")", "!=", "CompletionProposal", ".", "POTENTIAL_METHOD_DECLARATION", ")", "{", "switch", "(", "proposal", ".", "getKind", "(", ")", ")", "{", "case", "CompletionProposal", ".", "KEYWORD", ":", "case", "CompletionProposal", ".", "PACKAGE_REF", ":", "case", "CompletionProposal", ".", "TYPE_REF", ":", "case", "CompletionProposal", ".", "FIELD_REF", ":", "case", "CompletionProposal", ".", "METHOD_REF", ":", "case", "CompletionProposal", ".", "METHOD_NAME_REFERENCE", ":", "case", "CompletionProposal", ".", "METHOD_DECLARATION", ":", "case", "CompletionProposal", ".", "ANONYMOUS_CLASS_DECLARATION", ":", "case", "CompletionProposal", ".", "LABEL_REF", ":", "case", "CompletionProposal", ".", "LOCAL_VARIABLE_REF", ":", "case", "CompletionProposal", ".", "VARIABLE_DECLARATION", ":", "case", "CompletionProposal", ".", "ANNOTATION_ATTRIBUTE_REF", ":", "case", "CompletionProposal", ".", "POTENTIAL_METHOD_DECLARATION", ":", "proposals", ".", "add", "(", "proposal", ")", ";", "super", ".", "accept", "(", "proposal", ")", ";", "break", ";", "default", ":", "}", "}", "}", "catch", "(", "IllegalArgumentException", "e", ")", "{", "JavaPlugin", ".", "log", "(", "new", "Status", "(", "IStatus", ".", "ERROR", ",", "JavaPlugin", ".", "getPluginId", "(", ")", ",", "IStatus", ".", "OK", ",", "\"\"", "+", "String", ".", "valueOf", "(", "proposal", ".", "getCompletion", "(", ")", ")", ",", "e", ")", ")", ";", "}", "}", "public", "CompletionProposal", "getProposal", "(", "int", "index", ")", "{", "return", "(", "CompletionProposal", ")", "proposals", ".", "get", "(", "index", ")", ";", "}", "public", "void", "completionFailure", "(", "IProblem", "problem", ")", "{", "ICompilationUnit", "src", "=", "getCompilationUnit", "(", ")", ";", "IJavaProject", "javaProject", "=", "src", ".", "getJavaProject", "(", ")", ";", "IProject", "project", "=", "javaProject", ".", "getProject", "(", ")", ";", "if", "(", "problem", ".", "getID", "(", ")", "==", "IProblem", ".", "UndefinedType", "||", "problem", ".", "getID", "(", ")", "==", "IProblem", ".", "UnresolvedVariable", ")", "{", "try", "{", "SearchPattern", "pattern", "=", "SearchPattern", ".", "createPattern", "(", "problem", ".", "getArguments", "(", ")", "[", "0", "]", ",", "IJavaSearchConstants", ".", "TYPE", ",", "IJavaSearchConstants", ".", "DECLARATIONS", ",", "SearchPattern", ".", "R_EXACT_MATCH", "|", "SearchPattern", ".", "R_CASE_SENSITIVE", ")", ";", "IJavaSearchScope", "scope", "=", "SearchEngine", ".", "createJavaSearchScope", "(", "new", "IJavaElement", "[", "]", "{", "javaProject", "}", ")", ";", "SearchRequestor", "requestor", "=", "new", "SearchRequestor", "(", ")", ";", "SearchEngine", "engine", "=", "new", "SearchEngine", "(", ")", ";", "SearchParticipant", "[", "]", "participants", "=", "new", "SearchParticipant", "[", "]", "{", "SearchEngine", ".", "getDefaultSearchParticipant", "(", ")", "}", ";", "engine", ".", "search", "(", "pattern", ",", "participants", ",", "scope", ",", "requestor", ",", "null", ")", ";", "if", "(", "requestor", ".", "getMatches", "(", ")", ".", "size", "(", ")", ">", "0", ")", "{", "imports", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "for", "(", "SearchMatch", "match", ":", "requestor", ".", "getMatches", "(", ")", ")", "{", "if", "(", "match", ".", "getAccuracy", "(", ")", "!=", "SearchMatch", ".", "A_ACCURATE", ")", "{", "continue", ";", "}", "IJavaElement", "element", "=", "(", "IJavaElement", ")", "match", ".", "getElement", "(", ")", ";", "String", "name", "=", "null", ";", "switch", "(", "element", ".", "getElementType", "(", ")", ")", "{", "case", "IJavaElement", ".", "TYPE", ":", "IType", "type", "=", "(", "IType", ")", "element", ";", "if", "(", "Flags", ".", "isPublic", "(", "type", ".", "getFlags", "(", ")", ")", ")", "{", "name", "=", "type", ".", "getFullyQualifiedName", "(", ")", ";", "}", "break", ";", "case", "IJavaElement", ".", "METHOD", ":", "case", "IJavaElement", ".", "FIELD", ":", "name", "=", "(", "(", "IType", ")", "element", ".", "getParent", "(", ")", ")", ".", "getFullyQualifiedName", "(", ")", "+", "'.'", "+", "element", ".", "getElementName", "(", ")", ";", "break", ";", "}", "if", "(", "name", "!=", "null", ")", "{", "name", "=", "name", ".", "replace", "(", "'$'", ",", "'.'", ")", ";", "if", "(", "!", "ImportUtils", ".", "isImportExcluded", "(", "project", ",", "name", ")", ")", "{", "imports", ".", "add", "(", "name", ")", ";", "}", "}", "}", "}", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "}", "IResource", "resource", "=", "src", ".", "getResource", "(", ")", ";", "String", "relativeName", "=", "resource", ".", "getProjectRelativePath", "(", ")", ".", "toString", "(", ")", ";", "if", "(", "new", "String", "(", "problem", ".", "getOriginatingFileName", "(", ")", ")", ".", "endsWith", "(", "relativeName", ")", ")", "{", "String", "filename", "=", "resource", ".", "getLocation", "(", ")", ".", "toString", "(", ")", ";", "if", "(", "problem", ".", "getID", "(", ")", "==", "IProblem", ".", "PublicClassMustMatchFileName", "&&", "filename", ".", "indexOf", "(", "\"\"", ")", "!=", "-", "1", ")", "{", "return", ";", "}", "FileOffsets", "offsets", "=", "FileOffsets", ".", "compile", "(", "filename", ")", ";", "int", "[", "]", "lineColumn", "=", "offsets", ".", "offsetToLineColumn", "(", "problem", ".", "getSourceStart", "(", ")", ")", ";", "error", "=", "new", "Error", "(", "problem", ".", "getMessage", "(", ")", ",", "filename", ".", "replace", "(", "\"\"", ",", "\"\"", ")", ",", "lineColumn", "[", "0", "]", ",", "lineColumn", "[", "1", "]", ",", "problem", ".", "isWarning", "(", ")", ")", ";", "}", "}", "public", "List", "<", "String", ">", "getImports", "(", ")", "{", "return", "imports", ";", "}", "public", "Error", "getError", "(", ")", "{", "return", "error", ";", "}", "}", "</s>" ]
1,217
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "complete", ";", "import", "java", ".", "text", ".", "Collator", ";", "import", "java", ".", "util", ".", "Comparator", ";", "import", "java", ".", "util", ".", "Locale", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "command", ".", "complete", ".", "CodeCompleteResult", ";", "public", "class", "CompletionComparator", "implements", "Comparator", "<", "CodeCompleteResult", ">", "{", "public", "int", "compare", "(", "CodeCompleteResult", "o1", ",", "CodeCompleteResult", "o2", ")", "{", "if", "(", "o1", "==", "null", "&&", "o2", "==", "null", ")", "{", "return", "0", ";", "}", "else", "if", "(", "o2", "==", "null", ")", "{", "return", "-", "1", ";", "}", "else", "if", "(", "o1", "==", "null", ")", "{", "return", "1", ";", "}", "if", "(", "o1", ".", "getType", "(", ")", "==", "CodeCompleteResult", ".", "KEYWORD", "&&", "o2", ".", "getType", "(", ")", "!=", "CodeCompleteResult", ".", "KEYWORD", ")", "{", "return", "1", ";", "}", "else", "if", "(", "o2", ".", "getType", "(", ")", "==", "CodeCompleteResult", ".", "KEYWORD", "&&", "o1", ".", "getType", "(", ")", "!=", "CodeCompleteResult", ".", "KEYWORD", ")", "{", "return", "-", "1", ";", "}", "return", "Collator", ".", "getInstance", "(", "Locale", ".", "US", ")", ".", "compare", "(", "new", "String", "(", "o1", ".", "getCompletion", "(", ")", ")", ",", "new", "String", "(", "o2", ".", "getCompletion", "(", ")", ")", ")", ";", "}", "public", "boolean", "equals", "(", "Object", "obj", ")", "{", "if", "(", "obj", "instanceof", "CompletionComparator", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}", "}", "</s>" ]
1,218
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "complete", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Collections", ";", "import", "java", ".", "util", ".", "Comparator", ";", "import", "org", ".", "eclim", ".", "annotation", ".", "Command", ";", "import", "org", ".", "eclim", ".", "command", ".", "CommandLine", ";", "import", "org", ".", "eclim", ".", "command", ".", "Options", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "command", ".", "complete", ".", "AbstractCodeCompleteCommand", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "command", ".", "complete", ".", "CodeCompleteResult", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "util", ".", "JavaUtils", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "CompletionProposal", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "ICompilationUnit", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "ui", ".", "text", ".", "java", ".", "JavaCompletionProposal", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "ui", ".", "text", ".", "java", ".", "LazyJavaCompletionProposal", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "ui", ".", "text", ".", "java", ".", "IJavaCompletionProposal", ";", "@", "Command", "(", "name", "=", "\"\"", ",", "options", "=", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", ")", "public", "class", "CodeCompleteCommand", "extends", "AbstractCodeCompleteCommand", "{", "private", "static", "final", "Comparator", "<", "CodeCompleteResult", ">", "COMPLETION_COMPARATOR", "=", "new", "CompletionComparator", "(", ")", ";", "private", "static", "String", "COMPACT", "=", "\"compact\"", ";", "public", "Object", "execute", "(", "CommandLine", "commandLine", ")", "throws", "Exception", "{", "String", "project", "=", "commandLine", ".", "getValue", "(", "Options", ".", "PROJECT_OPTION", ")", ";", "String", "file", "=", "commandLine", ".", "getValue", "(", "Options", ".", "FILE_OPTION", ")", ";", "int", "offset", "=", "getOffset", "(", "commandLine", ")", ";", "ICompilationUnit", "src", "=", "JavaUtils", ".", "getCompilationUnit", "(", "project", ",", "file", ")", ";", "CompletionProposalCollector", "collector", "=", "new", "CompletionProposalCollector", "(", "src", ")", ";", "src", ".", "codeComplete", "(", "offset", ",", "collector", ")", ";", "IJavaCompletionProposal", "[", "]", "proposals", "=", "collector", ".", "getJavaCompletionProposals", "(", ")", ";", "ArrayList", "<", "CodeCompleteResult", ">", "results", "=", "new", "ArrayList", "<", "CodeCompleteResult", ">", "(", ")", ";", "for", "(", "int", "ii", "=", "0", ";", "ii", "<", "proposals", ".", "length", ";", "ii", "++", ")", "{", "results", ".", "add", "(", "createCompletionResult", "(", "collector", ",", "ii", ",", "proposals", "[", "ii", "]", ")", ")", ";", "}", "Collections", ".", "sort", "(", "results", ",", "COMPLETION_COMPARATOR", ")", ";", "String", "layout", "=", "commandLine", ".", "getValue", "(", "Options", ".", "LAYOUT_OPTION", ")", ";", "if", "(", "COMPACT", ".", "equals", "(", "layout", ")", "&&", "results", ".", "size", "(", ")", ">", "0", ")", "{", "results", "=", "compact", "(", "results", ")", ";", "}", "return", "new", "CodeCompleteResponse", "(", "results", ",", "collector", ".", "getError", "(", ")", ",", "collector", ".", "getImports", "(", ")", ")", ";", "}", "protected", "CodeCompleteResult", "createCompletionResult", "(", "CompletionProposalCollector", "collector", ",", "int", "index", ",", "IJavaCompletionProposal", "proposal", ")", "{", "String", "completion", "=", "null", ";", "String", "menu", "=", "proposal", ".", "getDisplayString", "(", ")", ";", "if", "(", "proposal", "instanceof", "JavaCompletionProposal", ")", "{", "JavaCompletionProposal", "lazy", "=", "(", "JavaCompletionProposal", ")", "proposal", ";", "completion", "=", "lazy", ".", "getReplacementString", "(", ")", ";", "}", "else", "if", "(", "proposal", "instanceof", "LazyJavaCompletionProposal", ")", "{", "LazyJavaCompletionProposal", "lazy", "=", "(", "LazyJavaCompletionProposal", ")", "proposal", ";", "completion", "=", "lazy", ".", "getReplacementString", "(", ")", ";", "}", "int", "kind", "=", "collector", ".", "getProposal", "(", "index", ")", ".", "getKind", "(", ")", ";", "switch", "(", "kind", ")", "{", "case", "CompletionProposal", ".", "METHOD_REF", ":", "if", "(", "menu", ".", "lastIndexOf", "(", "')'", ")", ">", "menu", ".", "lastIndexOf", "(", "'('", ")", "+", "1", "&&", "(", "completion", ".", "length", "(", ")", ">", "0", "&&", "completion", ".", "charAt", "(", "completion", ".", "length", "(", ")", "-", "1", ")", "==", "')'", ")", ")", "{", "completion", "=", "completion", ".", "substring", "(", "0", ",", "completion", ".", "length", "(", ")", "-", "1", ")", ";", "}", "break", ";", "case", "CompletionProposal", ".", "TYPE_REF", ":", "int", "idx", "=", "completion", ".", "lastIndexOf", "(", "'.'", ")", ";", "if", "(", "idx", "!=", "-", "1", ")", "{", "completion", "=", "completion", ".", "substring", "(", "idx", "+", "1", ")", ";", "}", "break", ";", "}", "if", "(", "\"class\"", ".", "equals", "(", "completion", ")", ")", "{", "kind", "=", "CompletionProposal", ".", "KEYWORD", ";", "}", "String", "type", "=", "\"\"", ";", "switch", "(", "kind", ")", "{", "case", "CompletionProposal", ".", "TYPE_REF", ":", "type", "=", "CodeCompleteResult", ".", "TYPE", ";", "break", ";", "case", "CompletionProposal", ".", "FIELD_REF", ":", "case", "CompletionProposal", ".", "LOCAL_VARIABLE_REF", ":", "type", "=", "CodeCompleteResult", ".", "VARIABLE", ";", "type", "=", "CodeCompleteResult", ".", "VARIABLE", ";", "break", ";", "case", "CompletionProposal", ".", "METHOD_REF", ":", "type", "=", "CodeCompleteResult", ".", "FUNCTION", ";", "break", ";", "case", "CompletionProposal", ".", "KEYWORD", ":", "type", "=", "CodeCompleteResult", ".", "KEYWORD", ";", "break", ";", "}", "return", "new", "CodeCompleteResult", "(", "completion", ",", "menu", ",", "menu", ",", "type", ")", ";", "}", "}", "</s>" ]
1,219
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "complete", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "eclim", ".", "command", ".", "Error", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "command", ".", "complete", ".", "CodeCompleteResult", ";", "@", "SuppressWarnings", "(", "\"unused\"", ")", "public", "class", "CodeCompleteResponse", "{", "private", "List", "<", "CodeCompleteResult", ">", "completions", ";", "private", "Error", "error", ";", "private", "List", "<", "String", ">", "imports", ";", "public", "CodeCompleteResponse", "(", "List", "<", "CodeCompleteResult", ">", "completions", ",", "Error", "error", ",", "List", "<", "String", ">", "imports", ")", "{", "this", ".", "completions", "=", "completions", ";", "this", ".", "error", "=", "error", ";", "this", ".", "imports", "=", "imports", ";", "}", "}", "</s>" ]
1,220
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "launching", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "org", ".", "eclim", ".", "annotation", ".", "Command", ";", "import", "org", ".", "eclim", ".", "command", ".", "CommandLine", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "command", ".", "AbstractCommand", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "launching", ".", "AbstractVMInstall", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "launching", ".", "IVMInstall", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "launching", ".", "IVMInstallType", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "launching", ".", "JavaRuntime", ";", "@", "Command", "(", "name", "=", "\"\"", ")", "public", "class", "ListVmInstalls", "extends", "AbstractCommand", "{", "public", "Object", "execute", "(", "CommandLine", "commandLine", ")", "throws", "Exception", "{", "ArrayList", "<", "HashMap", "<", "String", ",", "Object", ">", ">", "results", "=", "new", "ArrayList", "<", "HashMap", "<", "String", ",", "Object", ">", ">", "(", ")", ";", "AbstractVMInstall", "defaultInstall", "=", "(", "AbstractVMInstall", ")", "JavaRuntime", ".", "getDefaultVMInstall", "(", ")", ";", "IVMInstallType", "[", "]", "types", "=", "JavaRuntime", ".", "getVMInstallTypes", "(", ")", ";", "for", "(", "IVMInstallType", "type", ":", "types", ")", "{", "IVMInstall", "[", "]", "installs", "=", "type", ".", "getVMInstalls", "(", ")", ";", "if", "(", "installs", ".", "length", ">", "0", ")", "{", "for", "(", "IVMInstall", "iinstall", ":", "installs", ")", "{", "AbstractVMInstall", "install", "=", "(", "AbstractVMInstall", ")", "iinstall", ";", "HashMap", "<", "String", ",", "Object", ">", "result", "=", "new", "HashMap", "<", "String", ",", "Object", ">", "(", ")", ";", "results", ".", "add", "(", "result", ")", ";", "result", ".", "put", "(", "\"type\"", ",", "type", ".", "getName", "(", ")", ")", ";", "result", ".", "put", "(", "\"name\"", ",", "install", ".", "getName", "(", ")", ")", ";", "result", ".", "put", "(", "\"dir\"", ",", "install", ".", "getInstallLocation", "(", ")", ".", "getPath", "(", ")", ")", ";", "result", ".", "put", "(", "\"version\"", ",", "install", ".", "getJavaVersion", "(", ")", ")", ";", "result", ".", "put", "(", "\"args\"", ",", "install", ".", "getVMArgs", "(", ")", ")", ";", "result", ".", "put", "(", "\"default\"", ",", "install", ".", "equals", "(", "defaultInstall", ")", ")", ";", "}", "}", "}", "return", "results", ";", "}", "}", "</s>" ]
1,221
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "launching", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "io", ".", "InputStream", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "io", ".", "OutputStream", ";", "import", "java", ".", "lang", ".", "reflect", ".", "Method", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "org", ".", "apache", ".", "tools", ".", "ant", ".", "BuildException", ";", "import", "org", ".", "apache", ".", "tools", ".", "ant", ".", "BuildLogger", ";", "import", "org", ".", "apache", ".", "tools", ".", "ant", ".", "DefaultLogger", ";", "import", "org", ".", "apache", ".", "tools", ".", "ant", ".", "Project", ";", "import", "org", ".", "apache", ".", "tools", ".", "ant", ".", "Task", ";", "import", "org", ".", "apache", ".", "tools", ".", "ant", ".", "taskdefs", ".", "ExecuteStreamHandler", ";", "import", "org", ".", "apache", ".", "tools", ".", "ant", ".", "taskdefs", ".", "Java", ";", "import", "org", ".", "apache", ".", "tools", ".", "ant", ".", "taskdefs", ".", "PumpStreamHandler", ";", "import", "org", ".", "apache", ".", "tools", ".", "ant", ".", "taskdefs", ".", "Redirector", ";", "import", "org", ".", "apache", ".", "tools", ".", "ant", ".", "taskdefs", ".", "StreamPumper", ";", "import", "org", ".", "apache", ".", "tools", ".", "ant", ".", "types", ".", "Commandline", ".", "Argument", ";", "import", "org", ".", "apache", ".", "tools", ".", "ant", ".", "types", ".", "Environment", ".", "Variable", ";", "import", "org", ".", "apache", ".", "tools", ".", "ant", ".", "types", ".", "Path", ";", "import", "org", ".", "eclim", ".", "Services", ";", "import", "org", ".", "eclim", ".", "annotation", ".", "Command", ";", "import", "org", ".", "eclim", ".", "command", ".", "CommandLine", ";", "import", "org", ".", "eclim", ".", "command", ".", "Options", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "command", ".", "AbstractCommand", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "util", ".", "ProjectUtils", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "util", ".", "ClasspathUtils", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "util", ".", "JavaUtils", ";", "import", "org", ".", "eclim", ".", "util", ".", "StringUtils", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "IProject", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "IncrementalProjectBuilder", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "Flags", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IClasspathEntry", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "ICompilationUnit", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IJavaElement", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IJavaProject", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IMethod", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IPackageDeclaration", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IPackageFragmentRoot", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "JavaModelException", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "Signature", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "search", ".", "IJavaSearchConstants", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "search", ".", "IJavaSearchScope", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "search", ".", "SearchEngine", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "search", ".", "SearchMatch", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "search", ".", "SearchParticipant", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "search", ".", "SearchPattern", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "search", ".", "SearchRequestor", ";", "@", "Command", "(", "name", "=", "\"java\"", ",", "options", "=", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", ")", "public", "class", "JavaCommand", "extends", "AbstractCommand", "{", "private", "static", "final", "String", "WORKINGDIR_OPTION", "=", "\"w\"", ";", "private", "static", "final", "String", "VMARGS_OPTION", "=", "\"v\"", ";", "private", "static", "final", "String", "SYSPROPS_OPTION", "=", "\"s\"", ";", "private", "static", "final", "String", "ENVARGS_OPTION", "=", "\"e\"", ";", "public", "Object", "execute", "(", "CommandLine", "commandLine", ")", "throws", "Exception", "{", "String", "projectName", "=", "commandLine", ".", "getValue", "(", "Options", ".", "PROJECT_OPTION", ")", ";", "String", "mainClass", "=", "commandLine", ".", "getValue", "(", "Options", ".", "CLASSNAME_OPTION", ")", ";", "boolean", "debug", "=", "commandLine", ".", "hasOption", "(", "Options", ".", "DEBUG_OPTION", ")", ";", "String", "workingDir", "=", "commandLine", ".", "getValue", "(", "WORKINGDIR_OPTION", ")", ";", "IProject", "project", "=", "ProjectUtils", ".", "getProject", "(", "projectName", ")", ";", "project", ".", "build", "(", "IncrementalProjectBuilder", ".", "INCREMENTAL_BUILD", ",", "null", ")", ";", "IJavaProject", "javaProject", "=", "JavaUtils", ".", "getJavaProject", "(", "project", ")", ";", "Project", "antProject", "=", "new", "Project", "(", ")", ";", "BuildLogger", "buildLogger", "=", "new", "DefaultLogger", "(", ")", ";", "buildLogger", ".", "setMessageOutputLevel", "(", "debug", "?", "Project", ".", "MSG_DEBUG", ":", "Project", ".", "MSG_INFO", ")", ";", "buildLogger", ".", "setOutputPrintStream", "(", "getContext", "(", ")", ".", "out", ")", ";", "buildLogger", ".", "setErrorPrintStream", "(", "getContext", "(", ")", ".", "err", ")", ";", "antProject", ".", "addBuildListener", "(", "buildLogger", ")", ";", "antProject", ".", "setBasedir", "(", "ProjectUtils", ".", "getPath", "(", "project", ")", ")", ";", "antProject", ".", "setDefaultInputStream", "(", "System", ".", "in", ")", ";", "if", "(", "mainClass", "==", "null", ")", "{", "mainClass", "=", "getPreferences", "(", ")", ".", "getValue", "(", "project", ",", "\"\"", ")", ";", "}", "if", "(", "mainClass", "==", "null", "||", "mainClass", ".", "trim", "(", ")", ".", "equals", "(", "StringUtils", ".", "EMPTY", ")", "||", "mainClass", ".", "trim", "(", ")", ".", "equals", "(", "\"none\"", ")", ")", "{", "mainClass", "=", "findMainClass", "(", "javaProject", ")", ";", "if", "(", "mainClass", "==", "null", ")", "{", "throw", "new", "RuntimeException", "(", "Services", ".", "getMessage", "(", "\"\"", ",", "\"\"", ")", ")", ";", "}", "}", "if", "(", "mainClass", ".", "endsWith", "(", "\".java\"", ")", "||", "mainClass", ".", "endsWith", "(", "\".class\"", ")", ")", "{", "mainClass", "=", "mainClass", ".", "substring", "(", "0", ",", "mainClass", ".", "lastIndexOf", "(", "'.'", ")", ")", ";", "}", "Java", "java", "=", "new", "MyJava", "(", ")", ";", "java", ".", "setTaskName", "(", "\"java\"", ")", ";", "java", ".", "setProject", "(", "antProject", ")", ";", "java", ".", "setClassname", "(", "mainClass", ")", ";", "java", ".", "setFork", "(", "true", ")", ";", "if", "(", "workingDir", "!=", "null", ")", "{", "java", ".", "setDir", "(", "new", "File", "(", "workingDir", ")", ")", ";", "}", "Path", "classpath", "=", "new", "Path", "(", "antProject", ")", ";", "String", "[", "]", "paths", "=", "ClasspathUtils", ".", "getClasspath", "(", "javaProject", ")", ";", "for", "(", "String", "path", ":", "paths", ")", "{", "Path", ".", "PathElement", "pe", "=", "classpath", ".", "createPathElement", "(", ")", ";", "pe", ".", "setPath", "(", "path", ")", ";", "}", "java", ".", "setClasspath", "(", "classpath", ")", ";", "String", "[", "]", "defaultArgs", "=", "getPreferences", "(", ")", ".", "getArrayValue", "(", "project", ",", "\"\"", ")", ";", "for", "(", "String", "vmarg", ":", "defaultArgs", ")", "{", "if", "(", "!", "vmarg", ".", "startsWith", "(", "\"-\"", ")", ")", "{", "continue", ";", "}", "Argument", "a", "=", "java", ".", "createJvmarg", "(", ")", ";", "a", ".", "setValue", "(", "vmarg", ")", ";", "}", "String", "[", "]", "vmargs", "=", "commandLine", ".", "getValues", "(", "VMARGS_OPTION", ")", ";", "if", "(", "vmargs", "!=", "null", "&&", "vmargs", ".", "length", ">", "0", ")", "{", "for", "(", "String", "vmarg", ":", "vmargs", ")", "{", "if", "(", "!", "vmarg", ".", "startsWith", "(", "\"-\"", ")", ")", "{", "continue", ";", "}", "Argument", "a", "=", "java", ".", "createJvmarg", "(", ")", ";", "a", ".", "setValue", "(", "vmarg", ")", ";", "}", "}", "String", "[", "]", "props", "=", "commandLine", ".", "getValues", "(", "SYSPROPS_OPTION", ")", ";", "if", "(", "props", "!=", "null", "&&", "props", ".", "length", ">", "0", ")", "{", "for", "(", "String", "prop", ":", "props", ")", "{", "String", "[", "]", "sysprop", "=", "StringUtils", ".", "split", "(", "prop", ",", "\"=\"", ",", "2", ")", ";", "if", "(", "sysprop", ".", "length", "!=", "2", ")", "{", "continue", ";", "}", "if", "(", "sysprop", "[", "0", "]", ".", "startsWith", "(", "\"-D\"", ")", ")", "{", "sysprop", "[", "0", "]", "=", "sysprop", "[", "0", "]", ".", "substring", "(", "2", ")", ";", "}", "Variable", "var", "=", "new", "Variable", "(", ")", ";", "var", ".", "setKey", "(", "sysprop", "[", "0", "]", ")", ";", "var", ".", "setValue", "(", "sysprop", "[", "1", "]", ")", ";", "java", ".", "addSysproperty", "(", "var", ")", ";", "}", "}", "String", "[", "]", "envs", "=", "commandLine", ".", "getValues", "(", "ENVARGS_OPTION", ")", ";", "if", "(", "envs", "!=", "null", "&&", "envs", ".", "length", ">", "0", ")", "{", "for", "(", "String", "env", ":", "envs", ")", "{", "String", "[", "]", "envvar", "=", "StringUtils", ".", "split", "(", "env", ",", "\"=\"", ",", "2", ")", ";", "if", "(", "envvar", ".", "length", "!=", "2", ")", "{", "continue", ";", "}", "Variable", "var", "=", "new", "Variable", "(", ")", ";", "var", ".", "setKey", "(", "envvar", "[", "0", "]", ")", ";", "var", ".", "setValue", "(", "envvar", "[", "1", "]", ")", ";", "java", ".", "addEnv", "(", "var", ")", ";", "}", "}", "String", "[", "]", "args", "=", "commandLine", ".", "getValues", "(", "Options", ".", "ARGS_OPTION", ")", ";", "if", "(", "args", "!=", "null", "&&", "args", ".", "length", ">", "0", ")", "{", "for", "(", "String", "arg", ":", "args", ")", "{", "Argument", "a", "=", "java", ".", "createArg", "(", ")", ";", "a", ".", "setValue", "(", "arg", ")", ";", "}", "}", "java", ".", "execute", "(", ")", ";", "return", "null", ";", "}", "private", "String", "findMainClass", "(", "IJavaProject", "javaProject", ")", "throws", "Exception", "{", "ArrayList", "<", "IJavaElement", ">", "srcs", "=", "new", "ArrayList", "<", "IJavaElement", ">", "(", ")", ";", "for", "(", "IClasspathEntry", "entry", ":", "javaProject", ".", "getResolvedClasspath", "(", "true", ")", ")", "{", "if", "(", "entry", ".", "getEntryKind", "(", ")", "==", "IClasspathEntry", ".", "CPE_SOURCE", ")", "{", "for", "(", "IPackageFragmentRoot", "root", ":", "javaProject", ".", "findPackageFragmentRoots", "(", "entry", ")", ")", "{", "srcs", ".", "add", "(", "root", ")", ";", "}", "}", "}", "final", "ArrayList", "<", "IMethod", ">", "methods", "=", "new", "ArrayList", "<", "IMethod", ">", "(", ")", ";", "int", "context", "=", "IJavaSearchConstants", ".", "DECLARATIONS", ";", "int", "type", "=", "IJavaSearchConstants", ".", "METHOD", ";", "int", "matchType", "=", "SearchPattern", ".", "R_EXACT_MATCH", "|", "SearchPattern", ".", "R_CASE_SENSITIVE", ";", "IJavaSearchScope", "scope", "=", "SearchEngine", ".", "createJavaSearchScope", "(", "srcs", ".", "toArray", "(", "new", "IJavaElement", "[", "srcs", ".", "size", "(", ")", "]", ")", ")", ";", "SearchPattern", "pattern", "=", "SearchPattern", ".", "createPattern", "(", "\"\"", ",", "type", ",", "context", ",", "matchType", ")", ";", "SearchRequestor", "requestor", "=", "new", "SearchRequestor", "(", ")", "{", "public", "void", "acceptSearchMatch", "(", "SearchMatch", "match", ")", "{", "if", "(", "match", ".", "getAccuracy", "(", ")", "!=", "SearchMatch", ".", "A_ACCURATE", ")", "{", "return", ";", "}", "try", "{", "IMethod", "method", "=", "(", "IMethod", ")", "match", ".", "getElement", "(", ")", ";", "String", "[", "]", "params", "=", "method", ".", "getParameterTypes", "(", ")", ";", "if", "(", "params", ".", "length", "!=", "1", ")", "{", "return", ";", "}", "if", "(", "!", "Signature", ".", "SIG_VOID", ".", "equals", "(", "method", ".", "getReturnType", "(", ")", ")", ")", "{", "return", ";", "}", "int", "flags", "=", "method", ".", "getFlags", "(", ")", ";", "if", "(", "!", "Flags", ".", "isPublic", "(", "flags", ")", "||", "!", "Flags", ".", "isStatic", "(", "flags", ")", ")", "{", "return", ";", "}", "methods", ".", "add", "(", "method", ")", ";", "}", "catch", "(", "JavaModelException", "e", ")", "{", "}", "}", "}", ";", "SearchEngine", "engine", "=", "new", "SearchEngine", "(", ")", ";", "SearchParticipant", "[", "]", "participants", "=", "new", "SearchParticipant", "[", "]", "{", "SearchEngine", ".", "getDefaultSearchParticipant", "(", ")", "}", ";", "engine", ".", "search", "(", "pattern", ",", "participants", ",", "scope", ",", "requestor", ",", "null", ")", ";", "if", "(", "methods", ".", "size", "(", ")", "==", "1", ")", "{", "IMethod", "method", "=", "methods", ".", "get", "(", "0", ")", ";", "ICompilationUnit", "cu", "=", "method", ".", "getCompilationUnit", "(", ")", ";", "IPackageDeclaration", "[", "]", "packages", "=", "cu", ".", "getPackageDeclarations", "(", ")", ";", "if", "(", "packages", "!=", "null", "&&", "packages", ".", "length", ">", "0", ")", "{", "return", "packages", "[", "0", "]", ".", "getElementName", "(", ")", "+", "\".\"", "+", "cu", ".", "getElementName", "(", ")", ";", "}", "return", "cu", ".", "getElementName", "(", ")", ";", "}", "return", "null", ";", "}", "private", "class", "MyJava", "extends", "Java", "{", "public", "MyJava", "(", ")", "{", "super", "(", ")", ";", "this", ".", "redirector", "=", "new", "MyRedirector", "(", "this", ")", ";", "}", "}", "private", "class", "MyRedirector", "extends", "Redirector", "{", "public", "MyRedirector", "(", "Task", "task", ")", "{", "super", "(", "task", ")", ";", "}", "@", "Override", "public", "synchronized", "ExecuteStreamHandler", "createHandler", "(", ")", "throws", "BuildException", "{", "return", "new", "MyPumpStreamHandler", "(", ")", ";", "}", "@", "Override", "public", "synchronized", "void", "complete", "(", ")", "throws", "IOException", "{", "getContext", "(", ")", ".", "out", ".", "flush", "(", ")", ";", "getContext", "(", ")", ".", "err", ".", "flush", "(", ")", ";", "}", "}", "private", "class", "MyPumpStreamHandler", "extends", "PumpStreamHandler", "{", "public", "MyPumpStreamHandler", "(", ")", "{", "super", "(", "new", "FlushingOutputStream", "(", "getContext", "(", ")", ".", "out", ")", ",", "getContext", "(", ")", ".", "err", ",", "getContext", "(", ")", ".", "in", ",", "true", ")", ";", "}", "protected", "Thread", "createPump", "(", "InputStream", "is", ",", "OutputStream", "os", ",", "boolean", "closeWhenExhausted", ",", "boolean", "nonBlockingIO", ")", "{", "Thread", "pump", "=", "super", ".", "createPump", "(", "is", ",", "os", ",", "closeWhenExhausted", ",", "nonBlockingIO", ")", ";", "try", "{", "Method", "getPumper", "=", "pump", ".", "getClass", "(", ")", ".", "getDeclaredMethod", "(", "\"getPumper\"", ")", ";", "getPumper", ".", "setAccessible", "(", "true", ")", ";", "StreamPumper", "pumper", "=", "(", "StreamPumper", ")", "getPumper", ".", "invoke", "(", "pump", ")", ";", "Method", "setAutoflush", "=", "pumper", ".", "getClass", "(", ")", ".", "getDeclaredMethod", "(", "\"setAutoflush\"", ",", "Boolean", ".", "TYPE", ")", ";", "setAutoflush", ".", "setAccessible", "(", "true", ")", ";", "setAutoflush", ".", "invoke", "(", "pumper", ",", "Boolean", ".", "TRUE", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "return", "pump", ";", "}", "}", "private", "class", "FlushingOutputStream", "extends", "OutputStream", "{", "private", "OutputStream", "out", ";", "public", "FlushingOutputStream", "(", "OutputStream", "out", ")", "{", "this", ".", "out", "=", "out", ";", "}", "@", "Override", "public", "void", "write", "(", "int", "b", ")", "throws", "IOException", "{", "out", ".", "write", "(", "b", ")", ";", "out", ".", "flush", "(", ")", ";", "}", "@", "Override", "public", "void", "write", "(", "byte", "[", "]", "b", ")", "throws", "IOException", "{", "out", ".", "write", "(", "b", ")", ";", "out", ".", "flush", "(", ")", ";", "}", "@", "Override", "public", "void", "write", "(", "byte", "[", "]", "b", ",", "int", "off", ",", "int", "len", ")", "throws", "IOException", "{", "out", ".", "write", "(", "b", ",", "off", ",", "len", ")", ";", "out", ".", "flush", "(", ")", ";", "}", "}", "}", "</s>" ]
1,222
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "junit", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Collections", ";", "import", "org", ".", "eclim", ".", "annotation", ".", "Command", ";", "import", "org", ".", "eclim", ".", "command", ".", "CommandLine", ";", "import", "org", ".", "eclim", ".", "command", ".", "Options", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "command", ".", "AbstractCommand", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "util", ".", "JavaUtils", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IJavaProject", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IType", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "junit", ".", "JUnitCore", ";", "@", "Command", "(", "name", "=", "\"\"", ",", "options", "=", "\"\"", ")", "public", "class", "JUnitTestsCommand", "extends", "AbstractCommand", "{", "@", "Override", "public", "Object", "execute", "(", "CommandLine", "commandLine", ")", "throws", "Exception", "{", "String", "projectName", "=", "commandLine", ".", "getValue", "(", "Options", ".", "PROJECT_OPTION", ")", ";", "IJavaProject", "javaProject", "=", "JavaUtils", ".", "getJavaProject", "(", "projectName", ")", ";", "ArrayList", "<", "String", ">", "names", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "IType", "[", "]", "types", "=", "JUnitCore", ".", "findTestTypes", "(", "javaProject", ",", "null", ")", ";", "for", "(", "IType", "type", ":", "types", ")", "{", "names", ".", "add", "(", "type", ".", "getFullyQualifiedName", "(", ")", ")", ";", "}", "Collections", ".", "sort", "(", "names", ")", ";", "return", "names", ";", "}", "}", "</s>" ]
1,223
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "junit", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "HashSet", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Set", ";", "import", "org", ".", "eclim", ".", "Services", ";", "import", "org", ".", "eclim", ".", "annotation", ".", "Command", ";", "import", "org", ".", "eclim", ".", "command", ".", "CommandLine", ";", "import", "org", ".", "eclim", ".", "command", ".", "Options", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "impl", ".", "ImplCommand", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "util", ".", "JavaUtils", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "IWorkspaceRunnable", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "IProgressMonitor", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "ICompilationUnit", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IJavaElement", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IJavaProject", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IType", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "dom", ".", "AST", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "dom", ".", "ASTNode", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "dom", ".", "AbstractTypeDeclaration", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "dom", ".", "Annotation", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "dom", ".", "Block", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "dom", ".", "ChildListPropertyDescriptor", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "dom", ".", "CompilationUnit", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "dom", ".", "IMethodBinding", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "dom", ".", "ITypeBinding", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "dom", ".", "MethodDeclaration", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "dom", ".", "Modifier", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "dom", ".", "rewrite", ".", "ASTRewrite", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "dom", ".", "rewrite", ".", "ImportRewrite", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "dom", ".", "rewrite", ".", "ListRewrite", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "corext", ".", "codemanipulation", ".", "StubUtility", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "corext", ".", "dom", ".", "ASTNodes", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "corext", ".", "refactoring", ".", "structure", ".", "ASTNodeSearchUtil", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "corext", ".", "refactoring", ".", "util", ".", "RefactoringASTParser", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "corext", ".", "util", ".", "JavaModelUtil", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "junit", ".", "JUnitCorePlugin", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "junit", ".", "Messages", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "junit", ".", "util", ".", "JUnitStubUtility", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "junit", ".", "wizards", ".", "WizardMessages", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "ui", ".", "javaeditor", ".", "ASTProvider", ";", "import", "org", ".", "eclipse", ".", "text", ".", "edits", ".", "MultiTextEdit", ";", "@", "Command", "(", "name", "=", "\"\"", ",", "options", "=", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", ")", "public", "class", "JUnitImplCommand", "extends", "ImplCommand", "{", "private", "ThreadLocal", "<", "ITypeBinding", ">", "base", "=", "new", "ThreadLocal", "<", "ITypeBinding", ">", "(", ")", ";", "@", "Override", "public", "Object", "execute", "(", "CommandLine", "commandLine", ")", "throws", "Exception", "{", "String", "projectName", "=", "commandLine", ".", "getValue", "(", "Options", ".", "PROJECT_OPTION", ")", ";", "String", "file", "=", "commandLine", ".", "getValue", "(", "Options", ".", "FILE_OPTION", ")", ";", "IJavaProject", "javaProject", "=", "JavaUtils", ".", "getJavaProject", "(", "projectName", ")", ";", "ICompilationUnit", "test", "=", "JavaUtils", ".", "getCompilationUnit", "(", "javaProject", ",", "file", ")", ";", "ICompilationUnit", "src", "=", "JUnitUtils", ".", "findClass", "(", "javaProject", ",", "test", ".", "getTypes", "(", ")", "[", "0", "]", ")", ";", "if", "(", "base", "==", "null", ")", "{", "return", "Services", ".", "getMessage", "(", "\"\"", ")", ";", "}", "RefactoringASTParser", "parser", "=", "new", "RefactoringASTParser", "(", "ASTProvider", ".", "SHARED_AST_LEVEL", ")", ";", "CompilationUnit", "cu", "=", "parser", ".", "parse", "(", "src", ",", "true", ")", ";", "ITypeBinding", "base", "=", "ASTNodeSearchUtil", ".", "getTypeDeclarationNode", "(", "src", ".", "getTypes", "(", ")", "[", "0", "]", ",", "cu", ")", ".", "resolveBinding", "(", ")", ";", "this", ".", "base", ".", "set", "(", "base", ")", ";", "return", "super", ".", "execute", "(", "commandLine", ")", ";", "}", "@", "Override", "protected", "List", "<", "IMethodBinding", ">", "getOverridableMethods", "(", "CompilationUnit", "cu", ",", "ITypeBinding", "typeBinding", ")", "throws", "Exception", "{", "HashSet", "<", "String", ">", "testMethods", "=", "new", "HashSet", "<", "String", ">", "(", ")", ";", "for", "(", "IMethodBinding", "method", ":", "typeBinding", ".", "getDeclaredMethods", "(", ")", ")", "{", "int", "modifiers", "=", "method", ".", "getModifiers", "(", ")", ";", "if", "(", "!", "method", ".", "isConstructor", "(", ")", "&&", "!", "Modifier", ".", "isPrivate", "(", "modifiers", ")", ")", "{", "testMethods", ".", "add", "(", "method", ".", "getName", "(", ")", ")", ";", "}", "}", "List", "<", "IMethodBinding", ">", "testable", "=", "new", "ArrayList", "<", "IMethodBinding", ">", "(", ")", ";", "ITypeBinding", "objectBinding", "=", "cu", ".", "getAST", "(", ")", ".", "resolveWellKnownType", "(", "\"\"", ")", ";", "ITypeBinding", "parentBinding", "=", "base", ".", "get", "(", ")", ";", "while", "(", "parentBinding", "!=", "null", "&&", "!", "parentBinding", ".", "equals", "(", "objectBinding", ")", ")", "{", "for", "(", "IMethodBinding", "method", ":", "parentBinding", ".", "getDeclaredMethods", "(", ")", ")", "{", "String", "name", "=", "method", ".", "getName", "(", ")", ";", "int", "modifiers", "=", "method", ".", "getModifiers", "(", ")", ";", "if", "(", "!", "method", ".", "isConstructor", "(", ")", "&&", "!", "Modifier", ".", "isPrivate", "(", "modifiers", ")", "&&", "!", "testMethods", ".", "contains", "(", "name", ")", ")", "{", "testable", ".", "add", "(", "method", ")", ";", "}", "}", "parentBinding", "=", "parentBinding", ".", "getSuperclass", "(", ")", ";", "}", "return", "testable", ";", "}", "@", "Override", "protected", "IWorkspaceRunnable", "getImplOperation", "(", "ICompilationUnit", "src", ",", "IType", "type", ",", "Set", "<", "String", ">", "chosen", ",", "IJavaElement", "sibling", ",", "int", "pos", ",", "CommandLine", "commandLine", ")", "throws", "Exception", "{", "RefactoringASTParser", "parser", "=", "new", "RefactoringASTParser", "(", "ASTProvider", ".", "SHARED_AST_LEVEL", ")", ";", "CompilationUnit", "cu", "=", "parser", ".", "parse", "(", "type", ".", "getCompilationUnit", "(", ")", ",", "true", ")", ";", "ITypeBinding", "typeBinding", "=", "ASTNodes", ".", "getTypeBinding", "(", "cu", ",", "type", ")", ";", "String", "superType", "=", "commandLine", ".", "getValue", "(", "Options", ".", "SUPERTYPE_OPTION", ")", ";", "List", "<", "IMethodBinding", ">", "testable", "=", "getOverridableMethods", "(", "cu", ",", "typeBinding", ")", ";", "List", "<", "IMethodBinding", ">", "tests", "=", "new", "ArrayList", "<", "IMethodBinding", ">", "(", ")", ";", "for", "(", "IMethodBinding", "binding", ":", "testable", ")", "{", "ITypeBinding", "declBinding", "=", "binding", ".", "getDeclaringClass", "(", ")", ";", "String", "fqn", "=", "declBinding", ".", "getQualifiedName", "(", ")", ".", "replaceAll", "(", "\"<.*?>\"", ",", "\"\"", ")", ";", "if", "(", "fqn", ".", "equals", "(", "superType", ")", "&&", "isChosen", "(", "chosen", ",", "binding", ")", ")", "{", "tests", ".", "add", "(", "binding", ")", ";", "}", "}", "if", "(", "tests", ".", "size", "(", ")", ">", "0", ")", "{", "return", "new", "AddTestMethodsOperation", "(", "cu", ",", "typeBinding", ",", "tests", ".", "toArray", "(", "new", "IMethodBinding", "[", "tests", ".", "size", "(", ")", "]", ")", ")", ";", "}", "return", "null", ";", "}", "private", "class", "AddTestMethodsOperation", "implements", "IWorkspaceRunnable", "{", "private", "CompilationUnit", "cu", ";", "private", "ITypeBinding", "typeBinding", ";", "private", "IMethodBinding", "[", "]", "methodBindings", ";", "public", "AddTestMethodsOperation", "(", "CompilationUnit", "cu", ",", "ITypeBinding", "typeBinding", ",", "IMethodBinding", "[", "]", "methodBindings", ")", "{", "this", ".", "cu", "=", "cu", ";", "this", ".", "typeBinding", "=", "typeBinding", ";", "this", ".", "methodBindings", "=", "methodBindings", ";", "}", "@", "Override", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "void", "run", "(", "IProgressMonitor", "monitor", ")", "{", "try", "{", "ICompilationUnit", "src", "=", "(", "ICompilationUnit", ")", "cu", ".", "getJavaElement", "(", ")", ";", "IJavaProject", "javaProject", "=", "src", ".", "getJavaProject", "(", ")", ";", "MultiTextEdit", "edit", "=", "new", "MultiTextEdit", "(", ")", ";", "ImportRewrite", "imports", "=", "StubUtility", ".", "createImportRewrite", "(", "cu", ",", "true", ")", ";", "imports", ".", "addStaticImport", "(", "\"\"", ",", "\"*\"", ",", "false", ")", ";", "imports", ".", "addImport", "(", "JUnitCorePlugin", ".", "JUNIT4_ANNOTATION_NAME", ")", ";", "edit", ".", "addChild", "(", "imports", ".", "rewriteImports", "(", "null", ")", ")", ";", "AST", "ast", "=", "cu", ".", "getAST", "(", ")", ";", "ASTRewrite", "astRewrite", "=", "ASTRewrite", ".", "create", "(", "ast", ")", ";", "ASTNode", "node", "=", "cu", ".", "findDeclaringNode", "(", "typeBinding", ")", ";", "ChildListPropertyDescriptor", "property", "=", "(", "(", "AbstractTypeDeclaration", ")", "node", ")", ".", "getBodyDeclarationsProperty", "(", ")", ";", "ListRewrite", "memberRewriter", "=", "astRewrite", ".", "getListRewrite", "(", "node", ",", "property", ")", ";", "HashSet", "<", "String", ">", "added", "=", "new", "HashSet", "<", "String", ">", "(", ")", ";", "for", "(", "IMethodBinding", "binding", ":", "methodBindings", ")", "{", "String", "name", "=", "binding", ".", "getName", "(", ")", ";", "if", "(", "added", ".", "contains", "(", "name", ")", ")", "{", "continue", ";", "}", "added", ".", "add", "(", "name", ")", ";", "MethodDeclaration", "stub", "=", "ast", ".", "newMethodDeclaration", "(", ")", ";", "stub", ".", "setConstructor", "(", "false", ")", ";", "stub", ".", "modifiers", "(", ")", ".", "addAll", "(", "ast", ".", "newModifiers", "(", "Modifier", ".", "PUBLIC", ")", ")", ";", "Annotation", "marker", "=", "ast", ".", "newMarkerAnnotation", "(", ")", ";", "marker", ".", "setTypeName", "(", "ast", ".", "newSimpleName", "(", "\"Test\"", ")", ")", ";", "astRewrite", ".", "getListRewrite", "(", "stub", ",", "MethodDeclaration", ".", "MODIFIERS2_PROPERTY", ")", ".", "insertFirst", "(", "marker", ",", "null", ")", ";", "stub", ".", "setName", "(", "ast", ".", "newSimpleName", "(", "name", ")", ")", ";", "Block", "body", "=", "ast", ".", "newBlock", "(", ")", ";", "stub", ".", "setBody", "(", "body", ")", ";", "String", "todoTask", "=", "\"\"", ";", "String", "todoTaskTag", "=", "JUnitStubUtility", ".", "getTodoTaskTag", "(", "javaProject", ")", ";", "if", "(", "todoTaskTag", "!=", "null", ")", "{", "todoTask", "=", "\"", "//", "\"", "+", "todoTaskTag", ";", "}", "String", "message", "=", "WizardMessages", ".", "NewTestCaseWizardPageOne_not_yet_implemented_string", ";", "body", ".", "statements", "(", ")", ".", "add", "(", "astRewrite", ".", "createStringPlaceholder", "(", "todoTask", ",", "ASTNode", ".", "RETURN_STATEMENT", ")", ")", ";", "body", ".", "statements", "(", ")", ".", "add", "(", "astRewrite", ".", "createStringPlaceholder", "(", "Messages", ".", "format", "(", "\"fail(\\\"{0}\\\");\"", ",", "message", ")", ",", "ASTNode", ".", "RETURN_STATEMENT", ")", ")", ";", "memberRewriter", ".", "insertLast", "(", "stub", ",", "null", ")", ";", "}", "edit", ".", "addChild", "(", "astRewrite", ".", "rewriteAST", "(", ")", ")", ";", "JavaModelUtil", ".", "applyEdit", "(", "src", ",", "edit", ",", "true", ",", "null", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "}", "}", "}", "</s>" ]
1,224
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "junit", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "regex", ".", "Matcher", ";", "import", "java", ".", "util", ".", "regex", ".", "Pattern", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang", ".", "StringUtils", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "util", ".", "TypeUtils", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "ICompilationUnit", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IJavaProject", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IMethod", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IType", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "Signature", ";", "public", "class", "JUnitUtils", "{", "private", "static", "final", "Pattern", "TESTING_CLASS_NAME", "=", "Pattern", ".", "compile", "(", "\"\"", ")", ";", "public", "static", "ICompilationUnit", "findTest", "(", "IJavaProject", "javaProject", ",", "IType", "type", ")", "throws", "Exception", "{", "String", "[", "]", "names", "=", "new", "String", "[", "]", "{", "type", ".", "getFullyQualifiedName", "(", ")", "+", "\"Test\"", ",", "type", ".", "getPackageFragment", "(", ")", ".", "getElementName", "(", ")", "+", "\".Test\"", "+", "type", ".", "getElementName", "(", ")", ",", "}", ";", "for", "(", "String", "name", ":", "names", ")", "{", "IType", "[", "]", "results", "=", "TypeUtils", ".", "findTypes", "(", "javaProject", ",", "name", ")", ";", "for", "(", "IType", "result", ":", "results", ")", "{", "if", "(", "result", ".", "getCompilationUnit", "(", ")", "!=", "null", ")", "{", "return", "result", ".", "getCompilationUnit", "(", ")", ";", "}", "}", "}", "return", "null", ";", "}", "public", "static", "ICompilationUnit", "findClass", "(", "IJavaProject", "javaProject", ",", "IType", "type", ")", "throws", "Exception", "{", "String", "name", "=", "type", ".", "getElementName", "(", ")", ";", "Matcher", "matcher", "=", "TESTING_CLASS_NAME", ".", "matcher", "(", "name", ")", ";", "IType", "found", "=", "null", ";", "if", "(", "matcher", ".", "matches", "(", ")", ")", "{", "name", "=", "matcher", ".", "group", "(", "2", ")", ";", "String", "fqn", "=", "type", ".", "getPackageFragment", "(", ")", ".", "getElementName", "(", ")", "+", "'.'", "+", "name", ";", "found", "=", "javaProject", ".", "findType", "(", "fqn", ")", ";", "}", "if", "(", "found", "==", "null", ")", "{", "IType", "[", "]", "types", "=", "findTypes", "(", "javaProject", ",", "type", ",", "name", ")", ";", "if", "(", "types", ".", "length", "==", "1", ")", "{", "found", "=", "types", "[", "0", "]", ";", "}", "}", "return", "found", ".", "getCompilationUnit", "(", ")", ";", "}", "private", "static", "IType", "[", "]", "findTypes", "(", "IJavaProject", "javaProject", ",", "IType", "ignore", ",", "String", "name", ")", "throws", "Exception", "{", "ArrayList", "<", "IType", ">", "types", "=", "new", "ArrayList", "<", "IType", ">", "(", ")", ";", "for", "(", "IType", "type", ":", "TypeUtils", ".", "findTypes", "(", "javaProject", ",", "name", ")", ")", "{", "if", "(", "!", "type", ".", "equals", "(", "ignore", ")", "&&", "type", ".", "getCompilationUnit", "(", ")", "!=", "null", ")", "{", "types", ".", "add", "(", "type", ")", ";", "}", "}", "return", "types", ".", "toArray", "(", "new", "IType", "[", "types", ".", "size", "(", ")", "]", ")", ";", "}", "public", "static", "IMethod", "findTestMethod", "(", "ICompilationUnit", "testSrc", ",", "IMethod", "method", ")", "throws", "Exception", "{", "String", "testName", "=", "\"test\"", "+", "StringUtils", ".", "capitalize", "(", "method", ".", "getElementName", "(", ")", ")", ";", "StringBuffer", "testNameWithParams", "=", "new", "StringBuffer", "(", "testName", ")", ";", "appendParameterNamesToMethodName", "(", "testNameWithParams", ",", "method", ".", "getParameterTypes", "(", ")", ")", ";", "replaceIllegalCharacters", "(", "testNameWithParams", ")", ";", "StringBuffer", "nameWithParams", "=", "new", "StringBuffer", "(", "method", ".", "getElementName", "(", ")", ")", ";", "appendParameterNamesToMethodName", "(", "nameWithParams", ",", "method", ".", "getParameterTypes", "(", ")", ")", ";", "replaceIllegalCharacters", "(", "nameWithParams", ")", ";", "String", "[", "]", "methodNames", "=", "new", "String", "[", "]", "{", "testNameWithParams", ".", "toString", "(", ")", ",", "nameWithParams", ".", "toString", "(", ")", ",", "testName", ",", "method", ".", "getElementName", "(", ")", ",", "}", ";", "for", "(", "String", "name", ":", "methodNames", ")", "{", "IMethod", "test", "=", "testSrc", ".", "getTypes", "(", ")", "[", "0", "]", ".", "getMethod", "(", "name", ",", "null", ")", ";", "if", "(", "test", "!=", "null", "&&", "test", ".", "exists", "(", ")", ")", "{", "return", "test", ";", "}", "}", "return", "null", ";", "}", "public", "static", "IMethod", "findClassMethod", "(", "ICompilationUnit", "src", ",", "IMethod", "testMethod", ")", "throws", "Exception", "{", "ICompilationUnit", "testSrc", "=", "testMethod", ".", "getCompilationUnit", "(", ")", ";", "if", "(", "testSrc", "==", "null", ")", "{", "return", "null", ";", "}", "IType", "testType", "=", "testSrc", ".", "getTypes", "(", ")", "[", "0", "]", ";", "IMethod", "[", "]", "methods", "=", "src", ".", "getTypes", "(", ")", "[", "0", "]", ".", "getMethods", "(", ")", ";", "for", "(", "IMethod", "method", ":", "methods", ")", "{", "String", "testName", "=", "\"test\"", "+", "StringUtils", ".", "capitalize", "(", "method", ".", "getElementName", "(", ")", ")", ";", "StringBuffer", "testNameWithParams", "=", "new", "StringBuffer", "(", "testName", ")", ";", "appendParameterNamesToMethodName", "(", "testNameWithParams", ",", "method", ".", "getParameterTypes", "(", ")", ")", ";", "replaceIllegalCharacters", "(", "testNameWithParams", ")", ";", "StringBuffer", "nameWithParams", "=", "new", "StringBuffer", "(", "method", ".", "getElementName", "(", ")", ")", ";", "appendParameterNamesToMethodName", "(", "nameWithParams", ",", "method", ".", "getParameterTypes", "(", ")", ")", ";", "replaceIllegalCharacters", "(", "nameWithParams", ")", ";", "String", "[", "]", "methodNames", "=", "new", "String", "[", "]", "{", "testNameWithParams", ".", "toString", "(", ")", ",", "nameWithParams", ".", "toString", "(", ")", ",", "}", ";", "for", "(", "String", "name", ":", "methodNames", ")", "{", "if", "(", "testMethod", ".", "equals", "(", "testType", ".", "getMethod", "(", "name", ",", "null", ")", ")", ")", "{", "return", "method", ";", "}", "}", "}", "for", "(", "IMethod", "method", ":", "methods", ")", "{", "String", "testName", "=", "\"test\"", "+", "StringUtils", ".", "capitalize", "(", "method", ".", "getElementName", "(", ")", ")", ";", "String", "[", "]", "methodNames", "=", "new", "String", "[", "]", "{", "testName", ",", "method", ".", "getElementName", "(", ")", ",", "}", ";", "for", "(", "String", "name", ":", "methodNames", ")", "{", "if", "(", "testMethod", ".", "equals", "(", "testType", ".", "getMethod", "(", "name", ",", "null", ")", ")", ")", "{", "return", "method", ";", "}", "}", "}", "return", "null", ";", "}", "private", "final", "static", "String", "QUESTION_MARK_TAG", "=", "\"Q\"", ";", "private", "final", "static", "String", "OF_TAG", "=", "\"Of\"", ";", "private", "static", "void", "appendParameterNamesToMethodName", "(", "StringBuffer", "buffer", ",", "String", "[", "]", "parameters", ")", "{", "for", "(", "String", "parameter", ":", "parameters", ")", "{", "final", "StringBuffer", "buf", "=", "new", "StringBuffer", "(", "Signature", ".", "getSimpleName", "(", "Signature", ".", "toString", "(", "Signature", ".", "getElementType", "(", "parameter", ")", ")", ")", ")", ";", "final", "char", "character", "=", "buf", ".", "charAt", "(", "0", ")", ";", "if", "(", "buf", ".", "length", "(", ")", ">", "0", "&&", "!", "Character", ".", "isUpperCase", "(", "character", ")", ")", "buf", ".", "setCharAt", "(", "0", ",", "Character", ".", "toUpperCase", "(", "character", ")", ")", ";", "buffer", ".", "append", "(", "buf", ".", "toString", "(", ")", ")", ";", "for", "(", "int", "j", "=", "0", ",", "arrayCount", "=", "Signature", ".", "getArrayCount", "(", "parameter", ")", ";", "j", "<", "arrayCount", ";", "j", "++", ")", "{", "buffer", ".", "append", "(", "\"Array\"", ")", ";", "}", "}", "}", "private", "static", "void", "replaceIllegalCharacters", "(", "StringBuffer", "buffer", ")", "{", "char", "character", "=", "0", ";", "for", "(", "int", "index", "=", "buffer", ".", "length", "(", ")", "-", "1", ";", "index", ">=", "0", ";", "index", "--", ")", "{", "character", "=", "buffer", ".", "charAt", "(", "index", ")", ";", "if", "(", "Character", ".", "isWhitespace", "(", "character", ")", ")", "{", "buffer", ".", "deleteCharAt", "(", "index", ")", ";", "}", "else", "if", "(", "character", "==", "'<'", ")", "{", "buffer", ".", "replace", "(", "index", ",", "index", "+", "1", ",", "OF_TAG", ")", ";", "}", "else", "if", "(", "character", "==", "'?'", ")", "{", "buffer", ".", "replace", "(", "index", ",", "index", "+", "1", ",", "QUESTION_MARK_TAG", ")", ";", "}", "}", "}", "}", "</s>" ]
1,225
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "junit", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "lang", ".", "reflect", ".", "Field", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Collections", ";", "import", "org", ".", "apache", ".", "tools", ".", "ant", ".", "BuildException", ";", "import", "org", ".", "apache", ".", "tools", ".", "ant", ".", "BuildLogger", ";", "import", "org", ".", "apache", ".", "tools", ".", "ant", ".", "DefaultLogger", ";", "import", "org", ".", "apache", ".", "tools", ".", "ant", ".", "Project", ";", "import", "org", ".", "apache", ".", "tools", ".", "ant", ".", "taskdefs", ".", "optional", ".", "junit", ".", "BatchTest", ";", "import", "org", ".", "apache", ".", "tools", ".", "ant", ".", "taskdefs", ".", "optional", ".", "junit", ".", "FormatterElement", ";", "import", "org", ".", "apache", ".", "tools", ".", "ant", ".", "taskdefs", ".", "optional", ".", "junit", ".", "JUnitTask", ";", "import", "org", ".", "apache", ".", "tools", ".", "ant", ".", "taskdefs", ".", "optional", ".", "junit", ".", "JUnitTest", ";", "import", "org", ".", "apache", ".", "tools", ".", "ant", ".", "types", ".", "FileSet", ";", "import", "org", ".", "apache", ".", "tools", ".", "ant", ".", "types", ".", "Path", ";", "import", "org", ".", "eclim", ".", "Services", ";", "import", "org", ".", "eclim", ".", "annotation", ".", "Command", ";", "import", "org", ".", "eclim", ".", "command", ".", "CommandLine", ";", "import", "org", ".", "eclim", ".", "command", ".", "Options", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "command", ".", "AbstractCommand", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "util", ".", "ProjectUtils", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "util", ".", "ClasspathUtils", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "util", ".", "JavaUtils", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "IProject", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "IncrementalProjectBuilder", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "FileLocator", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "Platform", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IAnnotation", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IClasspathEntry", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "ICompilationUnit", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IJavaElement", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IJavaProject", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IMethod", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IType", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "junit", ".", "launcher", ".", "JUnit4TestFinder", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "junit", ".", "JUnitCore", ";", "import", "org", ".", "osgi", ".", "framework", ".", "Bundle", ";", "@", "Command", "(", "name", "=", "\"java_junit\"", ",", "options", "=", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", ")", "public", "class", "JUnitCommand", "extends", "AbstractCommand", "{", "@", "Override", "public", "Object", "execute", "(", "CommandLine", "commandLine", ")", "throws", "Exception", "{", "String", "projectName", "=", "commandLine", ".", "getValue", "(", "Options", ".", "PROJECT_OPTION", ")", ";", "String", "testName", "=", "commandLine", ".", "getValue", "(", "Options", ".", "TEST_OPTION", ")", ";", "String", "file", "=", "commandLine", ".", "getValue", "(", "Options", ".", "FILE_OPTION", ")", ";", "int", "offset", "=", "getOffset", "(", "commandLine", ")", ";", "boolean", "debug", "=", "commandLine", ".", "hasOption", "(", "Options", ".", "DEBUG_OPTION", ")", ";", "boolean", "halt", "=", "commandLine", ".", "hasOption", "(", "Options", ".", "HALT_OPTION", ")", ";", "IProject", "project", "=", "ProjectUtils", ".", "getProject", "(", "projectName", ")", ";", "project", ".", "build", "(", "IncrementalProjectBuilder", ".", "INCREMENTAL_BUILD", ",", "null", ")", ";", "IJavaProject", "javaProject", "=", "JavaUtils", ".", "getJavaProject", "(", "project", ")", ";", "JUnitTask", "junit", "=", "createJUnitTask", "(", "javaProject", ",", "debug", ",", "halt", ")", ";", "if", "(", "file", "!=", "null", ")", "{", "ICompilationUnit", "src", "=", "JavaUtils", ".", "getCompilationUnit", "(", "javaProject", ",", "file", ")", ";", "IMethod", "method", "=", "null", ";", "if", "(", "offset", "!=", "-", "1", ")", "{", "IJavaElement", "element", "=", "src", ".", "getElementAt", "(", "offset", ")", ";", "if", "(", "element", "!=", "null", "&&", "element", ".", "getElementType", "(", ")", "==", "IJavaElement", ".", "METHOD", ")", "{", "method", "=", "(", "IMethod", ")", "element", ";", "}", "}", "JUnit4TestFinder", "finder", "=", "new", "JUnit4TestFinder", "(", ")", ";", "IType", "type", "=", "src", ".", "getTypes", "(", ")", "[", "0", "]", ";", "if", "(", "!", "finder", ".", "isTest", "(", "type", ")", ")", "{", "src", "=", "JUnitUtils", ".", "findTest", "(", "javaProject", ",", "type", ")", ";", "if", "(", "src", "==", "null", ")", "{", "println", "(", "Services", ".", "getMessage", "(", "\"\"", ")", ")", ";", "return", "null", ";", "}", "if", "(", "method", "!=", "null", ")", "{", "method", "=", "JUnitUtils", ".", "findTestMethod", "(", "src", ",", "method", ")", ";", "if", "(", "method", "==", "null", ")", "{", "println", "(", "Services", ".", "getMessage", "(", "\"\"", ")", ")", ";", "return", "null", ";", "}", "}", "}", "JUnitTest", "test", "=", "new", "JUnitTest", "(", ")", ";", "test", ".", "setName", "(", "JavaUtils", ".", "getFullyQualifiedName", "(", "src", ")", ")", ";", "if", "(", "method", "!=", "null", ")", "{", "IAnnotation", "testAnnotation", "=", "method", ".", "getAnnotation", "(", "\"Test\"", ")", ";", "if", "(", "testAnnotation", "==", "null", "||", "!", "testAnnotation", ".", "exists", "(", ")", ")", "{", "println", "(", "Services", ".", "getMessage", "(", "\"\"", ",", "method", ".", "getElementName", "(", ")", ")", ")", ";", "return", "null", ";", "}", "test", ".", "setMethods", "(", "method", ".", "getElementName", "(", ")", ")", ";", "}", "junit", ".", "addTest", "(", "test", ")", ";", "}", "else", "if", "(", "testName", "!=", "null", ")", "{", "if", "(", "testName", ".", "indexOf", "(", "'*'", ")", "!=", "-", "1", ")", "{", "createBatchTest", "(", "javaProject", ",", "junit", ",", "testName", ")", ";", "}", "else", "{", "JUnitTest", "test", "=", "new", "JUnitTest", "(", ")", ";", "test", ".", "setName", "(", "testName", ")", ";", "junit", ".", "addTest", "(", "test", ")", ";", "}", "}", "else", "{", "ArrayList", "<", "String", ">", "names", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "IType", "[", "]", "types", "=", "JUnitCore", ".", "findTestTypes", "(", "javaProject", ",", "null", ")", ";", "for", "(", "IType", "type", ":", "types", ")", "{", "names", ".", "add", "(", "type", ".", "getFullyQualifiedName", "(", ")", ")", ";", "}", "Collections", ".", "sort", "(", "names", ")", ";", "for", "(", "String", "name", ":", "names", ")", "{", "JUnitTest", "test", "=", "new", "JUnitTest", "(", ")", ";", "test", ".", "setName", "(", "name", ")", ";", "junit", ".", "addTest", "(", "test", ")", ";", "}", "}", "try", "{", "junit", ".", "init", "(", ")", ";", "junit", ".", "execute", "(", ")", ";", "}", "catch", "(", "BuildException", "be", ")", "{", "if", "(", "debug", ")", "{", "be", ".", "printStackTrace", "(", "getContext", "(", ")", ".", "err", ")", ";", "}", "}", "return", "null", ";", "}", "private", "JUnitTask", "createJUnitTask", "(", "IJavaProject", "javaProject", ",", "boolean", "debug", ",", "boolean", "halt", ")", "throws", "Exception", "{", "Project", "antProject", "=", "new", "Project", "(", ")", ";", "BuildLogger", "buildLogger", "=", "new", "DefaultLogger", "(", ")", ";", "buildLogger", ".", "setEmacsMode", "(", "true", ")", ";", "buildLogger", ".", "setMessageOutputLevel", "(", "debug", "?", "Project", ".", "MSG_DEBUG", ":", "Project", ".", "MSG_INFO", ")", ";", "buildLogger", ".", "setOutputPrintStream", "(", "getContext", "(", ")", ".", "out", ")", ";", "buildLogger", ".", "setErrorPrintStream", "(", "getContext", "(", ")", ".", "err", ")", ";", "antProject", ".", "addBuildListener", "(", "buildLogger", ")", ";", "antProject", ".", "setBasedir", "(", "ProjectUtils", ".", "getPath", "(", "javaProject", ".", "getProject", "(", ")", ")", ")", ";", "Path", "classpath", "=", "new", "Path", "(", "antProject", ")", ";", "String", "[", "]", "paths", "=", "ClasspathUtils", ".", "getClasspath", "(", "javaProject", ")", ";", "for", "(", "String", "path", ":", "paths", ")", "{", "Path", ".", "PathElement", "pe", "=", "classpath", ".", "createPathElement", "(", ")", ";", "pe", ".", "setPath", "(", "path", ")", ";", "}", "Bundle", "bundle", "=", "Platform", ".", "getBundle", "(", "\"\"", ")", ";", "String", "pathName", "=", "FileLocator", ".", "getBundleFile", "(", "bundle", ")", ".", "getPath", "(", ")", ";", "classpath", ".", "createPathElement", "(", ")", ".", "setPath", "(", "pathName", "+", "\"/lib/ant.jar\"", ")", ";", "classpath", ".", "createPathElement", "(", ")", ".", "setPath", "(", "pathName", "+", "\"\"", ")", ";", "classpath", ".", "createPathElement", "(", ")", ".", "setPath", "(", "pathName", "+", "\"\"", ")", ";", "bundle", "=", "Platform", ".", "getBundle", "(", "\"\"", ")", ";", "pathName", "=", "FileLocator", ".", "getBundleFile", "(", "bundle", ")", ".", "getPath", "(", ")", ";", "classpath", ".", "createPathElement", "(", ")", ".", "setPath", "(", "pathName", "+", "\"\"", ")", ";", "JUnitTask", "junit", "=", "new", "JUnitTask", "(", ")", ";", "junit", ".", "setProject", "(", "antProject", ")", ";", "junit", ".", "setTaskName", "(", "\"junit\"", ")", ";", "junit", ".", "setFork", "(", "true", ")", ";", "junit", ".", "setHaltonerror", "(", "halt", ")", ";", "junit", ".", "setHaltonfailure", "(", "halt", ")", ";", "junit", ".", "createClasspath", "(", ")", ".", "append", "(", "classpath", ")", ";", "Field", "forkedPathChecked", "=", "JUnitTask", ".", "class", ".", "getDeclaredField", "(", "\"\"", ")", ";", "forkedPathChecked", ".", "setAccessible", "(", "true", ")", ";", "forkedPathChecked", ".", "set", "(", "junit", ",", "true", ")", ";", "FormatterElement", "formatter", "=", "new", "FormatterElement", "(", ")", ";", "junit", ".", "addFormatter", "(", "formatter", ")", ";", "formatter", ".", "setClassname", "(", "\"\"", ")", ";", "formatter", ".", "setUseFile", "(", "false", ")", ";", "return", "junit", ";", "}", "private", "void", "createBatchTest", "(", "IJavaProject", "javaProject", ",", "JUnitTask", "junit", ",", "String", "pattern", ")", "throws", "Exception", "{", "if", "(", "!", "pattern", ".", "endsWith", "(", "\".java\"", ")", ")", "{", "pattern", "+=", "\".java\"", ";", "}", "BatchTest", "batch", "=", "junit", ".", "createBatchTest", "(", ")", ";", "IClasspathEntry", "[", "]", "entries", "=", "javaProject", ".", "getResolvedClasspath", "(", "true", ")", ";", "for", "(", "IClasspathEntry", "entry", ":", "entries", ")", "{", "if", "(", "entry", ".", "getEntryKind", "(", ")", "==", "IClasspathEntry", ".", "CPE_SOURCE", ")", "{", "String", "path", "=", "ProjectUtils", ".", "getFilePath", "(", "javaProject", ".", "getProject", "(", ")", ",", "entry", ".", "getPath", "(", ")", ".", "toOSString", "(", ")", ")", ";", "FileSet", "fileset", "=", "new", "FileSet", "(", ")", ";", "fileset", ".", "setDir", "(", "new", "File", "(", "path", ")", ")", ";", "fileset", ".", "setIncludes", "(", "pattern", ")", ";", "batch", ".", "addFileSet", "(", "fileset", ")", ";", "}", "}", "}", "}", "</s>" ]
1,226
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "junit", ";", "import", "org", ".", "eclim", ".", "Services", ";", "import", "org", ".", "eclim", ".", "annotation", ".", "Command", ";", "import", "org", ".", "eclim", ".", "command", ".", "CommandLine", ";", "import", "org", ".", "eclim", ".", "command", ".", "Options", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "command", ".", "AbstractCommand", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "util", ".", "ProjectUtils", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "util", ".", "JavaUtils", ";", "import", "org", ".", "eclim", ".", "util", ".", "file", ".", "Position", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "IProject", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "ICompilationUnit", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IJavaElement", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IJavaProject", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IMethod", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "ISourceRange", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "ISourceReference", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IType", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "junit", ".", "launcher", ".", "JUnit4TestFinder", ";", "@", "Command", "(", "name", "=", "\"\"", ",", "options", "=", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", ")", "public", "class", "JUnitFindTestCommand", "extends", "AbstractCommand", "{", "@", "Override", "public", "Object", "execute", "(", "CommandLine", "commandLine", ")", "throws", "Exception", "{", "String", "projectName", "=", "commandLine", ".", "getValue", "(", "Options", ".", "PROJECT_OPTION", ")", ";", "String", "file", "=", "commandLine", ".", "getValue", "(", "Options", ".", "FILE_OPTION", ")", ";", "int", "offset", "=", "getOffset", "(", "commandLine", ")", ";", "IProject", "project", "=", "ProjectUtils", ".", "getProject", "(", "projectName", ")", ";", "IJavaProject", "javaProject", "=", "JavaUtils", ".", "getJavaProject", "(", "project", ")", ";", "JUnit4TestFinder", "finder", "=", "new", "JUnit4TestFinder", "(", ")", ";", "ICompilationUnit", "src", "=", "JavaUtils", ".", "getCompilationUnit", "(", "javaProject", ",", "file", ")", ";", "ICompilationUnit", "result", "=", "null", ";", "if", "(", "finder", ".", "isTest", "(", "src", ".", "getTypes", "(", ")", "[", "0", "]", ")", ")", "{", "result", "=", "JUnitUtils", ".", "findClass", "(", "javaProject", ",", "src", ".", "getTypes", "(", ")", "[", "0", "]", ")", ";", "if", "(", "result", "==", "null", ")", "{", "return", "Services", ".", "getMessage", "(", "\"\"", ")", ";", "}", "}", "else", "{", "result", "=", "JUnitUtils", ".", "findTest", "(", "javaProject", ",", "src", ".", "getTypes", "(", ")", "[", "0", "]", ")", ";", "if", "(", "result", "==", "null", ")", "{", "return", "Services", ".", "getMessage", "(", "\"\"", ")", ";", "}", "}", "IType", "resultType", "=", "result", ".", "getTypes", "(", ")", "[", "0", "]", ";", "String", "name", "=", "resultType", ".", "getElementName", "(", ")", ";", "ISourceReference", "ref", "=", "resultType", ";", "ISourceRange", "docRange", "=", "resultType", ".", "getJavadocRange", "(", ")", ";", "IJavaElement", "element", "=", "src", ".", "getElementAt", "(", "offset", ")", ";", "if", "(", "element", "!=", "null", "&&", "element", ".", "getElementType", "(", ")", "==", "IJavaElement", ".", "METHOD", ")", "{", "IMethod", "method", "=", "null", ";", "if", "(", "finder", ".", "isTest", "(", "src", ".", "getTypes", "(", ")", "[", "0", "]", ")", ")", "{", "method", "=", "JUnitUtils", ".", "findClassMethod", "(", "result", ",", "(", "IMethod", ")", "element", ")", ";", "}", "else", "{", "method", "=", "JUnitUtils", ".", "findTestMethod", "(", "result", ",", "(", "IMethod", ")", "element", ")", ";", "}", "if", "(", "method", "!=", "null", ")", "{", "name", "=", "method", ".", "getElementName", "(", ")", ";", "ref", "=", "method", ";", "docRange", "=", "method", ".", "getJavadocRange", "(", ")", ";", "}", "}", "String", "lineDelim", "=", "result", ".", "findRecommendedLineSeparator", "(", ")", ";", "int", "docLength", "=", "docRange", "!=", "null", "?", "docRange", ".", "getLength", "(", ")", "+", "lineDelim", ".", "length", "(", ")", ":", "0", ";", "return", "Position", ".", "fromOffset", "(", "result", ".", "getResource", "(", ")", ".", "getLocation", "(", ")", ".", "toOSString", "(", ")", ",", "name", ",", "ref", ".", "getSourceRange", "(", ")", ".", "getOffset", "(", ")", "+", "docLength", ",", "0", ")", ";", "}", "}", "</s>" ]
1,227
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "junit", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "io", ".", "OutputStream", ";", "import", "org", ".", "apache", ".", "tools", ".", "ant", ".", "BuildException", ";", "import", "org", ".", "apache", ".", "tools", ".", "ant", ".", "taskdefs", ".", "optional", ".", "junit", ".", "JUnitTest", ";", "import", "org", ".", "apache", ".", "tools", ".", "ant", ".", "taskdefs", ".", "optional", ".", "junit", ".", "PlainJUnitResultFormatter", ";", "import", "org", ".", "apache", ".", "tools", ".", "ant", ".", "util", ".", "StringUtils", ";", "public", "class", "ResultFormatter", "extends", "PlainJUnitResultFormatter", "{", "private", "OutputStream", "out", ";", "@", "Override", "public", "void", "setOutput", "(", "OutputStream", "out", ")", "{", "super", ".", "setOutput", "(", "out", ")", ";", "this", ".", "out", "=", "out", ";", "}", "@", "Override", "public", "void", "startTestSuite", "(", "JUnitTest", "suite", ")", "throws", "BuildException", "{", "if", "(", "out", "==", "null", ")", "{", "return", ";", "}", "String", "name", "=", "suite", ".", "getName", "(", ")", ";", "StringBuffer", "nameDelim", "=", "new", "StringBuffer", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "name", ".", "length", "(", ")", ";", "i", "++", ")", "{", "nameDelim", ".", "append", "(", "'-'", ")", ";", "}", "StringBuffer", "sb", "=", "new", "StringBuffer", "(", ")", ";", "sb", ".", "append", "(", "StringUtils", ".", "LINE_SEP", ")", ";", "sb", ".", "append", "(", "\"-----------\"", ")", ".", "append", "(", "nameDelim", ")", ".", "append", "(", "StringUtils", ".", "LINE_SEP", ")", ";", "sb", ".", "append", "(", "\"Testsuite:", "\"", ")", ";", "sb", ".", "append", "(", "name", ")", ";", "sb", ".", "append", "(", "StringUtils", ".", "LINE_SEP", ")", ";", "sb", ".", "append", "(", "\"-----------\"", ")", ".", "append", "(", "nameDelim", ")", ".", "append", "(", "StringUtils", ".", "LINE_SEP", ")", ";", "try", "{", "out", ".", "write", "(", "sb", ".", "toString", "(", ")", ".", "getBytes", "(", ")", ")", ";", "out", ".", "flush", "(", ")", ";", "}", "catch", "(", "IOException", "ex", ")", "{", "throw", "new", "BuildException", "(", "\"\"", ",", "ex", ")", ";", "}", "}", "}", "</s>" ]
1,228
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "src", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "io", ".", "FileInputStream", ";", "import", "java", ".", "net", ".", "URL", ";", "import", "java", ".", "net", ".", "URLClassLoader", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "HashSet", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Properties", ";", "import", "java", ".", "util", ".", "Set", ";", "import", "org", ".", "eclim", ".", "Services", ";", "import", "org", ".", "eclim", ".", "annotation", ".", "Command", ";", "import", "org", ".", "eclim", ".", "command", ".", "CommandLine", ";", "import", "org", ".", "eclim", ".", "command", ".", "Error", ";", "import", "org", ".", "eclim", ".", "command", ".", "Options", ";", "import", "org", ".", "eclim", ".", "logging", ".", "Logger", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "command", ".", "AbstractCommand", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "preference", ".", "Preferences", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "util", ".", "ProjectUtils", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "util", ".", "JavaUtils", ";", "import", "org", ".", "eclim", ".", "util", ".", "IOUtils", ";", "import", "org", ".", "eclim", ".", "util", ".", "StringUtils", ";", "import", "org", ".", "eclim", ".", "util", ".", "file", ".", "FileUtils", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "IProject", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "IPath", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IClasspathEntry", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IJavaProject", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "JavaModelException", ";", "import", "com", ".", "puppycrawl", ".", "tools", ".", "checkstyle", ".", "Checker", ";", "import", "com", ".", "puppycrawl", ".", "tools", ".", "checkstyle", ".", "ConfigurationLoader", ";", "import", "com", ".", "puppycrawl", ".", "tools", ".", "checkstyle", ".", "PropertiesExpander", ";", "import", "com", ".", "puppycrawl", ".", "tools", ".", "checkstyle", ".", "api", ".", "AuditEvent", ";", "import", "com", ".", "puppycrawl", ".", "tools", ".", "checkstyle", ".", "api", ".", "AuditListener", ";", "import", "com", ".", "puppycrawl", ".", "tools", ".", "checkstyle", ".", "api", ".", "Configuration", ";", "import", "com", ".", "puppycrawl", ".", "tools", ".", "checkstyle", ".", "api", ".", "SeverityLevel", ";", "@", "Command", "(", "name", "=", "\"\"", ",", "options", "=", "\"\"", "+", "\"\"", ")", "public", "class", "CheckstyleCommand", "extends", "AbstractCommand", "{", "private", "static", "final", "Logger", "logger", "=", "Logger", ".", "getLogger", "(", "CheckstyleCommand", ".", "class", ")", ";", "@", "Override", "public", "Object", "execute", "(", "CommandLine", "commandLine", ")", "throws", "Exception", "{", "String", "name", "=", "commandLine", ".", "getValue", "(", "Options", ".", "PROJECT_OPTION", ")", ";", "String", "file", "=", "commandLine", ".", "getValue", "(", "Options", ".", "FILE_OPTION", ")", ";", "IProject", "project", "=", "ProjectUtils", ".", "getProject", "(", "name", ",", "true", ")", ";", "Preferences", "prefs", "=", "getPreferences", "(", ")", ";", "String", "configFile", "=", "prefs", ".", "getValue", "(", "project", ",", "\"\"", ")", ";", "String", "propsFile", "=", "prefs", ".", "getValue", "(", "project", ",", "\"\"", ")", ";", "Properties", "properties", "=", "System", ".", "getProperties", "(", ")", ";", "if", "(", "propsFile", "!=", "null", "&&", "!", "propsFile", ".", "equals", "(", "StringUtils", ".", "EMPTY", ")", ")", "{", "FileInputStream", "fis", "=", "null", ";", "try", "{", "File", "pfile", "=", "new", "File", "(", "propsFile", ")", ";", "if", "(", "!", "pfile", ".", "exists", "(", ")", ")", "{", "pfile", "=", "new", "File", "(", "ProjectUtils", ".", "getFilePath", "(", "project", ",", "propsFile", ")", ")", ";", "if", "(", "!", "pfile", ".", "exists", "(", ")", ")", "{", "throw", "new", "RuntimeException", "(", "Services", ".", "getMessage", "(", "\"\"", ",", "configFile", ")", ")", ";", "}", "}", "fis", "=", "new", "FileInputStream", "(", "pfile", ")", ";", "properties", "=", "new", "Properties", "(", ")", ";", "properties", ".", "load", "(", "fis", ")", ";", "}", "finally", "{", "IOUtils", ".", "closeQuietly", "(", "fis", ")", ";", "}", "}", "if", "(", "!", "new", "File", "(", "configFile", ")", ".", "exists", "(", ")", ")", "{", "String", "projectConfigFile", "=", "ProjectUtils", ".", "getFilePath", "(", "project", ",", "configFile", ")", ";", "if", "(", "!", "new", "File", "(", "projectConfigFile", ")", ".", "exists", "(", ")", ")", "{", "throw", "new", "RuntimeException", "(", "Services", ".", "getMessage", "(", "\"\"", ",", "configFile", ")", ")", ";", "}", "configFile", "=", "projectConfigFile", ";", "}", "Configuration", "config", "=", "ConfigurationLoader", ".", "loadConfiguration", "(", "configFile", ",", "new", "PropertiesExpander", "(", "properties", ")", ")", ";", "CheckstyleListener", "listener", "=", "new", "CheckstyleListener", "(", ")", ";", "List", "<", "File", ">", "files", "=", "new", "ArrayList", "<", "File", ">", "(", ")", ";", "files", ".", "add", "(", "new", "File", "(", "ProjectUtils", ".", "getFilePath", "(", "project", ",", "file", ")", ")", ")", ";", "Checker", "checker", "=", "new", "Checker", "(", ")", ";", "checker", ".", "setModuleClassLoader", "(", "new", "ProjectClassLoader", "(", "JavaUtils", ".", "getJavaProject", "(", "project", ")", ",", "Checker", ".", "class", ".", "getClassLoader", "(", ")", ")", ")", ";", "checker", ".", "setClassloader", "(", "new", "ProjectClassLoader", "(", "JavaUtils", ".", "getJavaProject", "(", "project", ")", ")", ")", ";", "checker", ".", "configure", "(", "config", ")", ";", "checker", ".", "addListener", "(", "listener", ")", ";", "checker", ".", "process", "(", "files", ")", ";", "return", "listener", ".", "getErrors", "(", ")", ";", "}", "private", "static", "class", "CheckstyleListener", "implements", "AuditListener", "{", "private", "static", "final", "String", "CHECKSTYLE_PREFIX", "=", "\"\"", ";", "private", "ArrayList", "<", "Error", ">", "errors", ";", "public", "CheckstyleListener", "(", ")", "{", "errors", "=", "new", "ArrayList", "<", "Error", ">", "(", ")", ";", "}", "@", "Override", "public", "void", "auditStarted", "(", "AuditEvent", "event", ")", "{", "}", "@", "Override", "public", "void", "auditFinished", "(", "AuditEvent", "event", ")", "{", "}", "@", "Override", "public", "void", "fileStarted", "(", "AuditEvent", "event", ")", "{", "}", "@", "Override", "public", "void", "fileFinished", "(", "AuditEvent", "event", ")", "{", "}", "@", "Override", "public", "void", "addError", "(", "AuditEvent", "event", ")", "{", "errors", ".", "add", "(", "new", "Error", "(", "CHECKSTYLE_PREFIX", "+", "event", ".", "getMessage", "(", ")", ",", "event", ".", "getFileName", "(", ")", ".", "replace", "(", "'\\\\'", ",", "'/'", ")", ",", "event", ".", "getLine", "(", ")", ",", "event", ".", "getColumn", "(", ")", ",", "event", ".", "getSeverityLevel", "(", ")", "!=", "SeverityLevel", ".", "ERROR", ")", ")", ";", "}", "@", "Override", "public", "void", "addException", "(", "AuditEvent", "event", ",", "Throwable", "throwable", ")", "{", "throw", "new", "RuntimeException", "(", "throwable", ")", ";", "}", "public", "ArrayList", "<", "Error", ">", "getErrors", "(", ")", "{", "return", "this", ".", "errors", ";", "}", "}", "private", "static", "class", "ProjectClassLoader", "extends", "URLClassLoader", "{", "public", "ProjectClassLoader", "(", "IJavaProject", "project", ")", "throws", "Exception", "{", "super", "(", "ProjectClassLoader", ".", "classpath", "(", "project", ")", ")", ";", "}", "public", "ProjectClassLoader", "(", "IJavaProject", "project", ",", "ClassLoader", "parent", ")", "throws", "Exception", "{", "super", "(", "ProjectClassLoader", ".", "classpath", "(", "project", ")", ",", "parent", ")", ";", "}", "private", "static", "URL", "[", "]", "classpath", "(", "IJavaProject", "project", ")", "throws", "Exception", "{", "Set", "<", "IJavaProject", ">", "visited", "=", "new", "HashSet", "<", "IJavaProject", ">", "(", ")", ";", "List", "<", "URL", ">", "urls", "=", "new", "ArrayList", "<", "URL", ">", "(", ")", ";", "collect", "(", "project", ",", "urls", ",", "visited", ",", "true", ")", ";", "return", "urls", ".", "toArray", "(", "new", "URL", "[", "urls", ".", "size", "(", ")", "]", ")", ";", "}", "private", "static", "void", "collect", "(", "IJavaProject", "javaProject", ",", "List", "<", "URL", ">", "urls", ",", "Set", "<", "IJavaProject", ">", "visited", ",", "boolean", "isFirstProject", ")", "throws", "Exception", "{", "if", "(", "visited", ".", "contains", "(", "javaProject", ")", ")", "{", "return", ";", "}", "visited", ".", "add", "(", "javaProject", ")", ";", "try", "{", "IPath", "out", "=", "javaProject", ".", "getOutputLocation", "(", ")", ";", "String", "path", "=", "ProjectUtils", ".", "getFilePath", "(", "javaProject", ".", "getProject", "(", ")", ",", "out", ".", "toOSString", "(", ")", ")", ";", "path", "=", "FileUtils", ".", "addTrailingSlash", "(", "path", ".", "replace", "(", "'\\\\'", ",", "'/'", ")", ")", ";", "urls", ".", "add", "(", "new", "URL", "(", "\"file://\"", "+", "path", ")", ")", ";", "}", "catch", "(", "JavaModelException", "ignore", ")", "{", "}", "IProject", "project", "=", "javaProject", ".", "getProject", "(", ")", ";", "String", "name", "=", "project", ".", "getName", "(", ")", ";", "IClasspathEntry", "[", "]", "entries", "=", "null", ";", "try", "{", "entries", "=", "javaProject", ".", "getResolvedClasspath", "(", "true", ")", ";", "}", "catch", "(", "JavaModelException", "jme", ")", "{", "logger", ".", "warn", "(", "\"\"", "+", "name", ",", "jme", ")", ";", "return", ";", "}", "for", "(", "IClasspathEntry", "entry", ":", "entries", ")", "{", "switch", "(", "entry", ".", "getEntryKind", "(", ")", ")", "{", "case", "IClasspathEntry", ".", "CPE_LIBRARY", ":", "case", "IClasspathEntry", ".", "CPE_CONTAINER", ":", "case", "IClasspathEntry", ".", "CPE_VARIABLE", ":", "String", "path", "=", "entry", ".", "getPath", "(", ")", ".", "toOSString", "(", ")", ";", "if", "(", "path", ".", "startsWith", "(", "\"/\"", "+", "name", "+", "\"/\"", ")", ")", "{", "path", "=", "ProjectUtils", ".", "getFilePath", "(", "project", ",", "path", ")", ";", "}", "urls", ".", "add", "(", "new", "URL", "(", "\"file://\"", "+", "path", ")", ")", ";", "break", ";", "case", "IClasspathEntry", ".", "CPE_PROJECT", ":", "if", "(", "isFirstProject", "||", "entry", ".", "isExported", "(", ")", ")", "{", "collect", "(", "getJavaProject", "(", "entry", ")", ",", "urls", ",", "visited", ",", "false", ")", ";", "}", "break", ";", "}", "}", "}", "private", "static", "IJavaProject", "getJavaProject", "(", "IClasspathEntry", "entry", ")", "throws", "Exception", "{", "IProject", "project", "=", "ProjectUtils", ".", "getProject", "(", "entry", ".", "getPath", "(", ")", ".", "segment", "(", "0", ")", ")", ";", "if", "(", "project", "!=", "null", ")", "{", "return", "JavaUtils", ".", "getJavaProject", "(", "project", ")", ";", "}", "return", "null", ";", "}", "}", "}", "</s>" ]
1,229
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "src", ";", "import", "org", ".", "eclim", ".", "annotation", ".", "Command", ";", "import", "org", ".", "eclim", ".", "command", ".", "CommandLine", ";", "import", "org", ".", "eclim", ".", "command", ".", "Options", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "command", ".", "AbstractCommand", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "util", ".", "JavaUtils", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "ICompilationUnit", ";", "@", "Command", "(", "name", "=", "\"\"", ",", "options", "=", "\"\"", "+", "\"\"", ")", "public", "class", "SrcFindCommand", "extends", "AbstractCommand", "{", "public", "Object", "execute", "(", "CommandLine", "commandLine", ")", "throws", "Exception", "{", "String", "classname", "=", "commandLine", ".", "getValue", "(", "Options", ".", "CLASSNAME_OPTION", ")", ";", "String", "projectName", "=", "commandLine", ".", "getValue", "(", "Options", ".", "PROJECT_OPTION", ")", ";", "ICompilationUnit", "src", "=", "null", ";", "String", "file", "=", "classname", ".", "replace", "(", "'.'", ",", "'/'", ")", "+", "\".java\"", ";", "if", "(", "projectName", "!=", "null", ")", "{", "src", "=", "JavaUtils", ".", "findCompilationUnit", "(", "projectName", ",", "file", ")", ";", "}", "else", "{", "src", "=", "JavaUtils", ".", "findCompilationUnit", "(", "file", ")", ";", "}", "if", "(", "src", "!=", "null", "&&", "src", ".", "exists", "(", ")", ")", "{", "return", "src", ".", "getResource", "(", ")", ".", "getLocation", "(", ")", ".", "toOSString", "(", ")", ".", "replace", "(", "'\\\\'", ",", "'/'", ")", ";", "}", "return", "\"\"", ";", "}", "}", "</s>" ]
1,230
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "src", ";", "import", "org", ".", "eclim", ".", "annotation", ".", "Command", ";", "import", "org", ".", "eclim", ".", "command", ".", "CommandLine", ";", "import", "org", ".", "eclim", ".", "command", ".", "Options", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "command", ".", "AbstractCommand", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "util", ".", "ClasspathUtils", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "util", ".", "JavaUtils", ";", "import", "org", ".", "eclim", ".", "util", ".", "StringUtils", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IJavaProject", ";", "@", "Command", "(", "name", "=", "\"\"", ",", "options", "=", "\"\"", ")", "public", "class", "SrcDirsCommand", "extends", "AbstractCommand", "{", "public", "Object", "execute", "(", "CommandLine", "commandLine", ")", "throws", "Exception", "{", "String", "projectName", "=", "commandLine", ".", "getValue", "(", "Options", ".", "PROJECT_OPTION", ")", ";", "IJavaProject", "javaProject", "=", "JavaUtils", ".", "getJavaProject", "(", "projectName", ")", ";", "String", "[", "]", "paths", "=", "ClasspathUtils", ".", "getSrcPaths", "(", "javaProject", ")", ";", "return", "StringUtils", ".", "join", "(", "paths", ",", "\"n\"", ")", ";", "}", "}", "</s>" ]
1,231
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "src", ";", "import", "org", ".", "eclim", ".", "annotation", ".", "Command", ";", "import", "org", ".", "eclim", ".", "command", ".", "CommandLine", ";", "import", "org", ".", "eclim", ".", "command", ".", "Options", ";", "import", "org", ".", "eclim", ".", "logging", ".", "Logger", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "command", ".", "AbstractCommand", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "util", ".", "JavaUtils", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "ICompilationUnit", ";", "@", "Command", "(", "name", "=", "\"\"", ",", "options", "=", "\"\"", "+", "\"\"", ")", "public", "class", "SrcFileExistsCommand", "extends", "AbstractCommand", "{", "private", "static", "final", "Logger", "logger", "=", "Logger", ".", "getLogger", "(", "SrcFileExistsCommand", ".", "class", ")", ";", "public", "Object", "execute", "(", "CommandLine", "commandLine", ")", "throws", "Exception", "{", "try", "{", "String", "file", "=", "commandLine", ".", "getValue", "(", "Options", ".", "FILE_OPTION", ")", ";", "String", "projectName", "=", "commandLine", ".", "getValue", "(", "Options", ".", "PROJECT_OPTION", ")", ";", "if", "(", "projectName", "!=", "null", ")", "{", "ICompilationUnit", "src", "=", "JavaUtils", ".", "findCompilationUnit", "(", "projectName", ",", "file", ")", ";", "return", "src", "!=", "null", "&&", "src", ".", "exists", "(", ")", "?", "Boolean", ".", "TRUE", ".", "toString", "(", ")", ":", "Boolean", ".", "FALSE", ".", "toString", "(", ")", ";", "}", "ICompilationUnit", "src", "=", "JavaUtils", ".", "findCompilationUnit", "(", "file", ")", ";", "return", "src", "!=", "null", "&&", "src", ".", "exists", "(", ")", "?", "Boolean", ".", "TRUE", ".", "toString", "(", ")", ":", "Boolean", ".", "FALSE", ".", "toString", "(", ")", ";", "}", "catch", "(", "IllegalArgumentException", "iae", ")", "{", "logger", ".", "error", "(", "\"\"", ",", "iae", ")", ";", "return", "Boolean", ".", "FALSE", ".", "toString", "(", ")", ";", "}", "}", "}", "</s>" ]
1,232
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "src", ";", "import", "org", ".", "eclim", ".", "annotation", ".", "Command", ";", "import", "org", ".", "eclim", ".", "command", ".", "CommandLine", ";", "import", "org", ".", "eclim", ".", "command", ".", "Options", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "command", ".", "AbstractCommand", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "util", ".", "JavaUtils", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "ICompilationUnit", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "formatter", ".", "CodeFormatter", ";", "@", "Command", "(", "name", "=", "\"java_format\"", ",", "options", "=", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", ")", "public", "class", "FormatCommand", "extends", "AbstractCommand", "{", "@", "Override", "public", "Object", "execute", "(", "CommandLine", "commandLine", ")", "throws", "Exception", "{", "String", "project", "=", "commandLine", ".", "getValue", "(", "Options", ".", "PROJECT_OPTION", ")", ";", "String", "file", "=", "commandLine", ".", "getValue", "(", "Options", ".", "FILE_OPTION", ")", ";", "ICompilationUnit", "src", "=", "JavaUtils", ".", "getCompilationUnit", "(", "project", ",", "file", ")", ";", "int", "headOffset", "=", "getOffset", "(", "commandLine", ",", "\"h\"", ")", ";", "int", "tailOffset", "=", "getOffset", "(", "commandLine", ",", "\"t\"", ")", ";", "int", "kind", "=", "CodeFormatter", ".", "K_COMPILATION_UNIT", "|", "CodeFormatter", ".", "F_INCLUDE_COMMENTS", ";", "JavaUtils", ".", "format", "(", "src", ",", "kind", ",", "headOffset", ",", "tailOffset", "-", "headOffset", ")", ";", "return", "null", ";", "}", "}", "</s>" ]
1,233
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "src", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "io", ".", "FileInputStream", ";", "import", "java", ".", "io", ".", "FileWriter", ";", "import", "java", ".", "io", ".", "PrintWriter", ";", "import", "java", ".", "io", ".", "Writer", ";", "import", "java", ".", "util", ".", "Set", ";", "import", "java", ".", "util", ".", "TreeSet", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang", ".", "SystemUtils", ";", "import", "org", ".", "eclim", ".", "Services", ";", "import", "org", ".", "eclim", ".", "annotation", ".", "Command", ";", "import", "org", ".", "eclim", ".", "command", ".", "CommandLine", ";", "import", "org", ".", "eclim", ".", "command", ".", "Options", ";", "import", "org", ".", "eclim", ".", "logging", ".", "Logger", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "command", ".", "AbstractCommand", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "util", ".", "JavaUtils", ";", "import", "org", ".", "eclim", ".", "util", ".", "IOUtils", ";", "import", "org", ".", "eclim", ".", "util", ".", "StringUtils", ";", "import", "org", ".", "eclim", ".", "util", ".", "file", ".", "FileUtils", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "Flags", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IField", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IJavaProject", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IMember", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IMethod", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IType", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "Signature", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "AnnotationVisitor", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "Attribute", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "ClassReader", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "ClassVisitor", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "FieldVisitor", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "Label", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "MethodVisitor", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "Opcodes", ";", "@", "Command", "(", "name", "=", "\"\"", ",", "options", "=", "\"\"", "+", "\"\"", "+", "\"\"", ")", "public", "class", "ClassPrototypeCommand", "extends", "AbstractCommand", "{", "private", "static", "final", "Logger", "logger", "=", "Logger", ".", "getLogger", "(", "ClassPrototypeCommand", ".", "class", ")", ";", "private", "static", "final", "String", "INDENT", "=", "\"t\"", ";", "private", "static", "final", "String", "IMPORT_PATTERN", "=", "\"\"", ";", "private", "static", "final", "String", "OBJECT", "=", "\"\"", ";", "private", "static", "final", "String", "ANNOTATION", "=", "\"\"", ";", "public", "Object", "execute", "(", "CommandLine", "commandLine", ")", "throws", "Exception", "{", "String", "className", "=", "commandLine", ".", "getValue", "(", "Options", ".", "CLASSNAME_OPTION", ")", ";", "if", "(", "!", "commandLine", ".", "hasOption", "(", "Options", ".", "PROJECT_OPTION", ")", "&&", "!", "commandLine", ".", "hasOption", "(", "Options", ".", "FILE_OPTION", ")", ")", "{", "throw", "new", "RuntimeException", "(", "Services", ".", "getMessage", "(", "\"\"", ")", ")", ";", "}", "File", "file", "=", "new", "File", "(", "SystemUtils", ".", "JAVA_IO_TMPDIR", "+", "'/'", "+", "className", ".", "replace", "(", "'.'", ",", "'/'", ")", "+", "\".java\"", ")", ";", "new", "File", "(", "FileUtils", ".", "getFullPath", "(", "file", ".", "getAbsolutePath", "(", ")", ")", ")", ".", "mkdirs", "(", ")", ";", "file", ".", "deleteOnExit", "(", ")", ";", "FileWriter", "out", "=", "null", ";", "try", "{", "out", "=", "new", "FileWriter", "(", "file", ")", ";", "if", "(", "commandLine", ".", "hasOption", "(", "Options", ".", "FILE_OPTION", ")", ")", "{", "prototype", "(", "commandLine", ".", "getValue", "(", "Options", ".", "FILE_OPTION", ")", ",", "out", ")", ";", "}", "else", "{", "String", "projectName", "=", "commandLine", ".", "getValue", "(", "Options", ".", "PROJECT_OPTION", ")", ";", "IJavaProject", "javaProject", "=", "JavaUtils", ".", "getJavaProject", "(", "projectName", ")", ";", "IType", "type", "=", "javaProject", ".", "findType", "(", "className", ")", ";", "if", "(", "type", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "Services", ".", "getMessage", "(", "\"\"", ",", "projectName", ",", "className", ")", ")", ";", "}", "String", "prototype", "=", "prototype", "(", "type", ")", ";", "out", ".", "write", "(", "prototype", ")", ";", "}", "}", "finally", "{", "IOUtils", ".", "closeQuietly", "(", "out", ")", ";", "}", "return", "file", ".", "getAbsolutePath", "(", ")", ";", "}", "protected", "void", "prototype", "(", "String", "file", ",", "Writer", "writer", ")", "throws", "Exception", "{", "FileInputStream", "in", "=", "null", ";", "try", "{", "in", "=", "new", "FileInputStream", "(", "file", ")", ";", "ClassReader", "reader", "=", "new", "ClassReader", "(", "in", ")", ";", "reader", ".", "accept", "(", "new", "AsmClassVisitor", "(", "new", "PrintWriter", "(", "writer", ")", ")", ",", "false", ")", ";", "}", "finally", "{", "IOUtils", ".", "closeQuietly", "(", "in", ")", ";", "}", "}", "protected", "String", "prototype", "(", "IType", "type", ")", "throws", "Exception", "{", "Set", "<", "String", ">", "imports", "=", "new", "TreeSet", "<", "String", ">", "(", ")", ";", "StringBuffer", "buffer", "=", "new", "StringBuffer", "(", ")", ";", "buffer", ".", "append", "(", "Services", ".", "getMessage", "(", "\"\"", ")", ")", ";", "buffer", ".", "append", "(", "\"package", "\"", ")", ".", "append", "(", "type", ".", "getPackageFragment", "(", ")", ".", "getElementName", "(", ")", ")", ".", "append", "(", "\";n\"", ")", ";", "prototype", "(", "buffer", ",", "type", ",", "\"\"", ",", "imports", ")", ";", "StringBuffer", "importClauses", "=", "new", "StringBuffer", "(", ")", ".", "append", "(", "\"nn\"", ")", ";", "for", "(", "String", "className", ":", "imports", ")", "{", "importClauses", ".", "append", "(", "\"import", "\"", ")", ".", "append", "(", "className", ")", ".", "append", "(", "\";n\"", ")", ";", "}", "buffer", ".", "insert", "(", "buffer", ".", "indexOf", "(", "\";\"", ")", "+", "1", ",", "importClauses", ".", "toString", "(", ")", ")", ";", "return", "buffer", ".", "toString", "(", ")", ";", "}", "protected", "void", "prototype", "(", "StringBuffer", "buffer", ",", "IType", "type", ",", "String", "indent", ",", "Set", "<", "String", ">", "imports", ")", "throws", "Exception", "{", "buffer", ".", "append", "(", "indent", ")", ";", "prototypeFlags", "(", "buffer", ",", "type", ")", ";", "int", "flags", "=", "type", ".", "getFlags", "(", ")", ";", "if", "(", "Flags", ".", "isEnum", "(", "flags", ")", ")", "{", "buffer", ".", "append", "(", "\"enum", "\"", ")", ";", "}", "else", "if", "(", "Flags", ".", "isInterface", "(", "flags", ")", ")", "{", "buffer", ".", "append", "(", "\"interface", "\"", ")", ";", "}", "else", "if", "(", "Flags", ".", "isAnnotation", "(", "flags", ")", ")", "{", "buffer", ".", "append", "(", "\"@interface", "\"", ")", ";", "}", "else", "{", "buffer", ".", "append", "(", "\"class", "\"", ")", ";", "}", "buffer", ".", "append", "(", "type", ".", "getElementName", "(", ")", ")", ";", "String", "superclass", "=", "type", ".", "getSuperclassName", "(", ")", ";", "if", "(", "superclass", "!=", "null", ")", "{", "buffer", ".", "append", "(", "'\\n'", ")", ".", "append", "(", "indent", ")", ".", "append", "(", "INDENT", ")", ".", "append", "(", "\"extends", "\"", ")", ".", "append", "(", "superclass", ")", ";", "}", "String", "[", "]", "interfaces", "=", "type", ".", "getSuperInterfaceNames", "(", ")", ";", "if", "(", "interfaces", "!=", "null", "&&", "interfaces", ".", "length", ">", "0", ")", "{", "buffer", ".", "append", "(", "'\\n'", ")", ".", "append", "(", "indent", ")", ".", "append", "(", "INDENT", ")", ".", "append", "(", "\"implements", "\"", ")", ";", "for", "(", "int", "ii", "=", "0", ";", "ii", "<", "interfaces", ".", "length", ";", "ii", "++", ")", "{", "if", "(", "ii", "!=", "0", ")", "{", "buffer", ".", "append", "(", "\",", "\"", ")", ";", "}", "buffer", ".", "append", "(", "interfaces", "[", "ii", "]", ")", ";", "}", "}", "buffer", ".", "append", "(", "'\\n'", ")", ".", "append", "(", "indent", ")", ".", "append", "(", "\"{n\"", ")", ";", "int", "length", "=", "buffer", ".", "length", "(", ")", ";", "IField", "[", "]", "fields", "=", "type", ".", "getFields", "(", ")", ";", "for", "(", "int", "ii", "=", "0", ";", "ii", "<", "fields", ".", "length", ";", "ii", "++", ")", "{", "prototypeField", "(", "buffer", ",", "fields", "[", "ii", "]", ",", "indent", "+", "INDENT", ",", "imports", ")", ";", "}", "IMethod", "[", "]", "methods", "=", "type", ".", "getMethods", "(", ")", ";", "if", "(", "methods", "!=", "null", "&&", "methods", ".", "length", ">", "0", ")", "{", "for", "(", "int", "ii", "=", "0", ";", "ii", "<", "methods", ".", "length", ";", "ii", "++", ")", "{", "if", "(", "length", "!=", "buffer", ".", "length", "(", ")", ")", "{", "buffer", ".", "append", "(", "'\\n'", ")", ";", "}", "length", "=", "buffer", ".", "length", "(", ")", ";", "prototypeMethod", "(", "buffer", ",", "methods", "[", "ii", "]", ",", "indent", "+", "INDENT", ",", "imports", ")", ";", "}", "}", "IType", "[", "]", "types", "=", "type", ".", "getTypes", "(", ")", ";", "if", "(", "types", "!=", "null", "&&", "types", ".", "length", ">", "0", ")", "{", "if", "(", "length", "!=", "buffer", ".", "length", "(", ")", ")", "{", "buffer", ".", "append", "(", "'\\n'", ")", ";", "}", "for", "(", "int", "ii", "=", "0", ";", "ii", "<", "types", ".", "length", ";", "ii", "++", ")", "{", "if", "(", "ii", ">", "0", ")", "{", "buffer", ".", "append", "(", "'\\n'", ")", ";", "}", "prototype", "(", "buffer", ",", "types", "[", "ii", "]", ",", "indent", "+", "INDENT", ",", "imports", ")", ";", "buffer", ".", "append", "(", "'\\n'", ")", ";", "}", "}", "buffer", ".", "append", "(", "indent", ")", ".", "append", "(", "\"}\"", ")", ";", "}", "protected", "void", "prototypeField", "(", "StringBuffer", "buffer", ",", "IField", "field", ",", "String", "indent", ",", "Set", "<", "String", ">", "imports", ")", "throws", "Exception", "{", "String", "fieldName", "=", "field", ".", "getElementName", "(", ")", ";", "if", "(", "fieldName", ".", "indexOf", "(", "\"$\"", ")", "==", "-", "1", ")", "{", "buffer", ".", "append", "(", "indent", ")", ";", "prototypeFlags", "(", "buffer", ",", "field", ")", ";", "String", "type", "=", "field", ".", "getTypeSignature", "(", ")", ";", "String", "typeName", "=", "Signature", ".", "getSignatureSimpleName", "(", "type", ")", ";", "buffer", ".", "append", "(", "typeName", ")", ".", "append", "(", "'", "'", ")", ".", "append", "(", "field", ".", "getElementName", "(", ")", ")", ";", "addImport", "(", "imports", ",", "type", ")", ";", "Object", "defaultValue", "=", "field", ".", "getConstant", "(", ")", ";", "if", "(", "defaultValue", "!=", "null", ")", "{", "buffer", ".", "append", "(", "\"", "=", "\"", ")", ";", "if", "(", "typeName", ".", "equals", "(", "\"char\"", ")", ")", "{", "buffer", ".", "append", "(", "'\\''", ")", ".", "append", "(", "defaultValue", ")", ".", "append", "(", "'\\''", ")", ";", "}", "else", "if", "(", "typeName", ".", "equals", "(", "\"int\"", ")", "||", "typeName", ".", "equals", "(", "\"long\"", ")", "||", "typeName", ".", "equals", "(", "\"short\"", ")", "||", "typeName", ".", "equals", "(", "\"double\"", ")", "||", "typeName", ".", "equals", "(", "\"float\"", ")", "||", "typeName", ".", "equals", "(", "\"boolean\"", ")", "||", "typeName", ".", "equals", "(", "\"byte\"", ")", ")", "{", "buffer", ".", "append", "(", "defaultValue", ")", ";", "}", "else", "if", "(", "defaultValue", "instanceof", "String", ")", "{", "buffer", ".", "append", "(", "'\"'", ")", ".", "append", "(", "defaultValue", ")", ".", "append", "(", "'\"'", ")", ";", "}", "else", "{", "logger", ".", "warn", "(", "\"\"", ",", "defaultValue", ".", "getClass", "(", ")", ".", "getName", "(", ")", ",", "defaultValue", ")", ";", "}", "}", "buffer", ".", "append", "(", "\";n\"", ")", ";", "}", "}", "protected", "void", "prototypeMethod", "(", "StringBuffer", "buffer", ",", "IMethod", "method", ",", "String", "indent", ",", "Set", "<", "String", ">", "imports", ")", "throws", "Exception", "{", "String", "methodName", "=", "method", ".", "getElementName", "(", ")", ";", "if", "(", "methodName", ".", "indexOf", "(", "\"$\"", ")", "==", "-", "1", "&&", "!", "methodName", ".", "equals", "(", "\"<clinit>\"", ")", ")", "{", "buffer", ".", "append", "(", "indent", ")", ";", "prototypeFlags", "(", "buffer", ",", "method", ")", ";", "String", "returnType", "=", "method", ".", "getReturnType", "(", ")", ";", "String", "returnTypeName", "=", "Signature", ".", "getSignatureSimpleName", "(", "returnType", ")", ";", "addImport", "(", "imports", ",", "returnType", ")", ";", "buffer", ".", "append", "(", "returnTypeName", ")", ".", "append", "(", "'", "'", ")", ".", "append", "(", "methodName", ")", ".", "append", "(", "\"", "(\"", ")", ";", "String", "[", "]", "paramNames", "=", "method", ".", "getParameterNames", "(", ")", ";", "String", "[", "]", "paramTypes", "=", "method", ".", "getParameterTypes", "(", ")", ";", "if", "(", "paramNames", ".", "length", ">", "0", ")", "{", "for", "(", "int", "ii", "=", "0", ";", "ii", "<", "paramNames", ".", "length", ";", "ii", "++", ")", "{", "if", "(", "ii", "!=", "0", ")", "{", "buffer", ".", "append", "(", "\",", "\"", ")", ";", "}", "addImport", "(", "imports", ",", "paramTypes", "[", "ii", "]", ")", ";", "String", "typeName", "=", "Signature", ".", "getSignatureSimpleName", "(", "paramTypes", "[", "ii", "]", ")", ";", "buffer", ".", "append", "(", "typeName", ")", ".", "append", "(", "'", "'", ")", ".", "append", "(", "paramNames", "[", "ii", "]", ")", ";", "}", "}", "buffer", ".", "append", "(", "\")\"", ")", ";", "String", "[", "]", "exceptions", "=", "method", ".", "getExceptionTypes", "(", ")", ";", "if", "(", "exceptions", ".", "length", ">", "0", ")", "{", "buffer", ".", "append", "(", "'\\n'", ")", ".", "append", "(", "indent", ")", ".", "append", "(", "INDENT", ")", ".", "append", "(", "\"throws", "\"", ")", ";", "for", "(", "int", "ii", "=", "0", ";", "ii", "<", "exceptions", ".", "length", ";", "ii", "++", ")", "{", "if", "(", "ii", "!=", "0", ")", "{", "buffer", ".", "append", "(", "\",", "\"", ")", ";", "}", "buffer", ".", "append", "(", "Signature", ".", "getSignatureSimpleName", "(", "exceptions", "[", "ii", "]", ")", ")", ";", "}", "}", "buffer", ".", "append", "(", "\";n\"", ")", ";", "}", "}", "protected", "void", "prototypeFlags", "(", "StringBuffer", "buffer", ",", "IMember", "member", ")", "throws", "Exception", "{", "int", "flags", "=", "member", ".", "getFlags", "(", ")", ";", "if", "(", "Flags", ".", "isPublic", "(", "flags", ")", ")", "{", "buffer", ".", "append", "(", "\"public", "\"", ")", ";", "}", "else", "if", "(", "Flags", ".", "isProtected", "(", "flags", ")", ")", "{", "buffer", ".", "append", "(", "\"protected", "\"", ")", ";", "}", "else", "if", "(", "Flags", ".", "isPrivate", "(", "flags", ")", ")", "{", "buffer", ".", "append", "(", "\"private", "\"", ")", ";", "}", "if", "(", "Flags", ".", "isStatic", "(", "flags", ")", ")", "{", "buffer", ".", "append", "(", "\"static", "\"", ")", ";", "}", "if", "(", "Flags", ".", "isFinal", "(", "flags", ")", ")", "{", "buffer", ".", "append", "(", "\"final", "\"", ")", ";", "}", "if", "(", "Flags", ".", "isAbstract", "(", "flags", ")", ")", "{", "buffer", ".", "append", "(", "\"abstract", "\"", ")", ";", "}", "if", "(", "Flags", ".", "isNative", "(", "flags", ")", ")", "{", "buffer", ".", "append", "(", "\"native", "\"", ")", ";", "}", "if", "(", "Flags", ".", "isTransient", "(", "flags", ")", ")", "{", "buffer", ".", "append", "(", "\"transient", "\"", ")", ";", "}", "if", "(", "Flags", ".", "isVolatile", "(", "flags", ")", ")", "{", "buffer", ".", "append", "(", "\"volatile", "\"", ")", ";", "}", "if", "(", "Flags", ".", "isSynchronized", "(", "flags", ")", ")", "{", "buffer", ".", "append", "(", "\"\"", ")", ";", "}", "}", "protected", "void", "addImport", "(", "Set", "<", "String", ">", "imports", ",", "String", "signature", ")", "{", "String", "name", "=", "Signature", ".", "getSignatureSimpleName", "(", "signature", ")", ";", "if", "(", "name", ".", "length", "(", ")", ">", "1", "&&", "!", "name", ".", "equals", "(", "\"void\"", ")", ")", "{", "String", "pckg", "=", "Signature", ".", "getSignatureQualifier", "(", "signature", ")", ";", "if", "(", "pckg", "!=", "null", "&&", "pckg", ".", "length", "(", ")", ">", "0", ")", "{", "name", "=", "pckg", "+", "'.'", "+", "name", ";", "imports", ".", "add", "(", "name", ".", "replaceFirst", "(", "IMPORT_PATTERN", ",", "\"\"", ")", ")", ";", "}", "}", "}", "private", "static", "class", "AsmClassVisitor", "implements", "ClassVisitor", "{", "private", "PrintWriter", "writer", ";", "private", "StringBuffer", "classBuffer", ";", "private", "String", "name", ";", "public", "AsmClassVisitor", "(", "PrintWriter", "writer", ")", "{", "super", "(", ")", ";", "this", ".", "writer", "=", "writer", ";", "}", "public", "void", "visit", "(", "int", "version", ",", "int", "access", ",", "String", "name", ",", "String", "signature", ",", "String", "superName", ",", "String", "[", "]", "interfaces", ")", "{", "writer", ".", "print", "(", "Services", ".", "getMessage", "(", "\"\"", ")", ")", ";", "int", "index", "=", "name", ".", "lastIndexOf", "(", "'/'", ")", ";", "if", "(", "index", "!=", "-", "1", ")", "{", "String", "pack", "=", "name", ".", "substring", "(", "0", ",", "index", ")", ".", "replace", "(", "'/'", ",", "'.'", ")", ";", "name", "=", "name", ".", "substring", "(", "index", "+", "1", ")", ";", "writer", ".", "print", "(", "\"package", "\"", ")", ";", "writer", ".", "print", "(", "pack", ")", ";", "writer", ".", "println", "(", "\";n\"", ")", ";", "}", "this", ".", "name", "=", "name", ";", "classBuffer", "=", "new", "StringBuffer", "(", ")", ".", "append", "(", "getAccess", "(", "access", ")", ")", ";", "if", "(", "(", "access", "&", "Opcodes", ".", "ACC_INTERFACE", ")", "==", "1", ")", "{", "classBuffer", ".", "append", "(", "\"interface", "\"", ")", ";", "}", "else", "if", "(", "(", "access", "&", "Opcodes", ".", "ACC_ENUM", ")", "==", "1", ")", "{", "classBuffer", ".", "append", "(", "\"enum", "\"", ")", ";", "}", "else", "{", "if", "(", "interfaces", ".", "length", ">", "0", "&&", "interfaces", "[", "0", "]", ".", "equals", "(", "ANNOTATION", ")", ")", "{", "classBuffer", ".", "append", "(", "\"@interface", "\"", ")", ";", "}", "else", "{", "classBuffer", ".", "append", "(", "\"class", "\"", ")", ";", "}", "}", "classBuffer", ".", "append", "(", "name", ")", ".", "append", "(", "'\\n'", ")", ";", "if", "(", "!", "OBJECT", ".", "equals", "(", "superName", ")", ")", "{", "classBuffer", ".", "append", "(", "INDENT", ")", ".", "append", "(", "\"extends", "\"", ")", ".", "append", "(", "superName", ".", "replace", "(", "'/'", ",", "'.'", ")", ")", ".", "append", "(", "'\\n'", ")", ";", "}", "StringBuffer", "ifaces", "=", "new", "StringBuffer", "(", ")", ";", "for", "(", "String", "iface", ":", "interfaces", ")", "{", "if", "(", "!", "ANNOTATION", ".", "equals", "(", "iface", ")", ")", "{", "if", "(", "ifaces", ".", "length", "(", ")", ">", "0", ")", "{", "ifaces", ".", "append", "(", "\",", "\"", ")", ";", "}", "ifaces", ".", "append", "(", "iface", ".", "replace", "(", "'/'", ",", "'.'", ")", ")", ";", "}", "}", "if", "(", "ifaces", ".", "length", "(", ")", ">", "0", ")", "{", "classBuffer", ".", "append", "(", "INDENT", ")", ".", "append", "(", "\"implements", "\"", ")", ".", "append", "(", "ifaces", ")", ".", "append", "(", "'\\n'", ")", ";", "}", "classBuffer", ".", "append", "(", "\"{n\"", ")", ";", "}", "public", "void", "visitSource", "(", "String", "source", ",", "String", "debug", ")", "{", "}", "public", "void", "visitOuterClass", "(", "String", "owner", ",", "String", "name", ",", "String", "desc", ")", "{", "}", "public", "AnnotationVisitor", "visitAnnotation", "(", "String", "desc", ",", "boolean", "visible", ")", "{", "writer", ".", "print", "(", "'@'", ")", ";", "writer", ".", "print", "(", "getDescName", "(", "desc", ")", ")", ";", "return", "new", "AsmAnnotationVisitor", "(", ")", ";", "}", "public", "void", "visitAttribute", "(", "Attribute", "attr", ")", "{", "}", "public", "void", "visitInnerClass", "(", "String", "name", ",", "String", "outerName", ",", "String", "innerName", ",", "int", "access", ")", "{", "flushClassDeclaration", "(", ")", ";", "}", "public", "FieldVisitor", "visitField", "(", "int", "access", ",", "String", "name", ",", "String", "desc", ",", "String", "signature", ",", "Object", "value", ")", "{", "flushClassDeclaration", "(", ")", ";", "return", "new", "AsmFieldVisitor", "(", "access", ",", "name", ",", "desc", ",", "value", ")", ";", "}", "public", "MethodVisitor", "visitMethod", "(", "int", "access", ",", "String", "name", ",", "String", "desc", ",", "String", "signature", ",", "String", "[", "]", "exceptions", ")", "{", "flushClassDeclaration", "(", ")", ";", "return", "new", "AsmMethodVisitor", "(", "access", ",", "name", ",", "signature", "!=", "null", "?", "signature", ":", "desc", ",", "exceptions", ")", ";", "}", "private", "void", "flushClassDeclaration", "(", ")", "{", "if", "(", "classBuffer", "!=", "null", ")", "{", "writer", ".", "write", "(", "classBuffer", ".", "toString", "(", ")", ")", ";", "classBuffer", "=", "null", ";", "}", "}", "public", "void", "visitEnd", "(", ")", "{", "flushClassDeclaration", "(", ")", ";", "writer", ".", "print", "(", "'}'", ")", ";", "}", "private", "String", "getDescName", "(", "String", "desc", ")", "{", "if", "(", "desc", "!=", "null", ")", "{", "int", "indexStart", "=", "desc", ".", "indexOf", "(", "'<'", ")", ";", "int", "indexEnd", "=", "desc", ".", "lastIndexOf", "(", "'>'", ")", ";", "if", "(", "indexStart", "!=", "-", "1", "&&", "indexEnd", "!=", "-", "1", ")", "{", "String", "outer", "=", "desc", ".", "substring", "(", "0", ",", "indexStart", ")", ";", "String", "inner", "=", "desc", ".", "substring", "(", "indexStart", "+", "1", ",", "indexEnd", ")", ";", "return", "getDescName", "(", "outer", ")", "+", "'<'", "+", "getDescName", "(", "inner", ")", "+", "'>'", ";", "}", "int", "index", "=", "desc", ".", "lastIndexOf", "(", "'/'", ")", ";", "if", "(", "index", "!=", "-", "1", ")", "{", "String", "name", "=", "desc", ".", "substring", "(", "index", "+", "1", ")", ";", "if", "(", "name", ".", "endsWith", "(", "\";\"", ")", ")", "{", "name", "=", "name", ".", "substring", "(", "0", ",", "name", ".", "length", "(", ")", "-", "1", ")", ";", "}", "while", "(", "desc", ".", "startsWith", "(", "\"[\"", ")", ")", "{", "desc", "=", "desc", ".", "substring", "(", "1", ")", ";", "name", "+=", "\"[]\"", ";", "}", "return", "name", ";", "}", "String", "primitive", "=", "null", ";", "if", "(", "\"V\"", ".", "equals", "(", "desc", ")", ")", "{", "return", "\"void\"", ";", "}", "else", "if", "(", "desc", ".", "endsWith", "(", "\"I\"", ")", ")", "{", "primitive", "=", "\"int\"", ";", "}", "else", "if", "(", "desc", ".", "endsWith", "(", "\"J\"", ")", ")", "{", "primitive", "=", "\"long\"", ";", "}", "else", "if", "(", "desc", ".", "endsWith", "(", "\"S\"", ")", ")", "{", "primitive", "=", "\"short\"", ";", "}", "else", "if", "(", "desc", ".", "endsWith", "(", "\"C\"", ")", ")", "{", "primitive", "=", "\"char\"", ";", "}", "else", "if", "(", "desc", ".", "endsWith", "(", "\"B\"", ")", ")", "{", "primitive", "=", "\"byte\"", ";", "}", "else", "if", "(", "desc", ".", "endsWith", "(", "\"Z\"", ")", ")", "{", "primitive", "=", "\"boolean\"", ";", "}", "if", "(", "primitive", "!=", "null", ")", "{", "for", "(", "int", "ii", "=", "0", ";", "ii", "<", "desc", ".", "length", "(", ")", "-", "1", ";", "ii", "++", ")", "{", "primitive", "+=", "\"[]\"", ";", "}", "return", "primitive", ";", "}", "}", "return", "StringUtils", ".", "EMPTY", ";", "}", "private", "String", "getAccess", "(", "int", "access", ")", "{", "StringBuffer", "buffer", "=", "new", "StringBuffer", "(", ")", ";", "if", "(", "(", "access", "&", "Opcodes", ".", "ACC_PUBLIC", ")", "!=", "0", ")", "{", "buffer", ".", "append", "(", "\"public", "\"", ")", ";", "}", "if", "(", "(", "access", "&", "Opcodes", ".", "ACC_PRIVATE", ")", "!=", "0", ")", "{", "buffer", ".", "append", "(", "\"private", "\"", ")", ";", "}", "if", "(", "(", "access", "&", "Opcodes", ".", "ACC_PROTECTED", ")", "!=", "0", ")", "{", "buffer", ".", "append", "(", "\"protected", "\"", ")", ";", "}", "if", "(", "(", "access", "&", "Opcodes", ".", "ACC_STATIC", ")", "!=", "0", ")", "{", "buffer", ".", "append", "(", "\"static", "\"", ")", ";", "}", "if", "(", "(", "access", "&", "Opcodes", ".", "ACC_FINAL", ")", "!=", "0", ")", "{", "buffer", ".", "append", "(", "\"final", "\"", ")", ";", "}", "if", "(", "(", "access", "&", "Opcodes", ".", "ACC_TRANSIENT", ")", "!=", "0", ")", "{", "buffer", ".", "append", "(", "\"transient", "\"", ")", ";", "}", "if", "(", "(", "access", "&", "Opcodes", ".", "ACC_NATIVE", ")", "!=", "0", ")", "{", "buffer", ".", "append", "(", "\"native", "\"", ")", ";", "}", "if", "(", "(", "access", "&", "Opcodes", ".", "ACC_SYNCHRONIZED", ")", "!=", "0", ")", "{", "buffer", ".", "append", "(", "\"\"", ")", ";", "}", "if", "(", "(", "access", "&", "Opcodes", ".", "ACC_ABSTRACT", ")", "!=", "0", ")", "{", "buffer", ".", "append", "(", "\"abstract", "\"", ")", ";", "}", "return", "buffer", ".", "toString", "(", ")", ";", "}", "private", "String", "getValueString", "(", "Object", "value", ")", "{", "if", "(", "value", "instanceof", "String", ")", "{", "return", "new", "StringBuffer", "(", ")", ".", "append", "(", "'\"'", ")", ".", "append", "(", "value", ")", ".", "append", "(", "'\"'", ")", ".", "toString", "(", ")", ";", "}", "else", "if", "(", "value", "instanceof", "Character", ")", "{", "return", "new", "StringBuffer", "(", ")", ".", "append", "(", "'\\''", ")", ".", "append", "(", "value", ")", ".", "append", "(", "'\\''", ")", ".", "toString", "(", ")", ";", "}", "return", "String", ".", "valueOf", "(", "value", ")", ";", "}", "private", "class", "AsmAnnotationVisitor", "implements", "AnnotationVisitor", "{", "private", "boolean", "wrote", "=", "false", ";", "private", "boolean", "wroteOpenParen", "=", "false", ";", "public", "void", "visit", "(", "String", "name", ",", "Object", "value", ")", "{", "if", "(", "name", "!=", "null", ")", "{", "writeOpenParen", "(", ")", ";", "writer", ".", "print", "(", "name", ")", ";", "writer", ".", "print", "(", "\"", "=", "\"", ")", ";", "writer", ".", "print", "(", "getValueString", "(", "value", ")", ")", ";", "wrote", "=", "true", ";", "}", "}", "public", "void", "visitEnum", "(", "String", "name", ",", "String", "desc", ",", "String", "value", ")", "{", "writeOpenParen", "(", ")", ";", "writer", ".", "print", "(", "getDescName", "(", "desc", ")", ")", ";", "writer", ".", "print", "(", "'.'", ")", ";", "writer", ".", "print", "(", "value", ")", ";", "wrote", "=", "true", ";", "}", "public", "AnnotationVisitor", "visitAnnotation", "(", "String", "name", ",", "String", "desc", ")", "{", "return", "new", "AsmAnnotationVisitor", "(", ")", ";", "}", "public", "AnnotationVisitor", "visitArray", "(", "String", "name", ")", "{", "return", "new", "AsmAnnotationVisitor", "(", ")", ";", "}", "public", "void", "visitEnd", "(", ")", "{", "if", "(", "wrote", ")", "{", "if", "(", "wroteOpenParen", ")", "{", "writer", ".", "print", "(", "')'", ")", ";", "}", "writer", ".", "println", "(", ")", ";", "wrote", "=", "false", ";", "}", "}", "private", "void", "writeOpenParen", "(", ")", "{", "if", "(", "!", "wroteOpenParen", ")", "{", "writer", ".", "print", "(", "'('", ")", ";", "wroteOpenParen", "=", "true", ";", "}", "else", "{", "writer", ".", "print", "(", "\",", "\"", ")", ";", "}", "}", "}", "private", "class", "AsmMethodVisitor", "implements", "MethodVisitor", "{", "private", "int", "access", ";", "private", "String", "name", ";", "private", "String", "desc", ";", "private", "String", "[", "]", "exceptions", ";", "public", "AsmMethodVisitor", "(", "int", "access", ",", "String", "name", ",", "String", "desc", ",", "String", "[", "]", "exceptions", ")", "{", "this", ".", "access", "=", "access", ";", "this", ".", "name", "=", "name", ";", "this", ".", "desc", "=", "desc", ";", "this", ".", "exceptions", "=", "exceptions", ";", "}", "public", "AnnotationVisitor", "visitAnnotationDefault", "(", ")", "{", "return", "new", "AsmAnnotationVisitor", "(", ")", ";", "}", "public", "AnnotationVisitor", "visitAnnotation", "(", "String", "desc", ",", "boolean", "visible", ")", "{", "return", "new", "AsmAnnotationVisitor", "(", ")", ";", "}", "public", "AnnotationVisitor", "visitParameterAnnotation", "(", "int", "parameter", ",", "String", "desc", ",", "boolean", "visible", ")", "{", "return", "new", "AsmAnnotationVisitor", "(", ")", ";", "}", "public", "void", "visitAttribute", "(", "Attribute", "attr", ")", "{", "}", "public", "void", "visitCode", "(", ")", "{", "}", "public", "void", "visitInsn", "(", "int", "opcode", ")", "{", "}", "public", "void", "visitIntInsn", "(", "int", "opcode", ",", "int", "operand", ")", "{", "}", "public", "void", "visitVarInsn", "(", "int", "opcode", ",", "int", "var", ")", "{", "}", "public", "void", "visitTypeInsn", "(", "int", "opcode", ",", "String", "desc", ")", "{", "}", "public", "void", "visitFieldInsn", "(", "int", "opcode", ",", "String", "owner", ",", "String", "name", ",", "String", "desc", ")", "{", "}", "public", "void", "visitMethodInsn", "(", "int", "opcode", ",", "String", "owner", ",", "String", "name", ",", "String", "desc", ")", "{", "}", "public", "void", "visitJumpInsn", "(", "int", "opcode", ",", "Label", "operand", ")", "{", "}", "public", "void", "visitLabel", "(", "Label", "label", ")", "{", "}", "public", "void", "visitLdcInsn", "(", "Object", "cst", ")", "{", "}", "public", "void", "visitIincInsn", "(", "int", "var", ",", "int", "increment", ")", "{", "}", "public", "void", "visitTableSwitchInsn", "(", "int", "min", ",", "int", "max", ",", "Label", "dflt", ",", "Label", "[", "]", "labels", ")", "{", "}", "public", "void", "visitLookupSwitchInsn", "(", "Label", "dflt", ",", "int", "[", "]", "keys", ",", "Label", "[", "]", "labels", ")", "{", "}", "public", "void", "visitMultiANewArrayInsn", "(", "String", "desc", ",", "int", "dims", ")", "{", "}", "public", "void", "visitTryCatchBlock", "(", "Label", "start", ",", "Label", "end", ",", "Label", "handler", ",", "String", "type", ")", "{", "}", "public", "void", "visitLocalVariable", "(", "String", "name", ",", "String", "desc", ",", "String", "signature", ",", "Label", "start", ",", "Label", "end", ",", "int", "index", ")", "{", "}", "public", "void", "visitLineNumber", "(", "int", "line", ",", "Label", "start", ")", "{", "}", "public", "void", "visitMaxs", "(", "int", "maxStack", ",", "int", "maxLocal", ")", "{", "}", "public", "void", "visitEnd", "(", ")", "{", "if", "(", "\"<clinit>\"", ".", "equals", "(", "name", ")", ")", "{", "return", ";", "}", "if", "(", "\"<init>\"", ".", "equals", "(", "name", ")", ")", "{", "name", "=", "AsmClassVisitor", ".", "this", ".", "name", ";", "}", "String", "ret", "=", "\"void\"", ";", "int", "index", "=", "desc", ".", "lastIndexOf", "(", "')'", ")", ";", "if", "(", "index", "!=", "-", "1", ")", "{", "ret", "=", "getDescName", "(", "desc", ".", "substring", "(", "index", "+", "1", ",", "desc", ".", "length", "(", ")", ")", ")", ";", "}", "StringBuffer", "params", "=", "new", "StringBuffer", "(", ")", ";", "int", "openParen", "=", "desc", ".", "indexOf", "(", "'('", ")", ";", "int", "closeParen", "=", "desc", ".", "indexOf", "(", "')'", ")", ";", "if", "(", "closeParen", ">", "(", "openParen", "+", "1", ")", ")", "{", "String", "args", "=", "desc", ".", "substring", "(", "openParen", "+", "1", ",", "closeParen", ")", ";", "StringBuffer", "buffer", "=", "new", "StringBuffer", "(", ")", ";", "int", "paramIndex", "=", "0", ";", "int", "typeLevel", "=", "0", ";", "boolean", "inType", "=", "false", ";", "for", "(", "char", "c", ":", "args", ".", "toCharArray", "(", ")", ")", "{", "if", "(", "c", "==", "'['", "||", "c", "==", "'<'", ")", "{", "inType", "=", "false", ";", "buffer", ".", "append", "(", "c", ")", ";", "continue", ";", "}", "if", "(", "c", "==", "';'", "||", "(", "!", "inType", "&&", "Character", ".", "isLetter", "(", "c", ")", "&&", "Character", ".", "isUpperCase", "(", "c", ")", "&&", "c", "!=", "'L'", ")", ")", "{", "buffer", ".", "append", "(", "c", ")", ";", "if", "(", "c", "==", "';'", ")", "{", "typeLevel", "-=", "1", ";", "inType", "=", "false", ";", "}", "if", "(", "typeLevel", ">", "0", ")", "{", "continue", ";", "}", "if", "(", "params", ".", "length", "(", ")", "!=", "0", ")", "{", "params", ".", "append", "(", "\",", "\"", ")", ";", "}", "params", ".", "append", "(", "getDescName", "(", "buffer", ".", "toString", "(", ")", ")", ")", ";", "params", ".", "append", "(", "\"", "arg\"", ")", ".", "append", "(", "paramIndex", "++", ")", ";", "buffer", "=", "new", "StringBuffer", "(", ")", ";", "continue", ";", "}", "if", "(", "(", "!", "inType", "&&", "c", "==", "'L'", ")", "||", "c", "==", "'<'", ")", "{", "typeLevel", "+=", "1", ";", "inType", "=", "true", ";", "}", "buffer", ".", "append", "(", "c", ")", ";", "}", "}", "writer", ".", "print", "(", "INDENT", ")", ";", "writer", ".", "print", "(", "getAccess", "(", "access", ")", ")", ";", "writer", ".", "print", "(", "ret", ")", ";", "writer", ".", "print", "(", "'", "'", ")", ";", "writer", ".", "print", "(", "name", ")", ";", "writer", ".", "print", "(", "'('", ")", ";", "writer", ".", "print", "(", "params", ")", ";", "writer", ".", "print", "(", "')'", ")", ";", "if", "(", "exceptions", "!=", "null", "&&", "exceptions", ".", "length", ">", "0", ")", "{", "writer", ".", "println", "(", ")", ";", "writer", ".", "print", "(", "INDENT", ")", ";", "writer", ".", "print", "(", "INDENT", ")", ";", "writer", ".", "print", "(", "\"throws", "\"", ")", ";", "for", "(", "int", "ii", "=", "0", ";", "ii", "<", "exceptions", ".", "length", ";", "ii", "++", ")", "{", "if", "(", "ii", ">", "0", ")", "{", "writer", ".", "print", "(", "\",", "\"", ")", ";", "}", "writer", ".", "print", "(", "getDescName", "(", "exceptions", "[", "ii", "]", ")", ")", ";", "}", "}", "writer", ".", "print", "(", "\";n\"", ")", ";", "}", "}", "private", "class", "AsmFieldVisitor", "implements", "FieldVisitor", "{", "private", "int", "access", ";", "private", "String", "name", ";", "private", "String", "desc", ";", "private", "Object", "value", ";", "public", "AsmFieldVisitor", "(", "int", "access", ",", "String", "name", ",", "String", "desc", ",", "Object", "value", ")", "{", "this", ".", "access", "=", "access", ";", "this", ".", "name", "=", "name", ";", "this", ".", "desc", "=", "desc", ";", "this", ".", "value", "=", "value", ";", "}", "public", "AnnotationVisitor", "visitAnnotation", "(", "String", "desc", ",", "boolean", "visible", ")", "{", "return", "new", "AsmAnnotationVisitor", "(", ")", ";", "}", "public", "void", "visitAttribute", "(", "Attribute", "attr", ")", "{", "}", "public", "void", "visitEnd", "(", ")", "{", "writer", ".", "print", "(", "INDENT", ")", ";", "writer", ".", "print", "(", "getAccess", "(", "access", ")", ")", ";", "writer", ".", "print", "(", "getDescName", "(", "desc", ")", ")", ";", "writer", ".", "print", "(", "'", "'", ")", ";", "writer", ".", "print", "(", "name", ")", ";", "if", "(", "value", "!=", "null", ")", "{", "writer", ".", "print", "(", "\"", "=", "\"", ")", ";", "writer", ".", "print", "(", "getValueString", "(", "value", ")", ")", ";", "}", "writer", ".", "print", "(", "\";n\"", ")", ";", "}", "}", "}", "}", "</s>" ]
1,234
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "src", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "eclim", ".", "Services", ";", "import", "org", ".", "eclim", ".", "annotation", ".", "Command", ";", "import", "org", ".", "eclim", ".", "command", ".", "CommandLine", ";", "import", "org", ".", "eclim", ".", "command", ".", "Error", ";", "import", "org", ".", "eclim", ".", "command", ".", "Options", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "command", ".", "AbstractCommand", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "util", ".", "ProjectUtils", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "util", ".", "JavaUtils", ";", "import", "org", ".", "eclim", ".", "util", ".", "file", ".", "FileOffsets", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "IProject", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "IncrementalProjectBuilder", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "NullProgressMonitor", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "ICompilationUnit", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IJavaProject", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "compiler", ".", "IProblem", ";", "@", "Command", "(", "name", "=", "\"\"", ",", "options", "=", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", ")", "public", "class", "SrcUpdateCommand", "extends", "AbstractCommand", "{", "@", "Override", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "Object", "execute", "(", "CommandLine", "commandLine", ")", "throws", "Exception", "{", "String", "file", "=", "commandLine", ".", "getValue", "(", "Options", ".", "FILE_OPTION", ")", ";", "String", "projectName", "=", "commandLine", ".", "getValue", "(", "Options", ".", "PROJECT_OPTION", ")", ";", "IProject", "project", "=", "ProjectUtils", ".", "getProject", "(", "projectName", ")", ";", "if", "(", "!", "commandLine", ".", "hasOption", "(", "Options", ".", "VALIDATE_OPTION", ")", ")", "{", "ProjectUtils", ".", "getFile", "(", "project", ",", "file", ")", ";", "}", "else", "{", "IJavaProject", "javaProject", "=", "JavaUtils", ".", "getJavaProject", "(", "project", ")", ";", "ICompilationUnit", "src", "=", "JavaUtils", ".", "getCompilationUnit", "(", "javaProject", ",", "file", ")", ";", "IProblem", "[", "]", "problems", "=", "JavaUtils", ".", "getProblems", "(", "src", ")", ";", "ArrayList", "<", "Error", ">", "errors", "=", "new", "ArrayList", "<", "Error", ">", "(", ")", ";", "String", "filename", "=", "src", ".", "getResource", "(", ")", ".", "getLocation", "(", ")", ".", "toOSString", "(", ")", ".", "replace", "(", "'\\\\'", ",", "'/'", ")", ";", "FileOffsets", "offsets", "=", "FileOffsets", ".", "compile", "(", "filename", ")", ";", "for", "(", "int", "ii", "=", "0", ";", "ii", "<", "problems", ".", "length", ";", "ii", "++", ")", "{", "int", "[", "]", "lineColumn", "=", "offsets", ".", "offsetToLineColumn", "(", "problems", "[", "ii", "]", ".", "getSourceStart", "(", ")", ")", ";", "errors", ".", "add", "(", "new", "Error", "(", "problems", "[", "ii", "]", ".", "getMessage", "(", ")", ",", "filename", ",", "lineColumn", "[", "0", "]", ",", "lineColumn", "[", "1", "]", ",", "problems", "[", "ii", "]", ".", "isWarning", "(", ")", ")", ")", ";", "}", "boolean", "checkstyle", "=", "\"true\"", ".", "equals", "(", "getPreferences", "(", ")", ".", "getValue", "(", "project", ",", "\"\"", ")", ")", ";", "if", "(", "checkstyle", ")", "{", "errors", ".", "addAll", "(", "(", "List", "<", "Error", ">", ")", "Services", ".", "getCommand", "(", "\"\"", ")", ".", "execute", "(", "commandLine", ")", ")", ";", "}", "if", "(", "commandLine", ".", "hasOption", "(", "Options", ".", "BUILD_OPTION", ")", ")", "{", "project", ".", "build", "(", "IncrementalProjectBuilder", ".", "INCREMENTAL_BUILD", ",", "new", "NullProgressMonitor", "(", ")", ")", ";", "}", "return", "errors", ";", "}", "return", "null", ";", "}", "}", "</s>" ]
1,235
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "src", ";", "import", "java", ".", "text", ".", "Collator", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Collections", ";", "import", "org", ".", "eclim", ".", "annotation", ".", "Command", ";", "import", "org", ".", "eclim", ".", "command", ".", "CommandLine", ";", "import", "org", ".", "eclim", ".", "command", ".", "Options", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "command", ".", "AbstractCommand", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "util", ".", "JavaUtils", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IJavaProject", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IPackageFragment", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IPackageFragmentRoot", ";", "@", "Command", "(", "name", "=", "\"\"", ",", "options", "=", "\"\"", "+", "\"\"", ")", "public", "class", "CompletePackageCommand", "extends", "AbstractCommand", "{", "@", "Override", "public", "Object", "execute", "(", "CommandLine", "commandLine", ")", "throws", "Exception", "{", "String", "project", "=", "commandLine", ".", "getValue", "(", "Options", ".", "PROJECT_OPTION", ")", ";", "String", "name", "=", "commandLine", ".", "getValue", "(", "Options", ".", "NAME_OPTION", ")", ";", "IJavaProject", "javaProject", "=", "JavaUtils", ".", "getJavaProject", "(", "project", ")", ";", "IPackageFragment", "[", "]", "packs", "=", "javaProject", ".", "getPackageFragments", "(", ")", ";", "ArrayList", "<", "String", ">", "results", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "for", "(", "IPackageFragment", "pack", ":", "packs", ")", "{", "if", "(", "pack", ".", "getKind", "(", ")", "!=", "IPackageFragmentRoot", ".", "K_SOURCE", ")", "{", "continue", ";", "}", "String", "packName", "=", "pack", ".", "getElementName", "(", ")", ";", "if", "(", "packName", ".", "length", "(", ")", ">", "0", "&&", "!", "results", ".", "contains", "(", "packName", ")", "&&", "(", "name", "==", "null", "||", "packName", ".", "startsWith", "(", "name", ")", ")", ")", "{", "results", ".", "add", "(", "packName", ")", ";", "}", "}", "Collections", ".", "sort", "(", "results", ",", "Collator", ".", "getInstance", "(", ")", ")", ";", "return", "results", ";", "}", "}", "</s>" ]
1,236
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "include", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Collections", ";", "import", "org", ".", "eclim", ".", "annotation", ".", "Command", ";", "import", "org", ".", "eclim", ".", "command", ".", "CommandLine", ";", "import", "org", ".", "eclim", ".", "command", ".", "Options", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "command", ".", "AbstractCommand", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "util", ".", "ProjectUtils", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "util", ".", "JavaUtils", ";", "import", "org", ".", "eclim", ".", "util", ".", "file", ".", "Position", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "IProject", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "IStatus", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "OperationCanceledException", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "ICompilationUnit", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "dom", ".", "ASTNode", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "dom", ".", "CompilationUnit", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "dom", ".", "ImportDeclaration", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "dom", ".", "NodeFinder", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "dom", ".", "rewrite", ".", "ImportRewrite", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "dom", ".", "rewrite", ".", "ImportRewrite", ".", "ImportRewriteContext", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "search", ".", "TypeNameMatch", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "corext", ".", "codemanipulation", ".", "AddImportsOperation", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "corext", ".", "codemanipulation", ".", "CodeGenerationMessages", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "corext", ".", "codemanipulation", ".", "ContextSensitiveImportRewriteContext", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "corext", ".", "codemanipulation", ".", "StubUtility", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "corext", ".", "util", ".", "JavaModelUtil", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "ui", ".", "SharedASTProvider", ";", "import", "org", ".", "eclipse", ".", "text", ".", "edits", ".", "InsertEdit", ";", "import", "org", ".", "eclipse", ".", "text", ".", "edits", ".", "MultiTextEdit", ";", "import", "org", ".", "eclipse", ".", "text", ".", "edits", ".", "TextEdit", ";", "@", "Command", "(", "name", "=", "\"java_import\"", ",", "options", "=", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", ")", "public", "class", "ImportCommand", "extends", "AbstractCommand", "{", "@", "Override", "public", "Object", "execute", "(", "CommandLine", "commandLine", ")", "throws", "Exception", "{", "String", "file", "=", "commandLine", ".", "getValue", "(", "Options", ".", "FILE_OPTION", ")", ";", "String", "projectName", "=", "commandLine", ".", "getValue", "(", "Options", ".", "PROJECT_OPTION", ")", ";", "String", "type", "=", "commandLine", ".", "getValue", "(", "Options", ".", "TYPE_OPTION", ")", ";", "int", "offset", "=", "getOffset", "(", "commandLine", ")", ";", "ICompilationUnit", "src", "=", "JavaUtils", ".", "getCompilationUnit", "(", "projectName", ",", "file", ")", ";", "IProject", "project", "=", "src", ".", "getJavaProject", "(", ")", ".", "getProject", "(", ")", ";", "TextEdit", "edits", "=", "null", ";", "int", "oldLength", "=", "src", ".", "getBuffer", "(", ")", ".", "getLength", "(", ")", ";", "if", "(", "type", "!=", "null", ")", "{", "CompilationUnit", "astRoot", "=", "SharedASTProvider", ".", "getAST", "(", "src", ",", "SharedASTProvider", ".", "WAIT_YES", ",", "null", ")", ";", "edits", "=", "new", "MultiTextEdit", "(", ")", ";", "ImportRewrite", "importRewrite", "=", "StubUtility", ".", "createImportRewrite", "(", "astRoot", ",", "true", ")", ";", "ImportRewriteContext", "context", "=", "new", "ContextSensitiveImportRewriteContext", "(", "astRoot", ",", "offset", ",", "importRewrite", ")", ";", "String", "res", "=", "importRewrite", ".", "addImport", "(", "type", ",", "context", ")", ";", "if", "(", "type", ".", "equals", "(", "res", ")", ")", "{", "return", "CodeGenerationMessages", ".", "AddImportsOperation_error_importclash", ";", "}", "TextEdit", "rewrite", "=", "importRewrite", ".", "rewriteImports", "(", "null", ")", ";", "edits", ".", "addChild", "(", "rewrite", ")", ";", "JavaModelUtil", ".", "applyEdit", "(", "src", ",", "edits", ",", "true", ",", "null", ")", ";", "if", "(", "src", ".", "isWorkingCopy", "(", ")", ")", "{", "src", ".", "commitWorkingCopy", "(", "false", ",", "null", ")", ";", "}", "}", "else", "{", "ChooseImport", "query", "=", "new", "ChooseImport", "(", "project", ",", "type", ")", ";", "try", "{", "AddImportsOperation", "op", "=", "new", "AddImportsOperation", "(", "src", ",", "offset", ",", "1", ",", "query", ",", "true", ",", "true", ")", ";", "op", ".", "run", "(", "null", ")", ";", "edits", "=", "op", ".", "getResultingEdit", "(", ")", ";", "if", "(", "edits", "==", "null", ")", "{", "IStatus", "status", "=", "op", ".", "getStatus", "(", ")", ";", "return", "status", ".", "getSeverity", "(", ")", "!=", "IStatus", ".", "OK", "?", "status", ".", "getMessage", "(", ")", ":", "null", ";", "}", "}", "catch", "(", "OperationCanceledException", "oce", ")", "{", "return", "query", ".", "choices", ";", "}", "}", "TextEdit", "groupingEdit", "=", "importGroupingEdit", "(", "src", ",", "edits", ".", "getOffset", "(", ")", ")", ";", "if", "(", "groupingEdit", "!=", "null", ")", "{", "JavaModelUtil", ".", "applyEdit", "(", "src", ",", "groupingEdit", ",", "true", ",", "null", ")", ";", "if", "(", "src", ".", "isWorkingCopy", "(", ")", ")", "{", "src", ".", "commitWorkingCopy", "(", "false", ",", "null", ")", ";", "}", "}", "if", "(", "edits", ".", "getOffset", "(", ")", "<", "offset", ")", "{", "offset", "+=", "src", ".", "getBuffer", "(", ")", ".", "getLength", "(", ")", "-", "oldLength", ";", "}", "return", "Position", ".", "fromOffset", "(", "ProjectUtils", ".", "getFilePath", "(", "projectName", ",", "file", ")", ",", "null", ",", "offset", ",", "0", ")", ";", "}", "private", "TextEdit", "importGroupingEdit", "(", "ICompilationUnit", "src", ",", "int", "offset", ")", "throws", "Exception", "{", "int", "separationLevel", "=", "getPreferences", "(", ")", ".", "getIntValue", "(", "src", ".", "getJavaProject", "(", ")", ".", "getProject", "(", ")", ",", "\"\"", ")", ";", "String", "lineDelim", "=", "src", ".", "findRecommendedLineSeparator", "(", ")", ";", "CompilationUnit", "astRoot", "=", "SharedASTProvider", ".", "getAST", "(", "src", ",", "SharedASTProvider", ".", "WAIT_YES", ",", "null", ")", ";", "ASTNode", "node", "=", "NodeFinder", ".", "perform", "(", "astRoot", ",", "offset", ",", "1", ")", ";", "MultiTextEdit", "edit", "=", "new", "MultiTextEdit", "(", ")", ";", "if", "(", "node", "!=", "null", "&&", "node", ".", "getNodeType", "(", ")", "==", "ASTNode", ".", "IMPORT_DECLARATION", ")", "{", "ImportDeclaration", "imprt", "=", "(", "ImportDeclaration", ")", "node", ";", "int", "end", "=", "node", ".", "getStartPosition", "(", ")", "+", "node", ".", "getLength", "(", ")", "+", "lineDelim", ".", "length", "(", ")", ";", "ASTNode", "next", "=", "NodeFinder", ".", "perform", "(", "astRoot", ",", "end", ",", "1", ")", ";", "if", "(", "next", "!=", "null", "&&", "next", ".", "getNodeType", "(", ")", "==", "ASTNode", ".", "IMPORT_DECLARATION", ")", "{", "ImportDeclaration", "nextImprt", "=", "(", "ImportDeclaration", ")", "next", ";", "if", "(", "!", "ImportUtils", ".", "importsInSameGroup", "(", "separationLevel", ",", "imprt", ",", "nextImprt", ")", ")", "{", "edit", ".", "addChild", "(", "new", "InsertEdit", "(", "end", ",", "lineDelim", ")", ")", ";", "}", "}", "ASTNode", "prev", "=", "NodeFinder", ".", "perform", "(", "astRoot", ",", "offset", "-", "(", "lineDelim", ".", "length", "(", ")", "+", "1", ")", ",", "1", ")", ";", "if", "(", "prev", "!=", "null", "&&", "prev", ".", "getNodeType", "(", ")", "==", "ASTNode", ".", "IMPORT_DECLARATION", ")", "{", "ImportDeclaration", "prevImprt", "=", "(", "ImportDeclaration", ")", "prev", ";", "if", "(", "!", "ImportUtils", ".", "importsInSameGroup", "(", "separationLevel", ",", "imprt", ",", "prevImprt", ")", ")", "{", "end", "=", "prev", ".", "getStartPosition", "(", ")", "+", "prev", ".", "getLength", "(", ")", "+", "lineDelim", ".", "length", "(", ")", ";", "edit", ".", "addChild", "(", "new", "InsertEdit", "(", "end", ",", "lineDelim", ")", ")", ";", "}", "}", "}", "return", "edit", ".", "getChildrenSize", "(", ")", ">", "0", "?", "edit", ":", "null", ";", "}", "private", "class", "ChooseImport", "implements", "AddImportsOperation", ".", "IChooseImportQuery", "{", "public", "ArrayList", "<", "String", ">", "choices", ";", "private", "IProject", "project", ";", "private", "String", "type", ";", "public", "ChooseImport", "(", "IProject", "project", ",", "String", "type", ")", "{", "this", ".", "project", "=", "project", ";", "this", ".", "type", "=", "type", ";", "}", "@", "Override", "public", "TypeNameMatch", "chooseImport", "(", "TypeNameMatch", "[", "]", "choices", ",", "String", "name", ")", "{", "if", "(", "type", "!=", "null", ")", "{", "for", "(", "TypeNameMatch", "match", ":", "choices", ")", "{", "if", "(", "type", ".", "equals", "(", "match", ".", "getFullyQualifiedName", "(", ")", ")", ")", "{", "return", "match", ";", "}", "}", "}", "if", "(", "this", ".", "choices", "==", "null", ")", "{", "try", "{", "this", ".", "choices", "=", "new", "ArrayList", "<", "String", ">", "(", "choices", ".", "length", ")", ";", "for", "(", "TypeNameMatch", "match", ":", "choices", ")", "{", "String", "fqn", "=", "match", ".", "getFullyQualifiedName", "(", ")", ";", "if", "(", "!", "ImportUtils", ".", "isImportExcluded", "(", "project", ",", "fqn", ")", "&&", "!", "this", ".", "choices", ".", "contains", "(", "fqn", ")", ")", "{", "this", ".", "choices", ".", "add", "(", "fqn", ")", ";", "}", "}", "if", "(", "this", ".", "choices", ".", "size", "(", ")", "==", "1", ")", "{", "type", "=", "this", ".", "choices", ".", "get", "(", "0", ")", ";", "return", "chooseImport", "(", "choices", ",", "name", ")", ";", "}", "Collections", ".", "sort", "(", "this", ".", "choices", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "}", "return", "null", ";", "}", "}", "}", "</s>" ]
1,237
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "include", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Collections", ";", "import", "java", ".", "util", ".", "HashSet", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang", ".", "StringUtils", ";", "import", "org", ".", "eclim", ".", "annotation", ".", "Command", ";", "import", "org", ".", "eclim", ".", "command", ".", "CommandLine", ";", "import", "org", ".", "eclim", ".", "command", ".", "Options", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "command", ".", "AbstractCommand", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "util", ".", "ProjectUtils", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "util", ".", "JavaUtils", ";", "import", "org", ".", "eclim", ".", "util", ".", "file", ".", "Position", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "IProject", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "ICompilationUnit", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "ISourceRange", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "dom", ".", "CompilationUnit", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "dom", ".", "ImportDeclaration", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "search", ".", "TypeNameMatch", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "corext", ".", "codemanipulation", ".", "CodeGenerationSettings", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "corext", ".", "codemanipulation", ".", "OrganizeImportsOperation", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "corext", ".", "util", ".", "JavaModelUtil", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "ui", ".", "preferences", ".", "JavaPreferencesSettings", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "ui", ".", "SharedASTProvider", ";", "import", "org", ".", "eclipse", ".", "text", ".", "edits", ".", "InsertEdit", ";", "import", "org", ".", "eclipse", ".", "text", ".", "edits", ".", "MultiTextEdit", ";", "import", "org", ".", "eclipse", ".", "text", ".", "edits", ".", "TextEdit", ";", "@", "Command", "(", "name", "=", "\"\"", ",", "options", "=", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", ")", "public", "class", "ImportOrganizeCommand", "extends", "AbstractCommand", "{", "@", "Override", "public", "Object", "execute", "(", "CommandLine", "commandLine", ")", "throws", "Exception", "{", "String", "file", "=", "commandLine", ".", "getValue", "(", "Options", ".", "FILE_OPTION", ")", ";", "String", "projectName", "=", "commandLine", ".", "getValue", "(", "Options", ".", "PROJECT_OPTION", ")", ";", "String", "types", "=", "commandLine", ".", "getValue", "(", "Options", ".", "TYPE_OPTION", ")", ";", "int", "offset", "=", "getOffset", "(", "commandLine", ")", ";", "ICompilationUnit", "src", "=", "JavaUtils", ".", "getCompilationUnit", "(", "projectName", ",", "file", ")", ";", "IProject", "project", "=", "src", ".", "getJavaProject", "(", ")", ".", "getProject", "(", ")", ";", "int", "oldLength", "=", "src", ".", "getBuffer", "(", ")", ".", "getLength", "(", ")", ";", "CompilationUnit", "astRoot", "=", "SharedASTProvider", ".", "getAST", "(", "src", ",", "SharedASTProvider", ".", "WAIT_YES", ",", "null", ")", ";", "String", "[", "]", "typeNames", "=", "types", "!=", "null", "?", "StringUtils", ".", "split", "(", "types", ",", "','", ")", ":", "null", ";", "ChooseImports", "query", "=", "new", "ChooseImports", "(", "project", ",", "typeNames", ")", ";", "CodeGenerationSettings", "settings", "=", "JavaPreferencesSettings", ".", "getCodeGenerationSettings", "(", "src", ".", "getJavaProject", "(", ")", ")", ";", "OrganizeImportsOperation", "op", "=", "new", "OrganizeImportsOperation", "(", "src", ",", "astRoot", ",", "settings", ".", "importIgnoreLowercase", ",", "true", ",", "true", ",", "query", ")", ";", "TextEdit", "edit", "=", "op", ".", "createTextEdit", "(", "null", ")", ";", "if", "(", "query", ".", "choices", "!=", "null", "&&", "query", ".", "choices", ".", "size", "(", ")", ">", "0", ")", "{", "return", "query", ".", "choices", ";", "}", "if", "(", "edit", "!=", "null", ")", "{", "JavaModelUtil", ".", "applyEdit", "(", "src", ",", "edit", ",", "true", ",", "null", ")", ";", "if", "(", "src", ".", "isWorkingCopy", "(", ")", ")", "{", "src", ".", "commitWorkingCopy", "(", "false", ",", "null", ")", ";", "}", "}", "TextEdit", "groupingEdit", "=", "importGroupingEdit", "(", "src", ")", ";", "if", "(", "groupingEdit", "!=", "null", ")", "{", "if", "(", "edit", "==", "null", ")", "{", "edit", "=", "groupingEdit", ";", "}", "JavaModelUtil", ".", "applyEdit", "(", "src", ",", "groupingEdit", ",", "true", ",", "null", ")", ";", "if", "(", "src", ".", "isWorkingCopy", "(", ")", ")", "{", "src", ".", "commitWorkingCopy", "(", "false", ",", "null", ")", ";", "}", "}", "if", "(", "edit", "!=", "null", ")", "{", "if", "(", "edit", ".", "getOffset", "(", ")", "<", "offset", ")", "{", "offset", "+=", "src", ".", "getBuffer", "(", ")", ".", "getLength", "(", ")", "-", "oldLength", ";", "}", "return", "Position", ".", "fromOffset", "(", "ProjectUtils", ".", "getFilePath", "(", "projectName", ",", "file", ")", ",", "null", ",", "offset", ",", "0", ")", ";", "}", "return", "null", ";", "}", "private", "TextEdit", "importGroupingEdit", "(", "ICompilationUnit", "src", ")", "throws", "Exception", "{", "int", "separationLevel", "=", "getPreferences", "(", ")", ".", "getIntValue", "(", "src", ".", "getJavaProject", "(", ")", ".", "getProject", "(", ")", ",", "\"\"", ")", ";", "CompilationUnit", "astRoot", "=", "SharedASTProvider", ".", "getAST", "(", "src", ",", "SharedASTProvider", ".", "WAIT_YES", ",", "null", ")", ";", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "List", "<", "ImportDeclaration", ">", "imports", "=", "astRoot", ".", "imports", "(", ")", ";", "String", "lineDelim", "=", "src", ".", "findRecommendedLineSeparator", "(", ")", ";", "MultiTextEdit", "edit", "=", "new", "MultiTextEdit", "(", ")", ";", "ImportDeclaration", "next", "=", "null", ";", "for", "(", "int", "i", "=", "imports", ".", "size", "(", ")", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "ImportDeclaration", "imprt", "=", "imports", ".", "get", "(", "i", ")", ";", "int", "end", "=", "imprt", ".", "getStartPosition", "(", ")", "+", "imprt", ".", "getLength", "(", ")", "+", "lineDelim", ".", "length", "(", ")", ";", "if", "(", "next", "!=", "null", "&&", "end", "==", "next", ".", "getStartPosition", "(", ")", "&&", "!", "ImportUtils", ".", "importsInSameGroup", "(", "separationLevel", ",", "imprt", ",", "next", ")", ")", "{", "edit", ".", "addChild", "(", "new", "InsertEdit", "(", "end", ",", "lineDelim", ")", ")", ";", "}", "next", "=", "imprt", ";", "}", "return", "edit", ".", "getChildrenSize", "(", ")", ">", "0", "?", "edit", ":", "null", ";", "}", "private", "class", "ChooseImports", "implements", "OrganizeImportsOperation", ".", "IChooseImportQuery", "{", "public", "ArrayList", "<", "ArrayList", "<", "String", ">", ">", "choices", ";", "private", "IProject", "project", ";", "private", "HashSet", "<", "String", ">", "types", ";", "public", "ChooseImports", "(", "IProject", "project", ",", "String", "[", "]", "types", ")", "{", "this", ".", "project", "=", "project", ";", "if", "(", "types", "!=", "null", ")", "{", "this", ".", "types", "=", "new", "HashSet", "<", "String", ">", "(", "types", ".", "length", ")", ";", "for", "(", "String", "type", ":", "types", ")", "{", "this", ".", "types", ".", "add", "(", "type", ")", ";", "}", "}", "}", "public", "TypeNameMatch", "[", "]", "chooseImports", "(", "TypeNameMatch", "[", "]", "[", "]", "choices", ",", "ISourceRange", "[", "]", "ranges", ")", "{", "ArrayList", "<", "TypeNameMatch", ">", "chosen", "=", "new", "ArrayList", "<", "TypeNameMatch", ">", "(", ")", ";", "this", ".", "choices", "=", "new", "ArrayList", "<", "ArrayList", "<", "String", ">", ">", "(", ")", ";", "try", "{", "for", "(", "TypeNameMatch", "[", "]", "matches", ":", "choices", ")", "{", "boolean", "foundChoice", "=", "false", ";", "if", "(", "types", "!=", "null", "&&", "types", ".", "size", "(", ")", ">", "0", ")", "{", "for", "(", "TypeNameMatch", "match", ":", "matches", ")", "{", "if", "(", "types", ".", "contains", "(", "match", ".", "getFullyQualifiedName", "(", ")", ")", ")", "{", "foundChoice", "=", "true", ";", "chosen", ".", "add", "(", "match", ")", ";", "break", ";", "}", "}", "}", "if", "(", "!", "foundChoice", ")", "{", "ArrayList", "<", "String", ">", "names", "=", "new", "ArrayList", "<", "String", ">", "(", "matches", ".", "length", ")", ";", "for", "(", "TypeNameMatch", "match", ":", "matches", ")", "{", "String", "name", "=", "match", ".", "getFullyQualifiedName", "(", ")", ";", "if", "(", "!", "ImportUtils", ".", "isImportExcluded", "(", "project", ",", "name", ")", ")", "{", "names", ".", "add", "(", "name", ")", ";", "}", "}", "if", "(", "names", ".", "size", "(", ")", "==", "1", ")", "{", "for", "(", "TypeNameMatch", "match", ":", "matches", ")", "{", "if", "(", "names", ".", "get", "(", "0", ")", ".", "equals", "(", "match", ".", "getFullyQualifiedName", "(", ")", ")", ")", "{", "chosen", ".", "add", "(", "match", ")", ";", "break", ";", "}", "}", "}", "else", "if", "(", "names", ".", "size", "(", ")", ">", "0", ")", "{", "Collections", ".", "sort", "(", "names", ")", ";", "this", ".", "choices", ".", "add", "(", "names", ")", ";", "}", "}", "}", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "return", "chosen", ".", "toArray", "(", "new", "TypeNameMatch", "[", "chosen", ".", "size", "(", ")", "]", ")", ";", "}", "}", "}", "</s>" ]
1,238
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "include", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang", ".", "StringUtils", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "preference", ".", "Preferences", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "IProject", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "dom", ".", "ImportDeclaration", ";", "public", "class", "ImportUtils", "{", "public", "static", "boolean", "importsInSameGroup", "(", "int", "separationLevel", ",", "ImportDeclaration", "i1", ",", "ImportDeclaration", "i2", ")", "{", "if", "(", "separationLevel", "==", "0", ")", "{", "return", "true", ";", "}", "List", "<", "String", ">", "pn1", "=", "packageName", "(", "i1", ")", ";", "List", "<", "String", ">", "pn2", "=", "packageName", "(", "i2", ")", ";", "for", "(", "int", "i", "=", "0", ";", "(", "i", "<", "separationLevel", "||", "separationLevel", "==", "-", "1", ")", ";", "i", "++", ")", "{", "int", "level", "=", "i", "+", "1", ";", "if", "(", "pn1", ".", "size", "(", ")", "<", "level", ")", "{", "return", "pn2", ".", "size", "(", ")", "<", "level", ";", "}", "if", "(", "pn2", ".", "size", "(", ")", "<", "level", ")", "{", "return", "pn1", ".", "size", "(", ")", "<", "level", ";", "}", "if", "(", "!", "pn1", ".", "get", "(", "i", ")", ".", "equals", "(", "pn2", ".", "get", "(", "i", ")", ")", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}", "public", "static", "List", "<", "String", ">", "packageName", "(", "ImportDeclaration", "imprt", ")", "{", "String", "name", "=", "imprt", ".", "getName", "(", ")", ".", "getFullyQualifiedName", "(", ")", ";", "List", "<", "String", ">", "pack", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "for", "(", "String", "part", ":", "StringUtils", ".", "split", "(", "name", ",", "'.'", ")", ")", "{", "if", "(", "Character", ".", "isUpperCase", "(", "part", ".", "charAt", "(", "0", ")", ")", ")", "{", "break", ";", "}", "pack", ".", "add", "(", "part", ")", ";", "}", "return", "pack", ";", "}", "public", "static", "boolean", "isImportExcluded", "(", "IProject", "project", ",", "String", "name", ")", "throws", "Exception", "{", "String", "[", "]", "patterns", "=", "Preferences", ".", "getInstance", "(", ")", ".", "getArrayValue", "(", "project", ",", "\"\"", ")", ";", "for", "(", "String", "pattern", ":", "patterns", ")", "{", "if", "(", "name", ".", "matches", "(", "pattern", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}", "}", "</s>" ]
1,239
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "refactoring", ";", "import", "java", ".", "lang", ".", "reflect", ".", "Field", ";", "import", "org", ".", "eclim", ".", "Services", ";", "import", "org", ".", "eclim", ".", "annotation", ".", "Command", ";", "import", "org", ".", "eclim", ".", "command", ".", "CommandLine", ";", "import", "org", ".", "eclim", ".", "command", ".", "Options", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "command", ".", "refactoring", ".", "AbstractRefactorCommand", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "command", ".", "refactoring", ".", "Refactor", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "command", ".", "refactoring", ".", "RefactorException", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "util", ".", "JavaUtils", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "ICompilationUnit", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IField", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IJavaElement", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "ILocalVariable", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IMember", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IMethod", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IPackageFragment", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IType", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "ITypeParameter", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "corext", ".", "refactoring", ".", "rename", ".", "JavaRenameProcessor", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "corext", ".", "refactoring", ".", "rename", ".", "MethodChecks", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "corext", ".", "refactoring", ".", "rename", ".", "RenameEnumConstProcessor", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "corext", ".", "refactoring", ".", "rename", ".", "RenameFieldProcessor", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "corext", ".", "refactoring", ".", "rename", ".", "RenameLocalVariableProcessor", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "corext", ".", "refactoring", ".", "rename", ".", "RenameNonVirtualMethodProcessor", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "corext", ".", "refactoring", ".", "rename", ".", "RenamePackageProcessor", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "corext", ".", "refactoring", ".", "rename", ".", "RenameTypeParameterProcessor", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "corext", ".", "refactoring", ".", "rename", ".", "RenameTypeProcessor", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "corext", ".", "refactoring", ".", "rename", ".", "RenameVirtualMethodProcessor", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "corext", ".", "refactoring", ".", "tagging", ".", "IReferenceUpdating", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "corext", ".", "refactoring", ".", "tagging", ".", "ITextUpdating", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "corext", ".", "util", ".", "JdtFlags", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "ui", ".", "refactoring", ".", "RenameSupport", ";", "import", "org", ".", "eclipse", ".", "ltk", ".", "core", ".", "refactoring", ".", "Refactoring", ";", "import", "org", ".", "eclipse", ".", "ltk", ".", "core", ".", "refactoring", ".", "participants", ".", "RenameRefactoring", ";", "@", "Command", "(", "name", "=", "\"\"", ",", "options", "=", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", ")", "public", "class", "RenameCommand", "extends", "AbstractRefactorCommand", "{", "@", "Override", "public", "Refactor", "createRefactoring", "(", "CommandLine", "commandLine", ")", "throws", "Exception", "{", "String", "project", "=", "commandLine", ".", "getValue", "(", "Options", ".", "PROJECT_OPTION", ")", ";", "String", "file", "=", "commandLine", ".", "getValue", "(", "Options", ".", "FILE_OPTION", ")", ";", "String", "name", "=", "commandLine", ".", "getValue", "(", "Options", ".", "NAME_OPTION", ")", ";", "int", "offset", "=", "getOffset", "(", "commandLine", ")", ";", "int", "length", "=", "commandLine", ".", "getIntValue", "(", "Options", ".", "LENGTH_OPTION", ")", ";", "int", "flags", "=", "RenameSupport", ".", "UPDATE_REFERENCES", ";", "ICompilationUnit", "src", "=", "JavaUtils", ".", "getCompilationUnit", "(", "project", ",", "file", ")", ";", "IJavaElement", "[", "]", "elements", "=", "src", ".", "codeSelect", "(", "offset", ",", "length", ")", ";", "if", "(", "elements", "==", "null", "||", "elements", ".", "length", "==", "0", ")", "{", "throw", "new", "RefactorException", "(", ")", ";", "}", "IJavaElement", "element", "=", "elements", "[", "0", "]", ";", "if", "(", "element", "instanceof", "IMember", ")", "{", "ICompilationUnit", "cu", "=", "(", "(", "IMember", ")", "element", ")", ".", "getCompilationUnit", "(", ")", ";", "if", "(", "cu", "==", "null", ")", "{", "throw", "new", "RefactorException", "(", "Services", ".", "getMessage", "(", "\"\"", ",", "element", ".", "getElementName", "(", ")", ")", ")", ";", "}", "}", "JavaRenameProcessor", "processor", "=", "getProcessor", "(", "element", ",", "name", ",", "flags", ")", ";", "Refactoring", "refactoring", "=", "new", "RenameRefactoring", "(", "processor", ")", ";", "String", "desc", "=", "refactoring", ".", "getName", "(", ")", "+", "\"", "(\"", "+", "element", ".", "getElementName", "(", ")", "+", "\"", "->", "\"", "+", "name", "+", "')'", ";", "return", "new", "Refactor", "(", "desc", ",", "refactoring", ")", ";", "}", "private", "JavaRenameProcessor", "getProcessor", "(", "IJavaElement", "element", ",", "String", "name", ",", "int", "flags", ")", "throws", "Exception", "{", "JavaRenameProcessor", "processor", ";", "if", "(", "element", "instanceof", "IPackageFragment", ")", "{", "processor", "=", "new", "RenamePackageProcessor", "(", "(", "IPackageFragment", ")", "element", ")", ";", "Field", "renameSubpackages", "=", "RenamePackageProcessor", ".", "class", ".", "getDeclaredField", "(", "\"\"", ")", ";", "renameSubpackages", ".", "setAccessible", "(", "true", ")", ";", "renameSubpackages", ".", "setBoolean", "(", "processor", ",", "true", ")", ";", "}", "else", "if", "(", "element", "instanceof", "IType", ")", "{", "processor", "=", "new", "RenameTypeProcessor", "(", "(", "IType", ")", "element", ")", ";", "}", "else", "if", "(", "element", "instanceof", "IMethod", ")", "{", "IMethod", "method", "=", "(", "IMethod", ")", "element", ";", "if", "(", "MethodChecks", ".", "isVirtual", "(", "method", ")", ")", "{", "processor", "=", "new", "RenameVirtualMethodProcessor", "(", "method", ")", ";", "}", "else", "{", "processor", "=", "new", "RenameNonVirtualMethodProcessor", "(", "method", ")", ";", "}", "}", "else", "if", "(", "element", "instanceof", "IField", ")", "{", "IField", "field", "=", "(", "IField", ")", "element", ";", "if", "(", "JdtFlags", ".", "isEnum", "(", "field", ")", ")", "{", "processor", "=", "new", "RenameEnumConstProcessor", "(", "field", ")", ";", "}", "else", "{", "flags", "|=", "RenameSupport", ".", "UPDATE_GETTER_METHOD", ";", "flags", "|=", "RenameSupport", ".", "UPDATE_SETTER_METHOD", ";", "RenameFieldProcessor", "renameField", "=", "new", "RenameFieldProcessor", "(", "field", ")", ";", "renameField", ".", "setRenameGetter", "(", "(", "flags", "&", "RenameSupport", ".", "UPDATE_GETTER_METHOD", ")", "!=", "0", ")", ";", "renameField", ".", "setRenameSetter", "(", "(", "flags", "&", "RenameSupport", ".", "UPDATE_SETTER_METHOD", ")", "!=", "0", ")", ";", "processor", "=", "renameField", ";", "}", "}", "else", "if", "(", "element", "instanceof", "ITypeParameter", ")", "{", "processor", "=", "new", "RenameTypeParameterProcessor", "(", "(", "ITypeParameter", ")", "element", ")", ";", "}", "else", "if", "(", "element", "instanceof", "ILocalVariable", ")", "{", "processor", "=", "new", "RenameLocalVariableProcessor", "(", "(", "ILocalVariable", ")", "element", ")", ";", "}", "else", "{", "return", "null", ";", "}", "processor", ".", "setNewElementName", "(", "name", ")", ";", "if", "(", "processor", "instanceof", "IReferenceUpdating", ")", "{", "IReferenceUpdating", "reference", "=", "(", "IReferenceUpdating", ")", "processor", ";", "reference", ".", "setUpdateReferences", "(", "(", "flags", "&", "RenameSupport", ".", "UPDATE_REFERENCES", ")", "!=", "0", ")", ";", "}", "if", "(", "processor", "instanceof", "ITextUpdating", ")", "{", "ITextUpdating", "text", "=", "(", "ITextUpdating", ")", "processor", ";", "@", "SuppressWarnings", "(", "\"deprecation\"", ")", "int", "TEXT_UPDATES", "=", "RenameSupport", ".", "UPDATE_TEXTUAL_MATCHES", "|", "RenameSupport", ".", "UPDATE_REGULAR_COMMENTS", "|", "RenameSupport", ".", "UPDATE_STRING_LITERALS", ";", "text", ".", "setUpdateTextualMatches", "(", "(", "flags", "&", "TEXT_UPDATES", ")", "!=", "0", ")", ";", "}", "return", "processor", ";", "}", "}", "</s>" ]
1,240
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "refactoring", ";", "import", "org", ".", "eclim", ".", "Services", ";", "import", "org", ".", "eclim", ".", "annotation", ".", "Command", ";", "import", "org", ".", "eclim", ".", "command", ".", "CommandLine", ";", "import", "org", ".", "eclim", ".", "command", ".", "Options", ";", "import", "org", ".", "eclim", ".", "eclipse", ".", "EclimPlugin", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "command", ".", "refactoring", ".", "AbstractRefactorCommand", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "command", ".", "refactoring", ".", "Refactor", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "command", ".", "refactoring", ".", "RefactorException", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "util", ".", "JavaUtils", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "IResource", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "ICompilationUnit", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IJavaElement", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IPackageFragment", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IPackageFragmentRoot", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "corext", ".", "refactoring", ".", "reorg", ".", "IReorgDestination", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "corext", ".", "refactoring", ".", "reorg", ".", "IReorgPolicy", ".", "IMovePolicy", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "corext", ".", "refactoring", ".", "reorg", ".", "JavaMoveProcessor", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "corext", ".", "refactoring", ".", "reorg", ".", "ReorgDestinationFactory", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "corext", ".", "refactoring", ".", "reorg", ".", "ReorgPolicyFactory", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "corext", ".", "util", ".", "JavaModelUtil", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "ui", ".", "refactoring", ".", "reorg", ".", "CreateTargetQueries", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "ui", ".", "refactoring", ".", "reorg", ".", "ReorgQueries", ";", "import", "org", ".", "eclipse", ".", "ltk", ".", "core", ".", "refactoring", ".", "Refactoring", ";", "import", "org", ".", "eclipse", ".", "ltk", ".", "core", ".", "refactoring", ".", "RefactoringStatus", ";", "import", "org", ".", "eclipse", ".", "ltk", ".", "core", ".", "refactoring", ".", "participants", ".", "MoveRefactoring", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Shell", ";", "@", "Command", "(", "name", "=", "\"\"", ",", "options", "=", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", ")", "public", "class", "MoveCommand", "extends", "AbstractRefactorCommand", "{", "@", "Override", "public", "Refactor", "createRefactoring", "(", "CommandLine", "commandLine", ")", "throws", "Exception", "{", "String", "project", "=", "commandLine", ".", "getValue", "(", "Options", ".", "PROJECT_OPTION", ")", ";", "String", "file", "=", "commandLine", ".", "getValue", "(", "Options", ".", "FILE_OPTION", ")", ";", "String", "packName", "=", "commandLine", ".", "getValue", "(", "Options", ".", "NAME_OPTION", ")", ";", "ICompilationUnit", "src", "=", "JavaUtils", ".", "getCompilationUnit", "(", "project", ",", "file", ")", ";", "IPackageFragmentRoot", "root", "=", "JavaModelUtil", ".", "getPackageFragmentRoot", "(", "src", ")", ";", "IPackageFragment", "pack", "=", "root", ".", "getPackageFragment", "(", "packName", ")", ";", "ICompilationUnit", "dest", "=", "pack", ".", "getCompilationUnit", "(", "src", ".", "getElementName", "(", ")", ")", ";", "if", "(", "dest", ".", "exists", "(", ")", ")", "{", "throw", "new", "RefactorException", "(", "Services", ".", "getMessage", "(", "\"\"", ",", "pack", ".", "getElementName", "(", ")", ",", "src", ".", "getElementName", "(", ")", ")", ")", ";", "}", "if", "(", "!", "pack", ".", "exists", "(", ")", ")", "{", "pack", "=", "root", ".", "createPackageFragment", "(", "packName", ",", "true", ",", "null", ")", ";", "}", "IMovePolicy", "policy", "=", "ReorgPolicyFactory", ".", "createMovePolicy", "(", "new", "IResource", "[", "0", "]", ",", "new", "IJavaElement", "[", "]", "{", "src", "}", ")", ";", "JavaMoveProcessor", "processor", "=", "new", "JavaMoveProcessor", "(", "policy", ")", ";", "IReorgDestination", "destination", "=", "ReorgDestinationFactory", ".", "createDestination", "(", "pack", ")", ";", "RefactoringStatus", "status", "=", "processor", ".", "setDestination", "(", "destination", ")", ";", "if", "(", "status", ".", "hasError", "(", ")", ")", "{", "throw", "new", "RefactorException", "(", "status", ")", ";", "}", "Shell", "shell", "=", "EclimPlugin", ".", "getShell", "(", ")", ";", "processor", ".", "setCreateTargetQueries", "(", "new", "CreateTargetQueries", "(", "shell", ")", ")", ";", "processor", ".", "setReorgQueries", "(", "new", "ReorgQueries", "(", "shell", ")", ")", ";", "Refactoring", "refactoring", "=", "new", "MoveRefactoring", "(", "processor", ")", ";", "String", "desc", "=", "refactoring", ".", "getName", "(", ")", "+", "\"", "(\"", "+", "src", ".", "getElementName", "(", ")", "+", "\"", "->", "\"", "+", "pack", ".", "getElementName", "(", ")", "+", "')'", ";", "return", "new", "Refactor", "(", "desc", ",", "refactoring", ")", ";", "}", "}", "</s>" ]
1,241
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "correct", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Collections", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "HashSet", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "eclim", ".", "Services", ";", "import", "org", ".", "eclim", ".", "annotation", ".", "Command", ";", "import", "org", ".", "eclim", ".", "command", ".", "CommandLine", ";", "import", "org", ".", "eclim", ".", "command", ".", "Options", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "command", ".", "AbstractCommand", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "command", ".", "refactoring", ".", "ResourceChangeListener", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "include", ".", "ImportUtils", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "util", ".", "JavaUtils", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "IProject", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "IWorkspace", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "ResourcesPlugin", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "NullProgressMonitor", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "ICompilationUnit", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "compiler", ".", "IProblem", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "dom", ".", "rewrite", ".", "ImportRewrite", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "formatter", ".", "CodeFormatter", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "refactoring", ".", "CompilationUnitChange", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "ui", ".", "text", ".", "correction", ".", "AssistContext", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "ui", ".", "text", ".", "correction", ".", "CorrectionMessages", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "ui", ".", "text", ".", "correction", ".", "ReorgCorrectionsSubProcessor", ".", "ClasspathFixCorrectionProposal", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "ui", ".", "text", ".", "correction", ".", "proposals", ".", "NewCUUsingWizardProposal", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "ui", ".", "text", ".", "java", ".", "CompletionProposalComparator", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "ui", ".", "text", ".", "java", ".", "IJavaCompletionProposal", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "ui", ".", "text", ".", "java", ".", "IProblemLocation", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "ui", ".", "text", ".", "java", ".", "IQuickFixProcessor", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "ui", ".", "text", ".", "java", ".", "correction", ".", "ASTRewriteCorrectionProposal", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "ui", ".", "text", ".", "java", ".", "correction", ".", "ChangeCorrectionProposal", ";", "import", "org", ".", "eclipse", ".", "ltk", ".", "core", ".", "refactoring", ".", "Change", ";", "import", "org", ".", "eclipse", ".", "ltk", ".", "core", ".", "refactoring", ".", "PerformChangeOperation", ";", "import", "org", ".", "eclipse", ".", "ltk", ".", "core", ".", "refactoring", ".", "RefactoringCore", ";", "import", "org", ".", "eclipse", ".", "ltk", ".", "core", ".", "refactoring", ".", "RefactoringStatus", ";", "import", "org", ".", "eclipse", ".", "ltk", ".", "core", ".", "refactoring", ".", "RefactoringStatusEntry", ";", "import", "org", ".", "eclipse", ".", "ltk", ".", "core", ".", "refactoring", ".", "TextFileChange", ";", "import", "org", ".", "eclipse", ".", "text", ".", "edits", ".", "TextEdit", ";", "@", "Command", "(", "name", "=", "\"java_correct\"", ",", "options", "=", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", ")", "public", "class", "CodeCorrectCommand", "extends", "AbstractCommand", "{", "private", "static", "HashSet", "<", "Class", "<", "?", "extends", "IJavaCompletionProposal", ">", ">", "IGNORE_BY_TYPE", "=", "new", "HashSet", "<", "Class", "<", "?", "extends", "IJavaCompletionProposal", ">", ">", "(", ")", ";", "static", "{", "IGNORE_BY_TYPE", ".", "add", "(", "NewCUUsingWizardProposal", ".", "class", ")", ";", "IGNORE_BY_TYPE", ".", "add", "(", "ClasspathFixCorrectionProposal", ".", "class", ")", ";", "}", "private", "static", "HashSet", "<", "String", ">", "IGNORE_BY_INFO", "=", "new", "HashSet", "<", "String", ">", "(", ")", ";", "static", "{", "IGNORE_BY_INFO", ".", "add", "(", "CorrectionMessages", ".", "LocalCorrectionsSubProcessor_InferGenericTypeArguments_description", ")", ";", "}", "@", "Override", "public", "Object", "execute", "(", "CommandLine", "commandLine", ")", "throws", "Exception", "{", "String", "file", "=", "commandLine", ".", "getValue", "(", "Options", ".", "FILE_OPTION", ")", ";", "String", "projectName", "=", "commandLine", ".", "getValue", "(", "Options", ".", "PROJECT_OPTION", ")", ";", "int", "line", "=", "commandLine", ".", "getIntValue", "(", "Options", ".", "LINE_OPTION", ")", ";", "int", "offset", "=", "getOffset", "(", "commandLine", ")", ";", "ICompilationUnit", "src", "=", "JavaUtils", ".", "getCompilationUnit", "(", "projectName", ",", "file", ")", ";", "IProblem", "problem", "=", "getProblem", "(", "src", ",", "line", ",", "offset", ")", ";", "if", "(", "problem", "==", "null", ")", "{", "String", "message", "=", "Services", ".", "getMessage", "(", "\"\"", ",", "file", ",", "line", ")", ";", "if", "(", "commandLine", ".", "hasOption", "(", "Options", ".", "APPLY_OPTION", ")", ")", "{", "throw", "new", "RuntimeException", "(", "message", ")", ";", "}", "return", "message", ";", "}", "List", "<", "ChangeCorrectionProposal", ">", "proposals", "=", "getProposals", "(", "src", ",", "problem", ")", ";", "if", "(", "commandLine", ".", "hasOption", "(", "Options", ".", "APPLY_OPTION", ")", ")", "{", "ChangeCorrectionProposal", "proposal", "=", "proposals", ".", "get", "(", "commandLine", ".", "getIntValue", "(", "Options", ".", "APPLY_OPTION", ")", ")", ";", "return", "apply", "(", "src", ",", "proposal", ")", ";", "}", "HashMap", "<", "String", ",", "Object", ">", "result", "=", "new", "HashMap", "<", "String", ",", "Object", ">", "(", ")", ";", "result", ".", "put", "(", "\"message\"", ",", "problem", ".", "getMessage", "(", ")", ")", ";", "result", ".", "put", "(", "\"offset\"", ",", "problem", ".", "getSourceStart", "(", ")", ")", ";", "result", ".", "put", "(", "\"corrections\"", ",", "getCorrections", "(", "proposals", ")", ")", ";", "return", "result", ";", "}", "private", "IProblem", "getProblem", "(", "ICompilationUnit", "src", ",", "int", "line", ",", "int", "offset", ")", "throws", "Exception", "{", "IProblem", "[", "]", "problems", "=", "JavaUtils", ".", "getProblems", "(", "src", ")", ";", "ArrayList", "<", "IProblem", ">", "errors", "=", "new", "ArrayList", "<", "IProblem", ">", "(", ")", ";", "for", "(", "int", "ii", "=", "0", ";", "ii", "<", "problems", ".", "length", ";", "ii", "++", ")", "{", "if", "(", "problems", "[", "ii", "]", ".", "getSourceLineNumber", "(", ")", "==", "line", ")", "{", "errors", ".", "add", "(", "problems", "[", "ii", "]", ")", ";", "}", "}", "IProblem", "problem", "=", "null", ";", "if", "(", "errors", ".", "size", "(", ")", "==", "0", ")", "{", "return", "null", ";", "}", "else", "if", "(", "errors", ".", "size", "(", ")", ">", "0", ")", "{", "for", "(", "IProblem", "p", ":", "errors", ")", "{", "if", "(", "offset", "<", "p", ".", "getSourceStart", "(", ")", "&&", "offset", "<=", "p", ".", "getSourceEnd", "(", ")", ")", "{", "problem", "=", "p", ";", "}", "}", "}", "if", "(", "problem", "==", "null", ")", "{", "problem", "=", "(", "IProblem", ")", "errors", ".", "get", "(", "0", ")", ";", "}", "return", "problem", ";", "}", "private", "List", "<", "ChangeCorrectionProposal", ">", "getProposals", "(", "ICompilationUnit", "src", ",", "IProblem", "problem", ")", "throws", "Exception", "{", "IProject", "project", "=", "src", ".", "getJavaProject", "(", ")", ".", "getProject", "(", ")", ";", "ArrayList", "<", "ChangeCorrectionProposal", ">", "results", "=", "new", "ArrayList", "<", "ChangeCorrectionProposal", ">", "(", ")", ";", "int", "length", "=", "(", "problem", ".", "getSourceEnd", "(", ")", "+", "1", ")", "-", "problem", ".", "getSourceStart", "(", ")", ";", "AssistContext", "context", "=", "new", "AssistContext", "(", "src", ",", "problem", ".", "getSourceStart", "(", ")", ",", "length", ")", ";", "IProblemLocation", "[", "]", "locations", "=", "new", "IProblemLocation", "[", "]", "{", "new", "ProblemLocation", "(", "problem", ")", "}", ";", "IQuickFixProcessor", "[", "]", "processors", "=", "JavaUtils", ".", "getQuickFixProcessors", "(", "src", ")", ";", "for", "(", "int", "ii", "=", "0", ";", "ii", "<", "processors", ".", "length", ";", "ii", "++", ")", "{", "if", "(", "processors", "[", "ii", "]", "!=", "null", "&&", "processors", "[", "ii", "]", ".", "hasCorrections", "(", "src", ",", "problem", ".", "getID", "(", ")", ")", ")", "{", "if", "(", "processors", "[", "ii", "]", ".", "getClass", "(", ")", ".", "getName", "(", ")", ".", "equals", "(", "\"\"", ")", ")", "{", "continue", ";", "}", "IJavaCompletionProposal", "[", "]", "proposals", "=", "processors", "[", "ii", "]", ".", "getCorrections", "(", "context", ",", "locations", ")", ";", "if", "(", "proposals", "!=", "null", ")", "{", "for", "(", "IJavaCompletionProposal", "proposal", ":", "proposals", ")", "{", "if", "(", "!", "(", "proposal", "instanceof", "ChangeCorrectionProposal", ")", ")", "{", "continue", ";", "}", "if", "(", "IGNORE_BY_TYPE", ".", "contains", "(", "proposal", ".", "getClass", "(", ")", ")", "||", "IGNORE_BY_INFO", ".", "contains", "(", "proposal", ".", "getAdditionalProposalInfo", "(", ")", ")", ")", "{", "continue", ";", "}", "if", "(", "proposal", "instanceof", "ASTRewriteCorrectionProposal", ")", "{", "ImportRewrite", "rewrite", "=", "(", "(", "ASTRewriteCorrectionProposal", ")", "proposal", ")", ".", "getImportRewrite", "(", ")", ";", "if", "(", "rewrite", "!=", "null", ")", "{", "boolean", "exclude", "=", "true", ";", "for", "(", "String", "fqn", ":", "rewrite", ".", "getAddedImports", "(", ")", ")", "{", "if", "(", "!", "ImportUtils", ".", "isImportExcluded", "(", "project", ",", "fqn", ")", ")", "{", "exclude", "=", "false", ";", "break", ";", "}", "}", "for", "(", "String", "fqn", ":", "rewrite", ".", "getAddedStaticImports", "(", ")", ")", "{", "if", "(", "!", "ImportUtils", ".", "isImportExcluded", "(", "project", ",", "fqn", ")", ")", "{", "exclude", "=", "false", ";", "break", ";", "}", "}", "if", "(", "exclude", ")", "{", "continue", ";", "}", "}", "}", "results", ".", "add", "(", "(", "ChangeCorrectionProposal", ")", "proposal", ")", ";", "}", "}", "}", "}", "Collections", ".", "sort", "(", "results", ",", "new", "CompletionProposalComparator", "(", ")", ")", ";", "return", "results", ";", "}", "private", "List", "<", "CodeCorrectResult", ">", "getCorrections", "(", "List", "<", "ChangeCorrectionProposal", ">", "proposals", ")", "throws", "Exception", "{", "ArrayList", "<", "CodeCorrectResult", ">", "corrections", "=", "new", "ArrayList", "<", "CodeCorrectResult", ">", "(", ")", ";", "int", "index", "=", "0", ";", "for", "(", "ChangeCorrectionProposal", "proposal", ":", "proposals", ")", "{", "String", "preview", "=", "proposal", ".", "getAdditionalProposalInfo", "(", ")", ";", "if", "(", "preview", "!=", "null", ")", "{", "preview", "=", "preview", ".", "replaceAll", "(", "\"<br>\"", ",", "\"n\"", ")", ".", "replaceAll", "(", "\"<.+?>\"", ",", "\"\"", ")", ".", "replaceAll", "(", "\"&lt;\"", ",", "\"<\"", ")", ".", "replaceAll", "(", "\"&gt;\"", ",", "\">\"", ")", ";", "}", "corrections", ".", "add", "(", "new", "CodeCorrectResult", "(", "index", ",", "proposal", ".", "getDisplayString", "(", ")", ",", "preview", ")", ")", ";", "index", "++", ";", "}", "return", "corrections", ";", "}", "private", "Object", "apply", "(", "ICompilationUnit", "src", ",", "ChangeCorrectionProposal", "proposal", ")", "throws", "Exception", "{", "Change", "change", "=", "null", ";", "try", "{", "NullProgressMonitor", "monitor", "=", "new", "NullProgressMonitor", "(", ")", ";", "change", "=", "proposal", ".", "getChange", "(", ")", ";", "change", ".", "initializeValidationData", "(", "monitor", ")", ";", "RefactoringStatus", "status", "=", "change", ".", "isValid", "(", "monitor", ")", ";", "if", "(", "status", ".", "hasFatalError", "(", ")", ")", "{", "List", "<", "String", ">", "errors", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "for", "(", "RefactoringStatusEntry", "entry", ":", "status", ".", "getEntries", "(", ")", ")", "{", "String", "message", "=", "entry", ".", "getMessage", "(", ")", ";", "if", "(", "!", "errors", ".", "contains", "(", "message", ")", "&&", "!", "message", ".", "startsWith", "(", "\"\"", ")", ")", "{", "errors", ".", "add", "(", "message", ")", ";", "}", "}", "HashMap", "<", "String", ",", "List", "<", "String", ">", ">", "result", "=", "new", "HashMap", "<", "String", ",", "List", "<", "String", ">", ">", "(", ")", ";", "result", ".", "put", "(", "\"errors\"", ",", "errors", ")", ";", "return", "result", ";", "}", "ResourceChangeListener", "rcl", "=", "new", "ResourceChangeListener", "(", ")", ";", "IWorkspace", "workspace", "=", "ResourcesPlugin", ".", "getWorkspace", "(", ")", ";", "workspace", ".", "addResourceChangeListener", "(", "rcl", ")", ";", "try", "{", "TextEdit", "edit", "=", "null", ";", "if", "(", "change", "instanceof", "TextFileChange", ")", "{", "TextFileChange", "fileChange", "=", "(", "TextFileChange", ")", "change", ";", "fileChange", ".", "setSaveMode", "(", "TextFileChange", ".", "FORCE_SAVE", ")", ";", "edit", "=", "fileChange", ".", "getEdit", "(", ")", ";", "}", "PerformChangeOperation", "changeOperation", "=", "new", "PerformChangeOperation", "(", "change", ")", ";", "changeOperation", ".", "setUndoManager", "(", "RefactoringCore", ".", "getUndoManager", "(", ")", ",", "proposal", ".", "getName", "(", ")", ")", ";", "changeOperation", ".", "run", "(", "monitor", ")", ";", "if", "(", "edit", "!=", "null", "&&", "change", "instanceof", "CompilationUnitChange", "&&", "src", ".", "equals", "(", "(", "(", "CompilationUnitChange", ")", "change", ")", ".", "getCompilationUnit", "(", ")", ")", ")", "{", "JavaUtils", ".", "format", "(", "src", ",", "CodeFormatter", ".", "K_COMPILATION_UNIT", ",", "edit", ".", "getOffset", "(", ")", ",", "edit", ".", "getLength", "(", ")", ")", ";", "}", "return", "rcl", ".", "getChangedFiles", "(", ")", ";", "}", "finally", "{", "workspace", ".", "removeResourceChangeListener", "(", "rcl", ")", ";", "}", "}", "finally", "{", "if", "(", "change", "!=", "null", ")", "{", "change", ".", "dispose", "(", ")", ";", "}", "}", "}", "}", "</s>" ]
1,242
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "correct", ";", "public", "class", "CodeCorrectResult", "{", "private", "int", "index", ";", "private", "String", "description", ";", "private", "String", "preview", ";", "public", "CodeCorrectResult", "(", "int", "index", ",", "String", "description", ",", "String", "preview", ")", "{", "this", ".", "index", "=", "index", ";", "this", ".", "description", "=", "description", ";", "this", ".", "preview", "=", "preview", ";", "}", "public", "int", "getIndex", "(", ")", "{", "return", "index", ";", "}", "public", "String", "getDescription", "(", ")", "{", "return", "description", ";", "}", "public", "String", "getPreview", "(", ")", "{", "return", "preview", ";", "}", "}", "</s>" ]
1,243
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "correct", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IJavaModelMarker", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "compiler", ".", "IProblem", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "dom", ".", "ASTNode", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "dom", ".", "CompilationUnit", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "dom", ".", "NodeFinder", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "ui", ".", "text", ".", "java", ".", "IProblemLocation", ";", "public", "class", "ProblemLocation", "implements", "IProblemLocation", "{", "private", "int", "id", ";", "private", "int", "offset", ";", "private", "int", "length", ";", "private", "String", "[", "]", "arguments", ";", "private", "boolean", "error", ";", "public", "ProblemLocation", "(", "IProblem", "problem", ")", "{", "id", "=", "problem", ".", "getID", "(", ")", ";", "offset", "=", "problem", ".", "getSourceStart", "(", ")", ";", "length", "=", "(", "problem", ".", "getSourceEnd", "(", ")", "+", "1", ")", "-", "offset", ";", "arguments", "=", "problem", ".", "getArguments", "(", ")", ";", "error", "=", "problem", ".", "isError", "(", ")", ";", "}", "public", "ASTNode", "getCoveredNode", "(", "CompilationUnit", "astRoot", ")", "{", "NodeFinder", "finder", "=", "new", "NodeFinder", "(", "astRoot", ",", "offset", ",", "length", ")", ";", "return", "finder", ".", "getCoveredNode", "(", ")", ";", "}", "public", "ASTNode", "getCoveringNode", "(", "CompilationUnit", "astRoot", ")", "{", "NodeFinder", "finder", "=", "new", "NodeFinder", "(", "astRoot", ",", "offset", ",", "length", ")", ";", "return", "finder", ".", "getCoveringNode", "(", ")", ";", "}", "public", "int", "getLength", "(", ")", "{", "return", "length", ";", "}", "public", "int", "getOffset", "(", ")", "{", "return", "offset", ";", "}", "public", "String", "[", "]", "getProblemArguments", "(", ")", "{", "return", "arguments", ";", "}", "public", "int", "getProblemId", "(", ")", "{", "return", "id", ";", "}", "public", "boolean", "isError", "(", ")", "{", "return", "error", ";", "}", "public", "String", "getMarkerType", "(", ")", "{", "return", "IJavaModelMarker", ".", "JAVA_MODEL_PROBLEM_MARKER", ";", "}", "}", "</s>" ]
1,244
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "search", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Iterator", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "regex", ".", "Matcher", ";", "import", "java", ".", "util", ".", "regex", ".", "Pattern", ";", "import", "org", ".", "apache", ".", "commons", ".", "vfs", ".", "FileObject", ";", "import", "org", ".", "apache", ".", "commons", ".", "vfs", ".", "FileSystemManager", ";", "import", "org", ".", "apache", ".", "commons", ".", "vfs", ".", "VFS", ";", "import", "org", ".", "apache", ".", "tools", ".", "ant", ".", "taskdefs", ".", "condition", ".", "Os", ";", "import", "org", ".", "eclim", ".", "Services", ";", "import", "org", ".", "eclim", ".", "annotation", ".", "Command", ";", "import", "org", ".", "eclim", ".", "command", ".", "CommandLine", ";", "import", "org", ".", "eclim", ".", "command", ".", "Options", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "command", ".", "AbstractCommand", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "util", ".", "ProjectUtils", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "util", ".", "JavaUtils", ";", "import", "org", ".", "eclim", ".", "util", ".", "file", ".", "FileUtils", ";", "import", "org", ".", "eclim", ".", "util", ".", "file", ".", "Position", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "IProject", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "IResource", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "CoreException", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "IPath", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "ICodeAssist", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IJavaElement", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IJavaProject", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IPackageFragmentRoot", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "search", ".", "IJavaSearchConstants", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "search", ".", "IJavaSearchScope", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "search", ".", "SearchEngine", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "search", ".", "SearchMatch", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "search", ".", "SearchParticipant", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "search", ".", "SearchPattern", ";", "@", "Command", "(", "name", "=", "\"java_search\"", ",", "options", "=", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", ")", "public", "class", "SearchCommand", "extends", "AbstractCommand", "{", "public", "static", "final", "String", "CONTEXT_ALL", "=", "\"all\"", ";", "public", "static", "final", "String", "CONTEXT_DECLARATIONS", "=", "\"declarations\"", ";", "public", "static", "final", "String", "CONTEXT_IMPLEMENTORS", "=", "\"implementors\"", ";", "public", "static", "final", "String", "CONTEXT_REFERENCES", "=", "\"references\"", ";", "public", "static", "final", "String", "SCOPE_ALL", "=", "\"all\"", ";", "public", "static", "final", "String", "SCOPE_PROJECT", "=", "\"project\"", ";", "public", "static", "final", "String", "SCOPE_TYPE", "=", "\"type\"", ";", "public", "static", "final", "String", "TYPE_ALL", "=", "\"all\"", ";", "public", "static", "final", "String", "TYPE_ANNOTATION", "=", "\"annotation\"", ";", "public", "static", "final", "String", "TYPE_CLASS", "=", "\"class\"", ";", "public", "static", "final", "String", "TYPE_CLASS_OR_ENUM", "=", "\"classOrEnum\"", ";", "public", "static", "final", "String", "TYPE_CLASS_OR_INTERFACE", "=", "\"\"", ";", "public", "static", "final", "String", "TYPE_CONSTRUCTOR", "=", "\"constructor\"", ";", "public", "static", "final", "String", "TYPE_ENUM", "=", "\"enum\"", ";", "public", "static", "final", "String", "TYPE_FIELD", "=", "\"field\"", ";", "public", "static", "final", "String", "TYPE_INTERFACE", "=", "\"interface\"", ";", "public", "static", "final", "String", "TYPE_METHOD", "=", "\"method\"", ";", "public", "static", "final", "String", "TYPE_PACKAGE", "=", "\"package\"", ";", "public", "static", "final", "String", "TYPE_TYPE", "=", "\"type\"", ";", "private", "static", "final", "Pattern", "INNER_CLASS", "=", "Pattern", ".", "compile", "(", "\"\"", ")", ";", "protected", "static", "final", "String", "ANDROID_NATURE", "=", "\"\"", ";", "private", "static", "final", "Pattern", "ANDROID_JDK_URL", "=", "Pattern", ".", "compile", "(", "\"\"", ")", ";", "@", "Override", "public", "Object", "execute", "(", "CommandLine", "commandLine", ")", "throws", "Exception", "{", "List", "<", "SearchMatch", ">", "matches", "=", "executeSearch", "(", "commandLine", ")", ";", "String", "projectName", "=", "commandLine", ".", "getValue", "(", "Options", ".", "NAME_OPTION", ")", ";", "IProject", "project", "=", "projectName", "!=", "null", "?", "ProjectUtils", ".", "getProject", "(", "projectName", ")", ":", "null", ";", "ArrayList", "<", "Position", ">", "results", "=", "new", "ArrayList", "<", "Position", ">", "(", ")", ";", "for", "(", "SearchMatch", "match", ":", "matches", ")", "{", "IJavaElement", "element", "=", "(", "IJavaElement", ")", "match", ".", "getElement", "(", ")", ";", "if", "(", "element", "!=", "null", ")", "{", "int", "elementType", "=", "element", ".", "getElementType", "(", ")", ";", "if", "(", "elementType", "!=", "IJavaElement", ".", "PACKAGE_FRAGMENT", "&&", "elementType", "!=", "IJavaElement", ".", "PACKAGE_FRAGMENT_ROOT", ")", "{", "Position", "result", "=", "createPosition", "(", "project", ",", "match", ")", ";", "if", "(", "result", "!=", "null", ")", "{", "results", ".", "add", "(", "result", ")", ";", "}", "}", "}", "}", "return", "results", ";", "}", "public", "List", "<", "SearchMatch", ">", "executeSearch", "(", "CommandLine", "commandLine", ")", "throws", "Exception", "{", "int", "context", "=", "-", "1", ";", "if", "(", "commandLine", ".", "hasOption", "(", "Options", ".", "CONTEXT_OPTION", ")", ")", "{", "context", "=", "getContext", "(", "commandLine", ".", "getValue", "(", "Options", ".", "CONTEXT_OPTION", ")", ")", ";", "}", "String", "project", "=", "commandLine", ".", "getValue", "(", "Options", ".", "NAME_OPTION", ")", ";", "String", "scope", "=", "commandLine", ".", "getValue", "(", "Options", ".", "SCOPE_OPTION", ")", ";", "String", "file", "=", "commandLine", ".", "getValue", "(", "Options", ".", "FILE_OPTION", ")", ";", "String", "offset", "=", "commandLine", ".", "getValue", "(", "Options", ".", "OFFSET_OPTION", ")", ";", "String", "length", "=", "commandLine", ".", "getValue", "(", "Options", ".", "LENGTH_OPTION", ")", ";", "String", "pat", "=", "commandLine", ".", "getValue", "(", "Options", ".", "PATTERN_OPTION", ")", ";", "SearchPattern", "pattern", "=", "null", ";", "IJavaProject", "javaProject", "=", "project", "!=", "null", "?", "JavaUtils", ".", "getJavaProject", "(", "project", ")", ":", "null", ";", "if", "(", "file", "!=", "null", "&&", "offset", "!=", "null", "&&", "length", "!=", "null", ")", "{", "int", "charOffset", "=", "getOffset", "(", "commandLine", ")", ";", "IJavaElement", "element", "=", "getElement", "(", "javaProject", ",", "file", ",", "charOffset", ",", "Integer", ".", "parseInt", "(", "length", ")", ")", ";", "if", "(", "element", "!=", "null", ")", "{", "if", "(", "context", "==", "-", "1", ")", "{", "context", "=", "getElementContextualContext", "(", "element", ")", ";", "}", "pattern", "=", "SearchPattern", ".", "createPattern", "(", "element", ",", "context", ")", ";", "}", "}", "else", "if", "(", "pat", "!=", "null", ")", "{", "if", "(", "context", "==", "-", "1", ")", "{", "context", "=", "IJavaSearchConstants", ".", "DECLARATIONS", ";", "}", "int", "matchType", "=", "SearchPattern", ".", "R_EXACT_MATCH", ";", "if", "(", "pat", ".", "indexOf", "(", "'*'", ")", "!=", "-", "1", "||", "pat", ".", "indexOf", "(", "'?'", ")", "!=", "-", "1", ")", "{", "matchType", "=", "SearchPattern", ".", "R_PATTERN_MATCH", ";", "}", "else", "if", "(", "pat", ".", "equals", "(", "pat", ".", "toUpperCase", "(", ")", ")", ")", "{", "matchType", "|=", "SearchPattern", ".", "R_CAMELCASE_MATCH", ";", "}", "boolean", "caseSensitive", "=", "!", "commandLine", ".", "hasOption", "(", "Options", ".", "CASE_INSENSITIVE_OPTION", ")", ";", "if", "(", "caseSensitive", ")", "{", "matchType", "|=", "SearchPattern", ".", "R_CASE_SENSITIVE", ";", "}", "int", "type", "=", "getType", "(", "commandLine", ".", "getValue", "(", "Options", ".", "TYPE_OPTION", ")", ")", ";", "Matcher", "matcher", "=", "INNER_CLASS", ".", "matcher", "(", "pat", ")", ";", "if", "(", "matcher", ".", "matches", "(", ")", ")", "{", "pattern", "=", "SearchPattern", ".", "createPattern", "(", "matcher", ".", "replaceFirst", "(", "\"$1*$3\"", ")", ",", "type", ",", "context", ",", "matchType", ")", ";", "Pattern", "toMatch", "=", "Pattern", ".", "compile", "(", "pat", ".", "replace", "(", "\".\"", ",", "\"\\\\.\"", ")", ".", "replace", "(", "\"$\"", ",", "\"\\\\$\"", ")", ".", "replace", "(", "\"(\"", ",", "\"\\\\(\"", ")", ".", "replace", "(", "\")\"", ",", "\"\\\\)\"", ")", ".", "replace", "(", "\"*\"", ",", "\".*\"", ")", ".", "replace", "(", "\"?\"", ",", "\".\"", ")", ")", ";", "List", "<", "SearchMatch", ">", "matches", "=", "search", "(", "pattern", ",", "getScope", "(", "scope", ",", "javaProject", ")", ")", ";", "Iterator", "<", "SearchMatch", ">", "iterator", "=", "matches", ".", "iterator", "(", ")", ";", "while", "(", "iterator", ".", "hasNext", "(", ")", ")", "{", "SearchMatch", "match", "=", "iterator", ".", "next", "(", ")", ";", "String", "name", "=", "JavaUtils", ".", "getFullyQualifiedName", "(", "(", "IJavaElement", ")", "match", ".", "getElement", "(", ")", ")", ".", "replace", "(", "\"#\"", ",", "\".\"", ")", ";", "if", "(", "!", "toMatch", ".", "matcher", "(", "name", ")", ".", "matches", "(", ")", ")", "{", "iterator", ".", "remove", "(", ")", ";", "}", "}", "return", "matches", ";", "}", "pattern", "=", "SearchPattern", ".", "createPattern", "(", "pat", ",", "type", ",", "context", ",", "matchType", ")", ";", "}", "else", "{", "throw", "new", "IllegalArgumentException", "(", "Services", ".", "getMessage", "(", "\"\"", ")", ")", ";", "}", "List", "<", "SearchMatch", ">", "matches", "=", "search", "(", "pattern", ",", "getScope", "(", "scope", ",", "javaProject", ")", ")", ";", "return", "matches", ";", "}", "protected", "List", "<", "SearchMatch", ">", "search", "(", "SearchPattern", "pattern", ",", "IJavaSearchScope", "scope", ")", "throws", "CoreException", "{", "SearchRequestor", "requestor", "=", "new", "SearchRequestor", "(", ")", ";", "if", "(", "pattern", "!=", "null", ")", "{", "SearchEngine", "engine", "=", "new", "SearchEngine", "(", ")", ";", "SearchParticipant", "[", "]", "participants", "=", "new", "SearchParticipant", "[", "]", "{", "SearchEngine", ".", "getDefaultSearchParticipant", "(", ")", "}", ";", "engine", ".", "search", "(", "pattern", ",", "participants", ",", "scope", ",", "requestor", ",", "null", ")", ";", "}", "return", "requestor", ".", "getMatches", "(", ")", ";", "}", "protected", "IJavaElement", "getElement", "(", "IJavaProject", "javaProject", ",", "String", "filename", ",", "int", "offset", ",", "int", "length", ")", "throws", "Exception", "{", "ICodeAssist", "code", "=", "null", ";", "try", "{", "code", "=", "JavaUtils", ".", "getCompilationUnit", "(", "javaProject", ",", "filename", ")", ";", "}", "catch", "(", "IllegalArgumentException", "iae", ")", "{", "code", "=", "JavaUtils", ".", "findClassFile", "(", "javaProject", ",", "filename", ")", ";", "}", "if", "(", "code", "!=", "null", ")", "{", "IJavaElement", "[", "]", "elements", "=", "code", ".", "codeSelect", "(", "offset", ",", "length", ")", ";", "if", "(", "elements", "!=", "null", "&&", "elements", ".", "length", ">", "0", ")", "{", "return", "elements", "[", "0", "]", ";", "}", "}", "return", "null", ";", "}", "protected", "boolean", "isJarArchive", "(", "IPath", "path", ")", "{", "String", "ext", "=", "path", ".", "getFileExtension", "(", ")", ";", "return", "ext", "!=", "null", "&&", "ext", ".", "toLowerCase", "(", ")", ".", "matches", "(", "\"^(jar|zip)$\"", ")", ";", "}", "protected", "Position", "createPosition", "(", "IProject", "project", ",", "SearchMatch", "match", ")", "throws", "Exception", "{", "IJavaElement", "element", "=", "(", "IJavaElement", ")", "match", ".", "getElement", "(", ")", ";", "IJavaElement", "parent", "=", "JavaUtils", ".", "getPrimaryElement", "(", "element", ")", ";", "String", "file", "=", "null", ";", "String", "elementName", "=", "JavaUtils", ".", "getFullyQualifiedName", "(", "parent", ")", ";", "if", "(", "parent", ".", "getElementType", "(", ")", "==", "IJavaElement", ".", "CLASS_FILE", ")", "{", "IResource", "resource", "=", "parent", ".", "getResource", "(", ")", ";", "if", "(", "resource", "!=", "null", "&&", "resource", ".", "getType", "(", ")", "==", "IResource", ".", "FILE", "&&", "!", "isJarArchive", "(", "resource", ".", "getLocation", "(", ")", ")", ")", "{", "file", "=", "resource", ".", "getLocation", "(", ")", ".", "toOSString", "(", ")", ";", "}", "else", "{", "IPath", "path", "=", "null", ";", "IPackageFragmentRoot", "root", "=", "(", "IPackageFragmentRoot", ")", "parent", ".", "getParent", "(", ")", ".", "getParent", "(", ")", ";", "resource", "=", "root", ".", "getResource", "(", ")", ";", "if", "(", "resource", "!=", "null", ")", "{", "if", "(", "resource", ".", "getType", "(", ")", "==", "IResource", ".", "PROJECT", ")", "{", "path", "=", "ProjectUtils", ".", "getIPath", "(", "(", "IProject", ")", "resource", ")", ";", "}", "else", "{", "path", "=", "resource", ".", "getLocation", "(", ")", ";", "}", "}", "else", "{", "path", "=", "root", ".", "getPath", "(", ")", ";", "}", "String", "classFile", "=", "elementName", ".", "replace", "(", "'.'", ",", "File", ".", "separatorChar", ")", ";", "if", "(", "isJarArchive", "(", "path", ")", ")", "{", "file", "=", "\"jar:file://\"", "+", "path", ".", "toOSString", "(", ")", "+", "'!'", "+", "classFile", "+", "\".class\"", ";", "}", "else", "{", "file", "=", "path", ".", "toOSString", "(", ")", "+", "'/'", "+", "classFile", "+", "\".class\"", ";", "}", "if", "(", "ANDROID_JDK_URL", ".", "matcher", "(", "file", ")", ".", "matches", "(", ")", "&&", "project", "!=", "null", "&&", "!", "project", ".", "hasNature", "(", "ANDROID_NATURE", ")", ")", "{", "return", "null", ";", "}", "IPath", "srcPath", "=", "root", ".", "getSourceAttachmentPath", "(", ")", ";", "if", "(", "srcPath", "!=", "null", ")", "{", "String", "rootPath", ";", "IProject", "elementProject", "=", "root", ".", "getJavaProject", "(", ")", ".", "getProject", "(", ")", ";", "if", "(", "srcPath", ".", "isAbsolute", "(", ")", "&&", "elementProject", ".", "getName", "(", ")", ".", "equals", "(", "srcPath", ".", "segment", "(", "0", ")", ")", ")", "{", "rootPath", "=", "ProjectUtils", ".", "getFilePath", "(", "elementProject", ",", "srcPath", ".", "toString", "(", ")", ")", ";", "}", "else", "{", "rootPath", "=", "srcPath", ".", "toOSString", "(", ")", ";", "}", "String", "srcFile", "=", "FileUtils", ".", "toUrl", "(", "rootPath", "+", "File", ".", "separator", "+", "classFile", "+", "\".java\"", ")", ";", "FileSystemManager", "fsManager", "=", "VFS", ".", "getManager", "(", ")", ";", "FileObject", "fileObject", "=", "fsManager", ".", "resolveFile", "(", "srcFile", ")", ";", "if", "(", "fileObject", ".", "exists", "(", ")", ")", "{", "file", "=", "srcFile", ";", "}", "else", "if", "(", "Os", ".", "isFamily", "(", "Os", ".", "FAMILY_MAC", ")", ")", "{", "srcFile", "=", "FileUtils", ".", "toUrl", "(", "rootPath", "+", "File", ".", "separator", "+", "\"src\"", "+", "File", ".", "separator", "+", "classFile", "+", "\".java\"", ")", ";", "fileObject", "=", "fsManager", ".", "resolveFile", "(", "srcFile", ")", ";", "if", "(", "fileObject", ".", "exists", "(", ")", ")", "{", "file", "=", "srcFile", ";", "}", "}", "}", "}", "}", "else", "{", "IPath", "location", "=", "match", ".", "getResource", "(", ")", ".", "getLocation", "(", ")", ";", "file", "=", "location", "!=", "null", "?", "location", ".", "toOSString", "(", ")", ":", "null", ";", "}", "elementName", "=", "JavaUtils", ".", "getFullyQualifiedName", "(", "element", ")", ";", "return", "Position", ".", "fromOffset", "(", "file", ".", "replace", "(", "'\\\\'", ",", "'/'", ")", ",", "elementName", ",", "match", ".", "getOffset", "(", ")", ",", "match", ".", "getLength", "(", ")", ")", ";", "}", "protected", "IJavaSearchScope", "getScope", "(", "String", "scope", ",", "IJavaProject", "project", ")", "throws", "Exception", "{", "if", "(", "project", "==", "null", ")", "{", "return", "SearchEngine", ".", "createWorkspaceScope", "(", ")", ";", "}", "else", "if", "(", "SCOPE_PROJECT", ".", "equals", "(", "scope", ")", ")", "{", "return", "SearchEngine", ".", "createJavaSearchScope", "(", "new", "IJavaElement", "[", "]", "{", "project", "}", ")", ";", "}", "return", "SearchEngine", ".", "createWorkspaceScope", "(", ")", ";", "}", "protected", "int", "getElementContextualContext", "(", "IJavaElement", "element", ")", "{", "Class", "<", "?", ">", "theClass", "=", "element", ".", "getClass", "(", ")", ";", "if", "(", "theClass", ".", "equals", "(", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "core", ".", "SourceType", ".", "class", ")", "||", "theClass", ".", "equals", "(", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "core", ".", "SourceField", ".", "class", ")", "||", "theClass", ".", "equals", "(", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "core", ".", "SourceMethod", ".", "class", ")", ")", "{", "return", "IJavaSearchConstants", ".", "ALL_OCCURRENCES", ";", "}", "return", "IJavaSearchConstants", ".", "DECLARATIONS", ";", "}", "protected", "int", "getContext", "(", "String", "context", ")", "{", "if", "(", "CONTEXT_ALL", ".", "equals", "(", "context", ")", ")", "{", "return", "IJavaSearchConstants", ".", "ALL_OCCURRENCES", ";", "}", "else", "if", "(", "CONTEXT_IMPLEMENTORS", ".", "equals", "(", "context", ")", ")", "{", "return", "IJavaSearchConstants", ".", "IMPLEMENTORS", ";", "}", "else", "if", "(", "CONTEXT_REFERENCES", ".", "equals", "(", "context", ")", ")", "{", "return", "IJavaSearchConstants", ".", "REFERENCES", ";", "}", "return", "IJavaSearchConstants", ".", "DECLARATIONS", ";", "}", "protected", "int", "getType", "(", "String", "type", ")", "{", "if", "(", "TYPE_ANNOTATION", ".", "equals", "(", "type", ")", ")", "{", "return", "IJavaSearchConstants", ".", "ANNOTATION_TYPE", ";", "}", "else", "if", "(", "TYPE_CLASS", ".", "equals", "(", "type", ")", ")", "{", "return", "IJavaSearchConstants", ".", "CLASS", ";", "}", "else", "if", "(", "TYPE_CLASS_OR_ENUM", ".", "equals", "(", "type", ")", ")", "{", "return", "IJavaSearchConstants", ".", "CLASS_AND_ENUM", ";", "}", "else", "if", "(", "TYPE_CLASS_OR_INTERFACE", ".", "equals", "(", "type", ")", ")", "{", "return", "IJavaSearchConstants", ".", "CLASS_AND_INTERFACE", ";", "}", "else", "if", "(", "TYPE_CONSTRUCTOR", ".", "equals", "(", "type", ")", ")", "{", "return", "IJavaSearchConstants", ".", "CONSTRUCTOR", ";", "}", "else", "if", "(", "TYPE_ENUM", ".", "equals", "(", "type", ")", ")", "{", "return", "IJavaSearchConstants", ".", "ENUM", ";", "}", "else", "if", "(", "TYPE_FIELD", ".", "equals", "(", "type", ")", ")", "{", "return", "IJavaSearchConstants", ".", "FIELD", ";", "}", "else", "if", "(", "TYPE_INTERFACE", ".", "equals", "(", "type", ")", ")", "{", "return", "IJavaSearchConstants", ".", "INTERFACE", ";", "}", "else", "if", "(", "TYPE_METHOD", ".", "equals", "(", "type", ")", ")", "{", "return", "IJavaSearchConstants", ".", "METHOD", ";", "}", "else", "if", "(", "TYPE_PACKAGE", ".", "equals", "(", "type", ")", ")", "{", "return", "IJavaSearchConstants", ".", "PACKAGE", ";", "}", "return", "IJavaSearchConstants", ".", "TYPE", ";", "}", "}", "</s>" ]
1,245
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "search", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Collections", ";", "import", "java", ".", "util", ".", "Comparator", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "util", ".", "IJavaElementComparator", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "CoreException", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IJavaElement", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "search", ".", "SearchMatch", ";", "public", "class", "SearchRequestor", "extends", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "search", ".", "SearchRequestor", "{", "private", "static", "final", "SearchMatchComparator", "MATCH_COMPARATOR", "=", "new", "SearchMatchComparator", "(", ")", ";", "private", "ArrayList", "<", "SearchMatch", ">", "matches", "=", "new", "ArrayList", "<", "SearchMatch", ">", "(", ")", ";", "public", "void", "acceptSearchMatch", "(", "SearchMatch", "match", ")", "throws", "CoreException", "{", "if", "(", "match", ".", "getAccuracy", "(", ")", "==", "SearchMatch", ".", "A_ACCURATE", ")", "{", "matches", ".", "add", "(", "match", ")", ";", "}", "}", "public", "List", "<", "SearchMatch", ">", "getMatches", "(", ")", "{", "Collections", ".", "sort", "(", "matches", ",", "MATCH_COMPARATOR", ")", ";", "return", "matches", ";", "}", "public", "static", "class", "SearchMatchComparator", "implements", "Comparator", "<", "SearchMatch", ">", "{", "private", "static", "final", "IJavaElementComparator", "ELEMENT_COMPATATOR", "=", "new", "IJavaElementComparator", "(", ")", ";", "public", "int", "compare", "(", "SearchMatch", "o1", ",", "SearchMatch", "o2", ")", "{", "return", "ELEMENT_COMPATATOR", ".", "compare", "(", "(", "IJavaElement", ")", "o1", ".", "getElement", "(", ")", ",", "(", "IJavaElement", ")", "o2", ".", "getElement", "(", ")", ")", ";", "}", "public", "boolean", "equals", "(", "Object", "obj", ")", "{", "if", "(", "obj", "instanceof", "SearchMatchComparator", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}", "}", "}", "</s>" ]
1,246
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "classpath", ";", "import", "org", ".", "eclim", ".", "Services", ";", "import", "org", ".", "eclim", ".", "annotation", ".", "Command", ";", "import", "org", ".", "eclim", ".", "command", ".", "CommandLine", ";", "import", "org", ".", "eclim", ".", "command", ".", "Options", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "command", ".", "AbstractCommand", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "Path", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "JavaCore", ";", "@", "Command", "(", "name", "=", "\"\"", ",", "options", "=", "\"\"", "+", "\"\"", ")", "public", "class", "ClasspathVariableCreateCommand", "extends", "AbstractCommand", "{", "public", "Object", "execute", "(", "CommandLine", "commandLine", ")", "throws", "Exception", "{", "String", "name", "=", "commandLine", ".", "getValue", "(", "Options", ".", "NAME_OPTION", ")", ";", "String", "path", "=", "commandLine", ".", "getValue", "(", "Options", ".", "PATH_OPTION", ")", ";", "JavaCore", ".", "setClasspathVariable", "(", "name", ",", "new", "Path", "(", "path", ")", ",", "null", ")", ";", "return", "Services", ".", "getMessage", "(", "\"\"", ",", "name", ")", ";", "}", "}", "</s>" ]
1,247
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "classpath", ";", "public", "class", "ClasspathVariable", "implements", "Comparable", "<", "ClasspathVariable", ">", "{", "private", "String", "name", ";", "private", "String", "path", ";", "public", "String", "getName", "(", ")", "{", "return", "this", ".", "name", ";", "}", "public", "void", "setName", "(", "String", "name", ")", "{", "this", ".", "name", "=", "name", ";", "}", "public", "String", "getPath", "(", ")", "{", "return", "this", ".", "path", ";", "}", "public", "void", "setPath", "(", "String", "path", ")", "{", "this", ".", "path", "=", "path", ";", "}", "public", "int", "compareTo", "(", "ClasspathVariable", "obj", ")", "{", "if", "(", "obj", "==", "this", ")", "{", "return", "0", ";", "}", "return", "this", ".", "getName", "(", ")", ".", "compareTo", "(", "obj", ".", "getName", "(", ")", ")", ";", "}", "}", "</s>" ]
1,248
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "classpath", ";", "import", "org", ".", "eclim", ".", "Services", ";", "import", "org", ".", "eclim", ".", "annotation", ".", "Command", ";", "import", "org", ".", "eclim", ".", "command", ".", "CommandLine", ";", "import", "org", ".", "eclim", ".", "command", ".", "Options", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "command", ".", "AbstractCommand", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "JavaCore", ";", "@", "Command", "(", "name", "=", "\"\"", ",", "options", "=", "\"\"", ")", "public", "class", "ClasspathVariableDeleteCommand", "extends", "AbstractCommand", "{", "public", "Object", "execute", "(", "CommandLine", "commandLine", ")", "throws", "Exception", "{", "String", "name", "=", "commandLine", ".", "getValue", "(", "Options", ".", "NAME_OPTION", ")", ";", "JavaCore", ".", "removeClasspathVariable", "(", "name", ",", "null", ")", ";", "return", "Services", ".", "getMessage", "(", "\"\"", ",", "name", ")", ";", "}", "}", "</s>" ]
1,249
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "classpath", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Collections", ";", "import", "org", ".", "eclim", ".", "annotation", ".", "Command", ";", "import", "org", ".", "eclim", ".", "command", ".", "CommandLine", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "command", ".", "AbstractCommand", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "IPath", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "JavaCore", ";", "@", "Command", "(", "name", "=", "\"\"", ")", "public", "class", "ClasspathVariablesCommand", "extends", "AbstractCommand", "{", "public", "Object", "execute", "(", "CommandLine", "commandLine", ")", "throws", "Exception", "{", "ArrayList", "<", "ClasspathVariable", ">", "results", "=", "new", "ArrayList", "<", "ClasspathVariable", ">", "(", ")", ";", "String", "[", "]", "names", "=", "JavaCore", ".", "getClasspathVariableNames", "(", ")", ";", "for", "(", "int", "ii", "=", "0", ";", "ii", "<", "names", ".", "length", ";", "ii", "++", ")", "{", "IPath", "path", "=", "JavaCore", ".", "getClasspathVariable", "(", "names", "[", "ii", "]", ")", ";", "if", "(", "path", "!=", "null", ")", "{", "ClasspathVariable", "variable", "=", "new", "ClasspathVariable", "(", ")", ";", "variable", ".", "setName", "(", "names", "[", "ii", "]", ")", ";", "variable", ".", "setPath", "(", "path", ".", "toOSString", "(", ")", ")", ";", "results", ".", "add", "(", "variable", ")", ";", "}", "}", "Collections", ".", "sort", "(", "results", ")", ";", "return", "results", ";", "}", "}", "</s>" ]
1,250
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "classpath", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang", ".", "SystemUtils", ";", "import", "org", ".", "eclim", ".", "annotation", ".", "Command", ";", "import", "org", ".", "eclim", ".", "command", ".", "CommandLine", ";", "import", "org", ".", "eclim", ".", "command", ".", "Options", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "command", ".", "AbstractCommand", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "util", ".", "ClasspathUtils", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "util", ".", "JavaUtils", ";", "import", "org", ".", "eclim", ".", "util", ".", "StringUtils", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IJavaProject", ";", "@", "Command", "(", "name", "=", "\"\"", ",", "options", "=", "\"\"", "+", "\"\"", ")", "public", "class", "ClasspathCommand", "extends", "AbstractCommand", "{", "public", "Object", "execute", "(", "CommandLine", "commandLine", ")", "throws", "Exception", "{", "String", "name", "=", "commandLine", ".", "getValue", "(", "Options", ".", "PROJECT_OPTION", ")", ";", "String", "delim", "=", "commandLine", ".", "getValue", "(", "Options", ".", "DELIMETER_OPTION", ",", "SystemUtils", ".", "PATH_SEPARATOR", ")", ";", "IJavaProject", "javaProject", "=", "JavaUtils", ".", "getJavaProject", "(", "name", ")", ";", "String", "[", "]", "paths", "=", "ClasspathUtils", ".", "getClasspath", "(", "javaProject", ")", ";", "return", "StringUtils", ".", "join", "(", "paths", ",", "delim", ")", ";", "}", "}", "</s>" ]
1,251
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "webxml", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "eclim", ".", "Services", ";", "import", "org", ".", "eclim", ".", "annotation", ".", "Command", ";", "import", "org", ".", "eclim", ".", "command", ".", "CommandLine", ";", "import", "org", ".", "eclim", ".", "command", ".", "Error", ";", "import", "org", ".", "eclim", ".", "command", ".", "Options", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "util", ".", "ProjectUtils", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "util", ".", "JavaUtils", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IJavaProject", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IType", ";", "import", "org", ".", "xml", ".", "sax", ".", "Attributes", ";", "import", "org", ".", "xml", ".", "sax", ".", "Locator", ";", "import", "org", ".", "xml", ".", "sax", ".", "SAXException", ";", "import", "org", ".", "xml", ".", "sax", ".", "helpers", ".", "DefaultHandler", ";", "@", "Command", "(", "name", "=", "\"\"", ",", "options", "=", "\"\"", "+", "\"\"", ")", "public", "class", "ValidateCommand", "extends", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "command", ".", "xml", ".", "ValidateCommand", "{", "public", "Object", "execute", "(", "CommandLine", "commandLine", ")", "throws", "Exception", "{", "String", "project", "=", "commandLine", ".", "getValue", "(", "Options", ".", "PROJECT_OPTION", ")", ";", "String", "file", "=", "commandLine", ".", "getValue", "(", "Options", ".", "FILE_OPTION", ")", ";", "WebXmlHandler", "handler", "=", "new", "WebXmlHandler", "(", "JavaUtils", ".", "getJavaProject", "(", "project", ")", ",", "file", ")", ";", "List", "<", "Error", ">", "errors", "=", "super", ".", "validate", "(", "project", ",", "file", ",", "false", ",", "handler", ")", ";", "errors", ".", "addAll", "(", "handler", ".", "getErrors", "(", ")", ")", ";", "return", "errors", ";", "}", "private", "static", "class", "WebXmlHandler", "extends", "DefaultHandler", "{", "private", "static", "final", "String", "CLASS", "=", "\"-class\"", ";", "private", "static", "final", "String", "FILTER", "=", "\"filter\"", ";", "private", "static", "final", "String", "FILTER_MAPPING", "=", "\"\"", ";", "private", "static", "final", "String", "FILTER_NAME", "=", "\"filter-name\"", ";", "private", "static", "final", "String", "SERVLET", "=", "\"servlet\"", ";", "private", "static", "final", "String", "SERVLET_MAPPING", "=", "\"\"", ";", "private", "static", "final", "String", "SERVLET_NAME", "=", "\"servlet-name\"", ";", "private", "Locator", "locator", ";", "private", "IJavaProject", "project", ";", "private", "String", "file", ";", "private", "StringBuffer", "text", "=", "new", "StringBuffer", "(", ")", ";", "private", "boolean", "mapping", "=", "false", ";", "private", "ArrayList", "<", "String", ">", "filters", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "private", "ArrayList", "<", "String", ">", "servlets", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "private", "ArrayList", "<", "Error", ">", "errors", "=", "new", "ArrayList", "<", "Error", ">", "(", ")", ";", "public", "WebXmlHandler", "(", "IJavaProject", "project", ",", "String", "file", ")", "throws", "Exception", "{", "this", ".", "project", "=", "project", ";", "this", ".", "file", "=", "ProjectUtils", ".", "getFilePath", "(", "project", ".", "getProject", "(", ")", ",", "file", ")", ";", "}", "public", "void", "setDocumentLocator", "(", "Locator", "locator", ")", "{", "super", ".", "setDocumentLocator", "(", "locator", ")", ";", "this", ".", "locator", "=", "locator", ";", "}", "public", "void", "startElement", "(", "String", "uri", ",", "String", "localName", ",", "String", "qName", ",", "Attributes", "attributes", ")", "throws", "SAXException", "{", "if", "(", "SERVLET", ".", "equals", "(", "localName", ")", "||", "FILTER", ".", "equals", "(", "localName", ")", ")", "{", "mapping", "=", "false", ";", "}", "else", "if", "(", "SERVLET_MAPPING", ".", "equals", "(", "localName", ")", "||", "FILTER_MAPPING", ".", "equals", "(", "localName", ")", ")", "{", "mapping", "=", "true", ";", "}", "}", "public", "void", "endElement", "(", "String", "uri", ",", "String", "localName", ",", "String", "qName", ")", "throws", "SAXException", "{", "try", "{", "if", "(", "localName", ".", "endsWith", "(", "CLASS", ")", ")", "{", "String", "name", "=", "text", ".", "toString", "(", ")", ".", "trim", "(", ")", ";", "IType", "type", "=", "project", ".", "findType", "(", "name", ")", ";", "if", "(", "type", "==", "null", "||", "!", "type", ".", "exists", "(", ")", ")", "{", "String", "message", "=", "Services", ".", "getMessage", "(", "\"\"", ",", "project", ".", "getElementName", "(", ")", ",", "name", ")", ";", "errors", ".", "add", "(", "new", "Error", "(", "message", ",", "file", ",", "locator", ".", "getLineNumber", "(", ")", ",", "1", ",", "false", ")", ")", ";", "}", "}", "else", "if", "(", "SERVLET_NAME", ".", "equals", "(", "localName", ")", ")", "{", "String", "name", "=", "text", ".", "toString", "(", ")", ".", "trim", "(", ")", ";", "if", "(", "mapping", "&&", "!", "servlets", ".", "contains", "(", "name", ")", ")", "{", "String", "message", "=", "Services", ".", "getMessage", "(", "\"\"", ",", "name", ")", ";", "errors", ".", "add", "(", "new", "Error", "(", "message", ",", "file", ",", "locator", ".", "getLineNumber", "(", ")", ",", "1", ",", "false", ")", ")", ";", "}", "else", "if", "(", "!", "mapping", ")", "{", "servlets", ".", "add", "(", "name", ")", ";", "}", "}", "else", "if", "(", "FILTER_NAME", ".", "equals", "(", "localName", ")", ")", "{", "String", "name", "=", "text", ".", "toString", "(", ")", ".", "trim", "(", ")", ";", "if", "(", "mapping", "&&", "!", "filters", ".", "contains", "(", "name", ")", ")", "{", "String", "message", "=", "Services", ".", "getMessage", "(", "\"\"", ",", "name", ")", ";", "errors", ".", "add", "(", "new", "Error", "(", "message", ",", "file", ",", "locator", ".", "getLineNumber", "(", ")", ",", "1", ",", "false", ")", ")", ";", "}", "else", "if", "(", "!", "mapping", ")", "{", "filters", ".", "add", "(", "name", ")", ";", "}", "}", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "finally", "{", "text", "=", "new", "StringBuffer", "(", ")", ";", "}", "}", "public", "void", "characters", "(", "char", "[", "]", "ch", ",", "int", "start", ",", "int", "length", ")", "throws", "SAXException", "{", "for", "(", "int", "ii", "=", "start", ";", "ii", "<", "start", "+", "length", ";", "ii", "++", ")", "{", "text", ".", "append", "(", "ch", "[", "ii", "]", ")", ";", "}", "}", "public", "List", "<", "Error", ">", "getErrors", "(", ")", "{", "return", "errors", ";", "}", "}", "}", "</s>" ]
1,252
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "impl", ";", "import", "java", ".", "util", ".", "Arrays", ";", "import", "java", ".", "util", ".", "Comparator", ";", "import", "org", ".", "eclim", ".", "Services", ";", "import", "org", ".", "eclim", ".", "annotation", ".", "Command", ";", "import", "org", ".", "eclim", ".", "command", ".", "CommandLine", ";", "import", "org", ".", "eclim", ".", "command", ".", "Options", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "command", ".", "AbstractCommand", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "util", ".", "JavaUtils", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "util", ".", "TypeUtils", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "ICompilationUnit", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IField", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IJavaElement", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IMethod", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IType", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "Signature", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "dom", ".", "CompilationUnit", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "dom", ".", "IMethodBinding", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "dom", ".", "ITypeBinding", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "dom", ".", "IVariableBinding", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "dom", ".", "Modifier", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "formatter", ".", "CodeFormatter", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "corext", ".", "codemanipulation", ".", "AddCustomConstructorOperation", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "corext", ".", "codemanipulation", ".", "CodeGenerationSettings", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "corext", ".", "codemanipulation", ".", "StubUtility2", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "corext", ".", "dom", ".", "ASTNodes", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "corext", ".", "dom", ".", "Bindings", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "corext", ".", "refactoring", ".", "structure", ".", "ASTNodeSearchUtil", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "ui", ".", "actions", ".", "ActionMessages", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "ui", ".", "preferences", ".", "JavaPreferencesSettings", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "ui", ".", "SharedASTProvider", ";", "import", "org", ".", "eclipse", ".", "text", ".", "edits", ".", "TextEdit", ";", "import", "com", ".", "google", ".", "gson", ".", "Gson", ";", "@", "Command", "(", "name", "=", "\"\"", ",", "options", "=", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", ")", "public", "class", "ConstructorCommand", "extends", "AbstractCommand", "{", "@", "Override", "public", "Object", "execute", "(", "CommandLine", "commandLine", ")", "throws", "Exception", "{", "String", "project", "=", "commandLine", ".", "getValue", "(", "Options", ".", "PROJECT_OPTION", ")", ";", "String", "file", "=", "commandLine", ".", "getValue", "(", "Options", ".", "FILE_OPTION", ")", ";", "String", "propertiesOption", "=", "commandLine", ".", "getValue", "(", "Options", ".", "PROPERTIES_OPTION", ")", ";", "int", "offset", "=", "getOffset", "(", "commandLine", ")", ";", "String", "[", "]", "properties", "=", "{", "}", ";", "if", "(", "propertiesOption", "!=", "null", ")", "{", "properties", "=", "new", "Gson", "(", ")", ".", "fromJson", "(", "propertiesOption", ",", "String", "[", "]", ".", "class", ")", ";", "}", "ICompilationUnit", "src", "=", "JavaUtils", ".", "getCompilationUnit", "(", "project", ",", "file", ")", ";", "IType", "type", "=", "TypeUtils", ".", "getType", "(", "src", ",", "offset", ")", ";", "CompilationUnit", "cu", "=", "SharedASTProvider", ".", "getAST", "(", "src", ",", "SharedASTProvider", ".", "WAIT_YES", ",", "null", ")", ";", "ITypeBinding", "typeBinding", "=", "ASTNodes", ".", "getTypeBinding", "(", "cu", ",", "type", ")", ";", "if", "(", "typeBinding", ".", "isAnonymous", "(", ")", ")", "{", "return", "ActionMessages", ".", "GenerateConstructorUsingFieldsAction_error_anonymous_class", ";", "}", "IVariableBinding", "[", "]", "variables", "=", "new", "IVariableBinding", "[", "properties", ".", "length", "]", ";", "for", "(", "int", "ii", "=", "0", ";", "ii", "<", "properties", ".", "length", ";", "ii", "++", ")", "{", "IField", "field", "=", "type", ".", "getField", "(", "properties", "[", "ii", "]", ")", ";", "if", "(", "!", "field", ".", "exists", "(", ")", ")", "{", "return", "Services", ".", "getMessage", "(", "\"\"", ",", "properties", "[", "ii", "]", ",", "type", ".", "getElementName", "(", ")", ")", ";", "}", "variables", "[", "ii", "]", "=", "ASTNodeSearchUtil", ".", "getFieldDeclarationFragmentNode", "(", "field", ",", "cu", ")", ".", "resolveBinding", "(", ")", ";", "}", "if", "(", "findExistingConstructor", "(", "type", ",", "properties", ")", ".", "exists", "(", ")", ")", "{", "return", "Services", ".", "getMessage", "(", "\"\"", ",", "type", ".", "getElementName", "(", ")", "+", "'('", "+", "buildParams", "(", "type", ",", "properties", ")", "+", "')'", ")", ";", "}", "IMethodBinding", "constructor", "=", "findParentConstructor", "(", "cu", ",", "typeBinding", ",", "variables", ")", ";", "if", "(", "constructor", "==", "null", ")", "{", "return", "ActionMessages", ".", "GenerateConstructorUsingFieldsAction_error_nothing_found", ";", "}", "insertConstructor", "(", "src", ",", "cu", ",", "typeBinding", ",", "variables", ",", "constructor", ",", "commandLine", ")", ";", "return", "null", ";", "}", "private", "void", "insertConstructor", "(", "ICompilationUnit", "src", ",", "CompilationUnit", "cu", ",", "ITypeBinding", "typeBinding", ",", "IVariableBinding", "[", "]", "variables", ",", "IMethodBinding", "constructor", ",", "CommandLine", "commandLine", ")", "throws", "Exception", "{", "CodeGenerationSettings", "settings", "=", "JavaPreferencesSettings", ".", "getCodeGenerationSettings", "(", "src", ".", "getJavaProject", "(", ")", ")", ";", "settings", ".", "createComments", "=", "true", ";", "boolean", "isDefault", "=", "constructor", ".", "getDeclaringClass", "(", ")", ".", "getQualifiedName", "(", ")", ".", "equals", "(", "\"\"", ")", "||", "constructor", ".", "isDefaultConstructor", "(", ")", ";", "AddCustomConstructorOperation", "op", "=", "new", "AddCustomConstructorOperation", "(", "cu", ",", "typeBinding", ",", "variables", ",", "constructor", ",", "getSibling", "(", "(", "IType", ")", "typeBinding", ".", "getJavaElement", "(", ")", ")", ",", "settings", ",", "true", ",", "true", ")", ";", "op", ".", "setOmitSuper", "(", "!", "commandLine", ".", "hasOption", "(", "Options", ".", "SUPERTYPE_OPTION", ")", "||", "isDefault", ")", ";", "if", "(", "!", "typeBinding", ".", "isEnum", "(", ")", ")", "{", "op", ".", "setVisibility", "(", "Modifier", ".", "PUBLIC", ")", ";", "}", "op", ".", "run", "(", "null", ")", ";", "TextEdit", "edit", "=", "op", ".", "getResultingEdit", "(", ")", ";", "if", "(", "edit", "!=", "null", ")", "{", "edit", "=", "edit", ".", "getChildren", "(", ")", "[", "0", "]", ";", "JavaUtils", ".", "format", "(", "src", ",", "CodeFormatter", ".", "K_COMPILATION_UNIT", ",", "edit", ".", "getOffset", "(", ")", ",", "edit", ".", "getLength", "(", ")", ")", ";", "}", "}", "private", "IMethod", "findExistingConstructor", "(", "IType", "type", ",", "String", "[", "]", "properties", ")", "throws", "Exception", "{", "if", "(", "properties", ".", "length", "==", "0", ")", "{", "return", "type", ".", "getMethod", "(", "type", ".", "getElementName", "(", ")", ",", "null", ")", ";", "}", "String", "[", "]", "fieldSigs", "=", "new", "String", "[", "properties", ".", "length", "]", ";", "for", "(", "int", "ii", "=", "0", ";", "ii", "<", "properties", ".", "length", ";", "ii", "++", ")", "{", "fieldSigs", "[", "ii", "]", "=", "type", ".", "getField", "(", "properties", "[", "ii", "]", ")", ".", "getTypeSignature", "(", ")", ";", "}", "return", "type", ".", "getMethod", "(", "type", ".", "getElementName", "(", ")", ",", "fieldSigs", ")", ";", "}", "private", "IMethodBinding", "findParentConstructor", "(", "CompilationUnit", "cu", ",", "ITypeBinding", "typeBinding", ",", "IVariableBinding", "[", "]", "variables", ")", "{", "IMethodBinding", "constructor", "=", "null", ";", "if", "(", "typeBinding", ".", "isEnum", "(", ")", "||", "variables", ".", "length", "!=", "0", ")", "{", "ITypeBinding", "binding", "=", "cu", ".", "getAST", "(", ")", ".", "resolveWellKnownType", "(", "\"\"", ")", ";", "constructor", "=", "Bindings", ".", "findMethodInType", "(", "binding", ",", "\"Object\"", ",", "new", "ITypeBinding", "[", "0", "]", ")", ";", "}", "else", "{", "IMethodBinding", "[", "]", "bindings", "=", "StubUtility2", ".", "getVisibleConstructors", "(", "typeBinding", ",", "false", ",", "true", ")", ";", "Arrays", ".", "sort", "(", "bindings", ",", "new", "Comparator", "<", "IMethodBinding", ">", "(", ")", "{", "public", "int", "compare", "(", "IMethodBinding", "b1", ",", "IMethodBinding", "b2", ")", "{", "return", "b1", ".", "getParameterTypes", "(", ")", ".", "length", "-", "b2", ".", "getParameterTypes", "(", ")", ".", "length", ";", "}", "}", ")", ";", "constructor", "=", "bindings", ".", "length", ">", "0", "?", "bindings", "[", "0", "]", ":", "null", ";", "}", "return", "constructor", ";", "}", "private", "IJavaElement", "getSibling", "(", "IType", "type", ")", "throws", "Exception", "{", "IJavaElement", "sibling", "=", "null", ";", "IMethod", "[", "]", "methods", "=", "type", ".", "getMethods", "(", ")", ";", "for", "(", "int", "ii", "=", "0", ";", "ii", "<", "methods", ".", "length", ";", "ii", "++", ")", "{", "if", "(", "methods", "[", "ii", "]", ".", "isConstructor", "(", ")", ")", "{", "sibling", "=", "ii", "<", "methods", ".", "length", "-", "1", "?", "methods", "[", "ii", "+", "1", "]", ":", "null", ";", "}", "}", "if", "(", "sibling", "==", "null", ")", "{", "if", "(", "methods", ".", "length", ">", "0", ")", "{", "sibling", "=", "methods", "[", "0", "]", ";", "}", "else", "{", "IType", "[", "]", "types", "=", "type", ".", "getTypes", "(", ")", ";", "sibling", "=", "types", "!=", "null", "&&", "types", ".", "length", ">", "0", "?", "types", "[", "0", "]", ":", "null", ";", "}", "}", "return", "sibling", ";", "}", "private", "String", "buildParams", "(", "IType", "type", ",", "String", "[", "]", "fields", ")", "throws", "Exception", "{", "StringBuffer", "params", "=", "new", "StringBuffer", "(", ")", ";", "for", "(", "int", "ii", "=", "0", ";", "ii", "<", "fields", ".", "length", ";", "ii", "++", ")", "{", "if", "(", "ii", "!=", "0", ")", "{", "params", ".", "append", "(", "\",", "\"", ")", ";", "}", "IField", "field", "=", "type", ".", "getField", "(", "fields", "[", "ii", "]", ")", ";", "params", ".", "append", "(", "Signature", ".", "getSignatureSimpleName", "(", "field", ".", "getTypeSignature", "(", ")", ")", ")", ".", "append", "(", "'", "'", ")", ".", "append", "(", "field", ".", "getElementName", "(", ")", ")", ";", "}", "return", "params", ".", "toString", "(", ")", ";", "}", "}", "</s>" ]
1,253
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "impl", ";", "import", "java", ".", "util", ".", "Arrays", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang", ".", "StringUtils", ";", "import", "org", ".", "eclim", ".", "annotation", ".", "Command", ";", "import", "org", ".", "eclim", ".", "command", ".", "CommandLine", ";", "import", "org", ".", "eclim", ".", "command", ".", "Options", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "command", ".", "AbstractCommand", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "util", ".", "ASTUtils", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "util", ".", "JavaUtils", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "util", ".", "MethodUtils", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "util", ".", "TypeUtils", ";", "import", "org", ".", "eclim", ".", "util", ".", "file", ".", "Position", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "ICompilationUnit", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IField", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IJavaElement", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IMethod", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IType", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "Signature", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "dom", ".", "Modifier", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "formatter", ".", "CodeFormatter", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "corext", ".", "codemanipulation", ".", "AddGetterSetterOperation", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "corext", ".", "codemanipulation", ".", "CodeGenerationSettings", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "corext", ".", "codemanipulation", ".", "GetterSetterUtil", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "ui", ".", "preferences", ".", "JavaPreferencesSettings", ";", "import", "org", ".", "eclipse", ".", "text", ".", "edits", ".", "TextEdit", ";", "@", "Command", "(", "name", "=", "\"\"", ",", "options", "=", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", ")", "public", "class", "BeanPropertiesCommand", "extends", "AbstractCommand", "{", "private", "static", "final", "String", "GETTER", "=", "\"getter\"", ";", "private", "static", "final", "String", "SETTER", "=", "\"setter\"", ";", "private", "static", "final", "int", "TYPE_GET", "=", "0", ";", "private", "static", "final", "int", "TYPE_GET_INDEX", "=", "1", ";", "private", "static", "final", "int", "TYPE_SET", "=", "2", ";", "private", "static", "final", "int", "TYPE_SET_INDEX", "=", "3", ";", "private", "static", "final", "String", "INT_SIG", "=", "Signature", ".", "createTypeSignature", "(", "\"int\"", ",", "true", ")", ";", "private", "static", "final", "String", "[", "]", "INT_ARG", "=", "new", "String", "[", "]", "{", "INT_SIG", "}", ";", "private", "static", "final", "IField", "[", "]", "NO_FIELDS", "=", "new", "IField", "[", "0", "]", ";", "@", "Override", "public", "Object", "execute", "(", "CommandLine", "commandLine", ")", "throws", "Exception", "{", "String", "project", "=", "commandLine", ".", "getValue", "(", "Options", ".", "PROJECT_OPTION", ")", ";", "String", "file", "=", "commandLine", ".", "getValue", "(", "Options", ".", "FILE_OPTION", ")", ";", "String", "methods", "=", "commandLine", ".", "getValue", "(", "Options", ".", "TYPE_OPTION", ")", ";", "String", "[", "]", "properties", "=", "StringUtils", ".", "split", "(", "commandLine", ".", "getValue", "(", "Options", ".", "PROPERTIES_OPTION", ")", ",", "','", ")", ";", "int", "offset", "=", "getOffset", "(", "commandLine", ")", ";", "boolean", "indexed", "=", "commandLine", ".", "hasOption", "(", "Options", ".", "INDEXED_OPTION", ")", ";", "ICompilationUnit", "src", "=", "JavaUtils", ".", "getCompilationUnit", "(", "project", ",", "file", ")", ";", "IType", "type", "=", "TypeUtils", ".", "getType", "(", "src", ",", "offset", ")", ";", "List", "<", "IField", ">", "fields", "=", "Arrays", ".", "asList", "(", "type", ".", "getFields", "(", ")", ")", ";", "CodeGenerationSettings", "settings", "=", "JavaPreferencesSettings", ".", "getCodeGenerationSettings", "(", "src", ".", "getJavaProject", "(", ")", ")", ";", "settings", ".", "createComments", "=", "true", ";", "for", "(", "String", "property", ":", "properties", ")", "{", "IField", "field", "=", "type", ".", "getField", "(", "property", ")", ";", "if", "(", "field", "!=", "null", ")", "{", "boolean", "isArray", "=", "Signature", ".", "getArrayCount", "(", "field", ".", "getTypeSignature", "(", ")", ")", ">", "0", ";", "IField", "getter", "=", "methods", ".", "indexOf", "(", "GETTER", ")", "!=", "-", "1", "?", "field", ":", "null", ";", "IField", "setter", "=", "methods", ".", "indexOf", "(", "SETTER", ")", "!=", "-", "1", "?", "field", ":", "null", ";", "int", "methodType", "=", "getter", "!=", "null", "?", "TYPE_GET", ":", "TYPE_SET", ";", "if", "(", "getter", "!=", "null", "&&", "setter", "!=", "null", "&&", "GetterSetterUtil", ".", "getGetter", "(", "field", ")", "!=", "null", ")", "{", "methodType", "=", "TYPE_SET", ";", "}", "IJavaElement", "sibling", "=", "getSibling", "(", "type", ",", "fields", ",", "field", ",", "methodType", ")", ";", "insertMethods", "(", "src", ",", "type", ",", "sibling", ",", "settings", ",", "getter", ",", "setter", ")", ";", "if", "(", "isArray", "&&", "indexed", ")", "{", "insertIndexMethods", "(", "src", ",", "type", ",", "fields", ",", "settings", ",", "getter", ",", "setter", ")", ";", "}", "}", "}", "return", "null", ";", "}", "private", "void", "insertMethods", "(", "ICompilationUnit", "src", ",", "IType", "type", ",", "IJavaElement", "sibling", ",", "CodeGenerationSettings", "settings", ",", "IField", "getter", ",", "IField", "setter", ")", "throws", "Exception", "{", "AddGetterSetterOperation", "op", "=", "new", "AddGetterSetterOperation", "(", "type", ",", "getter", "!=", "null", "?", "new", "IField", "[", "]", "{", "getter", "}", ":", "NO_FIELDS", ",", "setter", "!=", "null", "?", "new", "IField", "[", "]", "{", "setter", "}", ":", "NO_FIELDS", ",", "NO_FIELDS", ",", "ASTUtils", ".", "getCompilationUnit", "(", "src", ")", ",", "null", ",", "sibling", ",", "settings", ",", "true", ",", "true", ")", ";", "op", ".", "run", "(", "null", ")", ";", "TextEdit", "edit", "=", "op", ".", "getResultingEdit", "(", ")", ";", "if", "(", "edit", "!=", "null", ")", "{", "JavaUtils", ".", "format", "(", "src", ",", "CodeFormatter", ".", "K_COMPILATION_UNIT", ",", "edit", ".", "getOffset", "(", ")", ",", "edit", ".", "getLength", "(", ")", ")", ";", "}", "}", "private", "void", "insertIndexMethods", "(", "ICompilationUnit", "src", ",", "IType", "type", ",", "List", "<", "IField", ">", "fields", ",", "CodeGenerationSettings", "settings", ",", "IField", "getter", ",", "IField", "setter", ")", "throws", "Exception", "{", "if", "(", "getter", "!=", "null", ")", "{", "IMethod", "existing", "=", "getBeanMethod", "(", "type", ",", "getter", ",", "TYPE_GET_INDEX", ")", ";", "if", "(", "existing", "==", "null", ")", "{", "IJavaElement", "sibling", "=", "getSibling", "(", "type", ",", "fields", ",", "getter", ",", "TYPE_GET_INDEX", ")", ";", "String", "name", "=", "GetterSetterUtil", ".", "getGetterName", "(", "getter", ",", "null", ")", ";", "String", "stub", "=", "GetterSetterUtil", ".", "getGetterStub", "(", "getter", ",", "name", ",", "settings", ".", "createComments", ",", "Modifier", ".", "PUBLIC", ")", ";", "stub", "=", "stub", ".", "replaceFirst", "(", "\"\"", ",", "\"\"", ")", ";", "stub", "=", "stub", ".", "replaceFirst", "(", "\"\\\\[\\\\]\\\\s*(\"", "+", "name", "+", "\"\\\\s*\\\\()\\\\)\"", ",", "\"\"", ")", ";", "stub", "=", "stub", ".", "replaceFirst", "(", "\"\"", ",", "\"$1[index]$2\"", ")", ";", "IMethod", "inserted", "=", "type", ".", "createMethod", "(", "stub", ",", "sibling", ",", "false", ",", "null", ")", ";", "Position", "position", "=", "TypeUtils", ".", "getPosition", "(", "type", ",", "inserted", ")", ";", "JavaUtils", ".", "format", "(", "src", ",", "CodeFormatter", ".", "K_COMPILATION_UNIT", ",", "position", ".", "getOffset", "(", ")", ",", "position", ".", "getLength", "(", ")", ")", ";", "}", "}", "if", "(", "setter", "!=", "null", ")", "{", "IMethod", "existing", "=", "getBeanMethod", "(", "type", ",", "setter", ",", "TYPE_SET_INDEX", ")", ";", "if", "(", "existing", "==", "null", ")", "{", "IJavaElement", "sibling", "=", "getSibling", "(", "type", ",", "fields", ",", "setter", ",", "TYPE_SET_INDEX", ")", ";", "String", "name", "=", "GetterSetterUtil", ".", "getSetterName", "(", "setter", ",", "null", ")", ";", "String", "stub", "=", "GetterSetterUtil", ".", "getSetterStub", "(", "setter", ",", "name", ",", "settings", ".", "createComments", ",", "Modifier", ".", "PUBLIC", ")", ";", "stub", "=", "stub", ".", "replaceFirst", "(", "\"\"", ",", "\"\"", ")", ";", "stub", "=", "stub", ".", "replaceFirst", "(", "\"(\"", "+", "name", "+", "\"\"", ",", "\"\"", ")", ";", "stub", "=", "stub", ".", "replaceFirst", "(", "\"\"", ",", "\"$1[index]$2\"", ")", ";", "IMethod", "inserted", "=", "type", ".", "createMethod", "(", "stub", ",", "sibling", ",", "false", ",", "null", ")", ";", "Position", "position", "=", "TypeUtils", ".", "getPosition", "(", "type", ",", "inserted", ")", ";", "JavaUtils", ".", "format", "(", "src", ",", "CodeFormatter", ".", "K_COMPILATION_UNIT", ",", "position", ".", "getOffset", "(", ")", ",", "position", ".", "getLength", "(", ")", ")", ";", "}", "}", "}", "private", "IJavaElement", "getSibling", "(", "IType", "type", ",", "List", "<", "IField", ">", "fields", ",", "IField", "field", ",", "int", "methodType", ")", "throws", "Exception", "{", "IMethod", "siblingMethod", "=", "null", ";", "int", "siblingType", "=", "TYPE_GET", ";", "for", "(", "int", "ii", "=", "TYPE_GET", ";", "ii", "<=", "TYPE_SET_INDEX", ";", "ii", "++", ")", "{", "IMethod", "method", "=", "getBeanMethod", "(", "type", ",", "field", ",", "ii", ")", ";", "if", "(", "method", "!=", "null", ")", "{", "siblingMethod", "=", "method", ";", "siblingType", "=", "ii", ";", "}", "}", "if", "(", "siblingMethod", "!=", "null", ")", "{", "if", "(", "siblingType", "<", "methodType", ")", "{", "siblingMethod", "=", "MethodUtils", ".", "getMethodAfter", "(", "type", ",", "siblingMethod", ")", ";", "}", "if", "(", "siblingMethod", "!=", "null", ")", "{", "return", "siblingMethod", ";", "}", "return", "getFirstInnerType", "(", "type", ")", ";", "}", "int", "index", "=", "fields", ".", "indexOf", "(", "field", ")", ";", "if", "(", "fields", ".", "size", "(", ")", ">", "1", "&&", "(", "index", "+", "1", ")", "<", "fields", ".", "size", "(", ")", ")", "{", "IMethod", "method", "=", "null", ";", "for", "(", "int", "ii", "=", "index", "+", "1", ";", "method", "==", "null", "&&", "ii", "<", "fields", ".", "size", "(", ")", ";", "ii", "++", ")", "{", "IField", "property", "=", "(", "IField", ")", "fields", ".", "get", "(", "ii", ")", ";", "method", "=", "getBeanMethod", "(", "type", ",", "property", ",", "false", ")", ";", "}", "if", "(", "method", "!=", "null", ")", "{", "return", "method", ";", "}", "}", "if", "(", "fields", ".", "size", "(", ")", ">", "1", "&&", "index", ">", "0", ")", "{", "IMethod", "method", "=", "null", ";", "for", "(", "int", "ii", "=", "index", "-", "1", ";", "method", "==", "null", "&&", "ii", ">=", "0", ";", "ii", "--", ")", "{", "IField", "property", "=", "(", "IField", ")", "fields", ".", "get", "(", "ii", ")", ";", "method", "=", "getBeanMethod", "(", "type", ",", "property", ",", "true", ")", ";", "}", "if", "(", "method", "!=", "null", ")", "{", "method", "=", "MethodUtils", ".", "getMethodAfter", "(", "type", ",", "method", ")", ";", "if", "(", "method", "!=", "null", ")", "{", "return", "method", ";", "}", "}", "}", "return", "getFirstInnerType", "(", "type", ")", ";", "}", "private", "IType", "getFirstInnerType", "(", "IType", "type", ")", "throws", "Exception", "{", "IType", "[", "]", "types", "=", "type", ".", "getTypes", "(", ")", ";", "for", "(", "int", "ii", "=", "0", ";", "ii", "<", "types", ".", "length", ";", "ii", "++", ")", "{", "if", "(", "!", "types", "[", "ii", "]", ".", "isEnum", "(", ")", ")", "{", "return", "types", "[", "ii", "]", ";", "}", "}", "return", "null", ";", "}", "private", "IMethod", "getBeanMethod", "(", "IType", "type", ",", "IField", "field", ",", "int", "methodType", ")", "throws", "Exception", "{", "String", "name", "=", "Signature", ".", "getSignatureSimpleName", "(", "field", ".", "getTypeSignature", "(", ")", ")", ";", "boolean", "isArray", "=", "Signature", ".", "getArrayCount", "(", "field", ".", "getTypeSignature", "(", ")", ")", ">", "0", ";", "String", "signature", "=", "null", ";", "switch", "(", "methodType", ")", "{", "case", "TYPE_GET", ":", "return", "GetterSetterUtil", ".", "getGetter", "(", "field", ")", ";", "case", "TYPE_GET_INDEX", ":", "if", "(", "isArray", ")", "{", "signature", "=", "GetterSetterUtil", ".", "getGetterName", "(", "field", ",", "null", ")", "+", "\"(int)\"", ";", "}", "break", ";", "case", "TYPE_SET", ":", "return", "GetterSetterUtil", ".", "getSetter", "(", "field", ")", ";", "case", "TYPE_SET_INDEX", ":", "if", "(", "isArray", ")", "{", "signature", "=", "GetterSetterUtil", ".", "getSetterName", "(", "field", ",", "null", ")", "+", "\"(int,", "\"", "+", "name", "+", "')'", ";", "}", "}", "if", "(", "signature", "!=", "null", ")", "{", "IMethod", "[", "]", "methods", "=", "type", ".", "getMethods", "(", ")", ";", "for", "(", "int", "ii", "=", "0", ";", "ii", "<", "methods", ".", "length", ";", "ii", "++", ")", "{", "String", "sig", "=", "MethodUtils", ".", "getMinimalMethodSignature", "(", "methods", "[", "ii", "]", ",", "null", ")", ";", "if", "(", "sig", ".", "equals", "(", "signature", ")", ")", "{", "return", "methods", "[", "ii", "]", ";", "}", "}", "}", "return", "null", ";", "}", "private", "IMethod", "getBeanMethod", "(", "IType", "type", ",", "IField", "field", ",", "boolean", "last", ")", "throws", "Exception", "{", "IMethod", "result", "=", "null", ";", "boolean", "isArray", "=", "Signature", ".", "getArrayCount", "(", "field", ".", "getTypeSignature", "(", ")", ")", ">", "0", ";", "IMethod", "method", "=", "GetterSetterUtil", ".", "getGetter", "(", "field", ")", ";", "if", "(", "method", "!=", "null", "&&", "method", ".", "exists", "(", ")", "&&", "!", "last", ")", "{", "return", "method", ";", "}", "else", "if", "(", "method", "!=", "null", "&&", "method", ".", "exists", "(", ")", ")", "{", "result", "=", "method", ";", "}", "if", "(", "isArray", ")", "{", "method", "=", "type", ".", "getMethod", "(", "GetterSetterUtil", ".", "getGetterName", "(", "field", ",", "null", ")", ",", "INT_ARG", ")", ";", "if", "(", "method", ".", "exists", "(", ")", "&&", "!", "last", ")", "{", "return", "method", ";", "}", "else", "if", "(", "method", ".", "exists", "(", ")", ")", "{", "result", "=", "method", ";", "}", "}", "method", "=", "GetterSetterUtil", ".", "getSetter", "(", "field", ")", ";", "if", "(", "method", "!=", "null", "&&", "method", ".", "exists", "(", ")", "&&", "!", "last", ")", "{", "return", "method", ";", "}", "else", "if", "(", "method", "!=", "null", "&&", "method", ".", "exists", "(", ")", ")", "{", "result", "=", "method", ";", "}", "if", "(", "!", "isArray", ")", "{", "String", "elementType", "=", "Signature", ".", "getElementType", "(", "field", ".", "getTypeSignature", "(", ")", ")", ";", "method", "=", "type", ".", "getMethod", "(", "GetterSetterUtil", ".", "getSetterName", "(", "field", ",", "null", ")", ",", "new", "String", "[", "]", "{", "INT_SIG", ",", "elementType", "}", ")", ";", "if", "(", "method", ".", "exists", "(", ")", ")", "{", "result", "=", "method", ";", "}", "}", "return", "result", ";", "}", "}", "</s>" ]
1,254
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "impl", ";", "import", "java", ".", "util", ".", "List", ";", "@", "SuppressWarnings", "(", "\"unused\"", ")", "public", "class", "ImplResult", "{", "private", "String", "type", ";", "private", "List", "<", "ImplType", ">", "superTypes", ";", "public", "ImplResult", "(", "String", "type", ",", "List", "<", "ImplType", ">", "superTypes", ")", "{", "this", ".", "type", "=", "type", ";", "this", ".", "superTypes", "=", "superTypes", ";", "}", "}", "</s>" ]
1,255
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "impl", ";", "@", "SuppressWarnings", "(", "\"unused\"", ")", "public", "class", "ImplType", "{", "private", "String", "packageName", ";", "private", "String", "signature", ";", "private", "String", "[", "]", "methods", ";", "public", "ImplType", "(", "String", "packageName", ",", "String", "signature", ",", "String", "[", "]", "methods", ")", "{", "this", ".", "packageName", "=", "packageName", ";", "this", ".", "signature", "=", "signature", ";", "this", ".", "methods", "=", "methods", ";", "}", "}", "</s>" ]
1,256
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "impl", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "HashSet", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Set", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang", ".", "StringUtils", ";", "import", "org", ".", "eclim", ".", "Services", ";", "import", "org", ".", "eclim", ".", "annotation", ".", "Command", ";", "import", "org", ".", "eclim", ".", "command", ".", "CommandLine", ";", "import", "org", ".", "eclim", ".", "command", ".", "Options", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "command", ".", "AbstractCommand", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "util", ".", "JavaUtils", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "util", ".", "MethodUtils", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "util", ".", "TypeUtils", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "IWorkspaceRunnable", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "ICompilationUnit", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IImportDeclaration", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IJavaElement", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IMethod", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "ISourceRange", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "ISourceReference", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IType", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "dom", ".", "CompilationUnit", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "dom", ".", "IMethodBinding", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "dom", ".", "IPackageBinding", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "dom", ".", "ITypeBinding", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "formatter", ".", "CodeFormatter", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "corext", ".", "codemanipulation", ".", "AddUnimplementedMethodsOperation", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "corext", ".", "codemanipulation", ".", "StubUtility2", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "corext", ".", "dom", ".", "ASTNodes", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "corext", ".", "dom", ".", "Bindings", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "corext", ".", "refactoring", ".", "util", ".", "RefactoringASTParser", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "ui", ".", "javaeditor", ".", "ASTProvider", ";", "import", "com", ".", "google", ".", "gson", ".", "Gson", ";", "@", "Command", "(", "name", "=", "\"java_impl\"", ",", "options", "=", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", ")", "public", "class", "ImplCommand", "extends", "AbstractCommand", "{", "@", "Override", "public", "Object", "execute", "(", "CommandLine", "commandLine", ")", "throws", "Exception", "{", "String", "project", "=", "commandLine", ".", "getValue", "(", "Options", ".", "PROJECT_OPTION", ")", ";", "String", "file", "=", "commandLine", ".", "getValue", "(", "Options", ".", "FILE_OPTION", ")", ";", "ICompilationUnit", "src", "=", "JavaUtils", ".", "getCompilationUnit", "(", "project", ",", "file", ")", ";", "IType", "type", "=", "getType", "(", "src", ",", "commandLine", ")", ";", "if", "(", "commandLine", ".", "hasOption", "(", "Options", ".", "SUPERTYPE_OPTION", ")", ")", "{", "insertMethods", "(", "src", ",", "type", ",", "commandLine", ")", ";", "}", "return", "getImplResult", "(", "src", ",", "type", ")", ";", "}", "protected", "IType", "getType", "(", "ICompilationUnit", "src", ",", "CommandLine", "commandLine", ")", "throws", "Exception", "{", "return", "commandLine", ".", "hasOption", "(", "Options", ".", "TYPE_OPTION", ")", "?", "src", ".", "getJavaProject", "(", ")", ".", "findType", "(", "commandLine", ".", "getValue", "(", "Options", ".", "TYPE_OPTION", ")", ".", "replace", "(", "'$'", ",", "'.'", ")", ")", ":", "TypeUtils", ".", "getType", "(", "src", ",", "getOffset", "(", "commandLine", ")", ")", ";", "}", "protected", "IWorkspaceRunnable", "getImplOperation", "(", "ICompilationUnit", "src", ",", "IType", "type", ",", "Set", "<", "String", ">", "chosen", ",", "IJavaElement", "sibling", ",", "int", "pos", ",", "CommandLine", "commandLine", ")", "throws", "Exception", "{", "RefactoringASTParser", "parser", "=", "new", "RefactoringASTParser", "(", "ASTProvider", ".", "SHARED_AST_LEVEL", ")", ";", "CompilationUnit", "cu", "=", "parser", ".", "parse", "(", "type", ".", "getCompilationUnit", "(", ")", ",", "true", ")", ";", "ITypeBinding", "typeBinding", "=", "ASTNodes", ".", "getTypeBinding", "(", "cu", ",", "type", ")", ";", "String", "superType", "=", "commandLine", ".", "getValue", "(", "Options", ".", "SUPERTYPE_OPTION", ")", ";", "List", "<", "IMethodBinding", ">", "overridable", "=", "getOverridableMethods", "(", "cu", ",", "typeBinding", ")", ";", "List", "<", "IMethodBinding", ">", "override", "=", "new", "ArrayList", "<", "IMethodBinding", ">", "(", ")", ";", "for", "(", "IMethodBinding", "binding", ":", "overridable", ")", "{", "ITypeBinding", "declBinding", "=", "binding", ".", "getDeclaringClass", "(", ")", ";", "String", "fqn", "=", "declBinding", ".", "getQualifiedName", "(", ")", ".", "replaceAll", "(", "\"<.*?>\"", ",", "\"\"", ")", ";", "if", "(", "fqn", ".", "equals", "(", "superType", ")", "&&", "isChosen", "(", "chosen", ",", "binding", ")", ")", "{", "override", ".", "add", "(", "binding", ")", ";", "}", "}", "if", "(", "override", ".", "size", "(", ")", ">", "0", ")", "{", "return", "new", "AddUnimplementedMethodsOperation", "(", "cu", ",", "typeBinding", ",", "override", ".", "toArray", "(", "new", "IMethodBinding", "[", "override", ".", "size", "(", ")", "]", ")", ",", "pos", ",", "true", ",", "true", ",", "true", ")", ";", "}", "return", "null", ";", "}", "protected", "boolean", "isChosen", "(", "Set", "<", "String", ">", "chosen", ",", "IMethodBinding", "methodBinding", ")", "{", "return", "chosen", "==", "null", "||", "chosen", ".", "contains", "(", "getMethodBindingShortCallSignature", "(", "methodBinding", ")", ")", ";", "}", "protected", "ImplResult", "getImplResult", "(", "ICompilationUnit", "src", ",", "IType", "type", ")", "throws", "Exception", "{", "List", "<", "IMethodBinding", ">", "overridable", "=", "getOverridableMethods", "(", "src", ",", "type", ")", ";", "return", "getImplResult", "(", "type", ".", "getFullyQualifiedName", "(", ")", ",", "overridable", ")", ";", "}", "protected", "ImplResult", "getImplResult", "(", "String", "name", ",", "List", "<", "IMethodBinding", ">", "methods", ")", "{", "ArrayList", "<", "ImplType", ">", "results", "=", "new", "ArrayList", "<", "ImplType", ">", "(", ")", ";", "ArrayList", "<", "String", ">", "overrideMethods", "=", "null", ";", "ITypeBinding", "curTypeBinding", "=", "null", ";", "for", "(", "IMethodBinding", "methodBinding", ":", "methods", ")", "{", "ITypeBinding", "typeBinding", "=", "methodBinding", ".", "getDeclaringClass", "(", ")", ";", "if", "(", "typeBinding", "!=", "curTypeBinding", ")", "{", "if", "(", "overrideMethods", "!=", "null", "&&", "overrideMethods", ".", "size", "(", ")", ">", "0", ")", "{", "results", ".", "add", "(", "createImplType", "(", "curTypeBinding", ",", "overrideMethods", ")", ")", ";", "}", "overrideMethods", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "}", "curTypeBinding", "=", "typeBinding", ";", "overrideMethods", ".", "add", "(", "getMethodBindingSignature", "(", "methodBinding", ")", ")", ";", "}", "if", "(", "overrideMethods", "!=", "null", "&&", "overrideMethods", ".", "size", "(", ")", ">", "0", ")", "{", "results", ".", "add", "(", "createImplType", "(", "curTypeBinding", ",", "overrideMethods", ")", ")", ";", "}", "return", "new", "ImplResult", "(", "name", ",", "results", ")", ";", "}", "protected", "List", "<", "IMethodBinding", ">", "getOverridableMethods", "(", "ICompilationUnit", "src", ",", "IType", "type", ")", "throws", "Exception", "{", "RefactoringASTParser", "parser", "=", "new", "RefactoringASTParser", "(", "ASTProvider", ".", "SHARED_AST_LEVEL", ")", ";", "CompilationUnit", "cu", "=", "parser", ".", "parse", "(", "type", ".", "getCompilationUnit", "(", ")", ",", "true", ")", ";", "ITypeBinding", "typeBinding", "=", "ASTNodes", ".", "getTypeBinding", "(", "cu", ",", "type", ")", ";", "return", "getOverridableMethods", "(", "cu", ",", "typeBinding", ")", ";", "}", "protected", "List", "<", "IMethodBinding", ">", "getOverridableMethods", "(", "CompilationUnit", "cu", ",", "ITypeBinding", "typeBinding", ")", "throws", "Exception", "{", "if", "(", "!", "typeBinding", ".", "isClass", "(", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "Services", ".", "getMessage", "(", "\"\"", ",", "typeBinding", ".", "getQualifiedName", "(", ")", ")", ")", ";", "}", "IPackageBinding", "packageBinding", "=", "typeBinding", ".", "getPackage", "(", ")", ";", "IMethodBinding", "[", "]", "methods", "=", "StubUtility2", ".", "getOverridableMethods", "(", "cu", ".", "getAST", "(", ")", ",", "typeBinding", ",", "false", ")", ";", "ArrayList", "<", "IMethodBinding", ">", "overridable", "=", "new", "ArrayList", "<", "IMethodBinding", ">", "(", ")", ";", "for", "(", "IMethodBinding", "methodBinding", ":", "methods", ")", "{", "if", "(", "Bindings", ".", "isVisibleInHierarchy", "(", "methodBinding", ",", "packageBinding", ")", ")", "{", "overridable", ".", "add", "(", "methodBinding", ")", ";", "}", "}", "return", "overridable", ";", "}", "private", "ImplType", "createImplType", "(", "ITypeBinding", "typeBinding", ",", "List", "<", "String", ">", "overridable", ")", "{", "String", "signature", "=", "(", "typeBinding", ".", "isInterface", "(", ")", "?", "\"interface", "\"", ":", "\"class", "\"", ")", "+", "typeBinding", ".", "getName", "(", ")", ".", "replaceAll", "(", "\"#RAW\"", ",", "\"\"", ")", ";", "return", "new", "ImplType", "(", "typeBinding", ".", "getPackage", "(", ")", ".", "getName", "(", ")", ",", "signature", ",", "overridable", ".", "toArray", "(", "new", "String", "[", "overridable", ".", "size", "(", ")", "]", ")", ")", ";", "}", "private", "void", "insertMethods", "(", "ICompilationUnit", "src", ",", "IType", "type", ",", "CommandLine", "commandLine", ")", "throws", "Exception", "{", "String", "methodsOption", "=", "commandLine", ".", "getValue", "(", "Options", ".", "METHOD_OPTION", ")", ";", "HashSet", "<", "String", ">", "chosen", "=", "null", ";", "if", "(", "methodsOption", "!=", "null", ")", "{", "chosen", "=", "new", "HashSet", "<", "String", ">", "(", ")", ";", "String", "[", "]", "sigs", "=", "new", "Gson", "(", ")", ".", "fromJson", "(", "methodsOption", ",", "String", "[", "]", ".", "class", ")", ";", "for", "(", "String", "sig", ":", "sigs", ")", "{", "chosen", ".", "add", "(", "sig", ".", "replace", "(", "\"", "\"", ",", "\"\"", ")", ")", ";", "}", "}", "int", "pos", "=", "-", "1", ";", "int", "len", "=", "src", ".", "getBuffer", "(", ")", ".", "getLength", "(", ")", ";", "IJavaElement", "sibling", "=", "getSibling", "(", "type", ")", ";", "if", "(", "sibling", "!=", "null", ")", "{", "pos", "=", "(", "(", "ISourceReference", ")", "sibling", ")", ".", "getSourceRange", "(", ")", ".", "getOffset", "(", ")", ";", "}", "IWorkspaceRunnable", "op", "=", "getImplOperation", "(", "src", ",", "type", ",", "chosen", ",", "sibling", ",", "pos", ",", "commandLine", ")", ";", "if", "(", "op", "!=", "null", ")", "{", "String", "lineDelim", "=", "src", ".", "findRecommendedLineSeparator", "(", ")", ";", "IImportDeclaration", "[", "]", "imports", "=", "src", ".", "getImports", "(", ")", ";", "int", "importsEnd", "=", "-", "1", ";", "if", "(", "imports", ".", "length", ">", "0", ")", "{", "ISourceRange", "last", "=", "imports", "[", "imports", ".", "length", "-", "1", "]", ".", "getSourceRange", "(", ")", ";", "importsEnd", "=", "last", ".", "getOffset", "(", ")", "+", "last", ".", "getLength", "(", ")", "+", "lineDelim", ".", "length", "(", ")", ";", "}", "op", ".", "run", "(", "null", ")", ";", "int", "offset", "=", "pos", "!=", "-", "1", "?", "pos", ":", "(", "len", "-", "1", "-", "lineDelim", ".", "length", "(", ")", ")", ";", "int", "newLen", "=", "src", ".", "getBuffer", "(", ")", ".", "getLength", "(", ")", ";", "int", "length", "=", "newLen", "-", "len", "-", "1", ";", "int", "importLenChange", "=", "0", ";", "imports", "=", "src", ".", "getImports", "(", ")", ";", "if", "(", "importsEnd", "!=", "-", "1", ")", "{", "ISourceRange", "last", "=", "imports", "[", "imports", ".", "length", "-", "1", "]", ".", "getSourceRange", "(", ")", ";", "importLenChange", "=", "last", ".", "getOffset", "(", ")", "+", "last", ".", "getLength", "(", ")", "+", "lineDelim", ".", "length", "(", ")", "-", "importsEnd", ";", "}", "else", "if", "(", "imports", ".", "length", ">", "0", ")", "{", "ISourceRange", "first", "=", "imports", "[", "0", "]", ".", "getSourceRange", "(", ")", ";", "ISourceRange", "last", "=", "imports", "[", "imports", ".", "length", "-", "1", "]", ".", "getSourceRange", "(", ")", ";", "importLenChange", "=", "last", ".", "getOffset", "(", ")", "+", "last", ".", "getLength", "(", ")", "+", "(", "lineDelim", ".", "length", "(", ")", "*", "2", ")", "-", "first", ".", "getOffset", "(", ")", ";", "}", "offset", "+=", "importLenChange", ";", "length", "-=", "importLenChange", ";", "JavaUtils", ".", "format", "(", "src", ",", "CodeFormatter", ".", "K_COMPILATION_UNIT", ",", "offset", ",", "length", ")", ";", "}", "}", "private", "String", "getMethodBindingSignature", "(", "IMethodBinding", "binding", ")", "{", "return", "binding", ".", "toString", "(", ")", ".", "trim", "(", ")", ".", "replaceAll", "(", "\"\"", ",", "\"\"", ")", ".", "replaceAll", "(", "\"\"", ",", "\"\"", ")", ".", "replaceFirst", "(", "\"\"", ",", "getMethodBindingCallSignature", "(", "binding", ")", ")", ";", "}", "private", "String", "getMethodBindingCallSignature", "(", "IMethodBinding", "binding", ")", "{", "ITypeBinding", "[", "]", "paramTypes", "=", "binding", ".", "getParameterTypes", "(", ")", ";", "String", "[", "]", "params", "=", "new", "String", "[", "paramTypes", ".", "length", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "paramTypes", ".", "length", ";", "i", "++", ")", "{", "params", "[", "i", "]", "=", "paramTypes", "[", "i", "]", ".", "getQualifiedName", "(", ")", ".", "replaceAll", "(", "\"\"", ",", "\"\"", ")", ".", "replaceAll", "(", "\"#RAW\"", ",", "\"\"", ")", ";", "}", "return", "binding", ".", "getName", "(", ")", "+", "'('", "+", "StringUtils", ".", "join", "(", "params", ",", "','", ")", "+", "')'", ";", "}", "private", "String", "getMethodBindingShortCallSignature", "(", "IMethodBinding", "binding", ")", "{", "return", "getMethodBindingCallSignature", "(", "binding", ")", ".", "replaceAll", "(", "\"<.*?>\"", ",", "\"\"", ")", ";", "}", "private", "IJavaElement", "getSibling", "(", "IType", "type", ")", "throws", "Exception", "{", "IJavaElement", "sibling", "=", "null", ";", "IMethod", "[", "]", "methods", "=", "type", ".", "getMethods", "(", ")", ";", "if", "(", "methods", ".", "length", ">", "0", ")", "{", "sibling", "=", "MethodUtils", ".", "getMethodAfter", "(", "type", ",", "methods", "[", "methods", ".", "length", "-", "1", "]", ")", ";", "}", "if", "(", "sibling", "==", "null", ")", "{", "IType", "[", "]", "types", "=", "type", ".", "getTypes", "(", ")", ";", "for", "(", "int", "ii", "=", "0", ";", "ii", "<", "types", ".", "length", ";", "ii", "++", ")", "{", "if", "(", "!", "types", "[", "ii", "]", ".", "isEnum", "(", ")", ")", "{", "sibling", "=", "types", "[", "ii", "]", ";", "break", ";", "}", "}", "}", "return", "sibling", ";", "}", "}", "</s>" ]
1,257
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "impl", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Set", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang", ".", "StringUtils", ";", "import", "org", ".", "eclim", ".", "Services", ";", "import", "org", ".", "eclim", ".", "annotation", ".", "Command", ";", "import", "org", ".", "eclim", ".", "command", ".", "CommandLine", ";", "import", "org", ".", "eclim", ".", "command", ".", "Options", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "impl", ".", "ImplCommand", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "util", ".", "JavaUtils", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "util", ".", "TypeUtils", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "IWorkspaceRunnable", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "ICompilationUnit", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IField", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IJavaElement", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IType", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "Signature", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "dom", ".", "CompilationUnit", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "dom", ".", "IMethodBinding", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "dom", ".", "ITypeBinding", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "dom", ".", "IVariableBinding", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "corext", ".", "codemanipulation", ".", "AddDelegateMethodsOperation", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "corext", ".", "codemanipulation", ".", "AddDelegateMethodsOperation", ".", "DelegateEntry", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "corext", ".", "codemanipulation", ".", "CodeGenerationSettings", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "corext", ".", "codemanipulation", ".", "StubUtility2", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "corext", ".", "dom", ".", "ASTNodes", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "corext", ".", "refactoring", ".", "structure", ".", "ASTNodeSearchUtil", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "corext", ".", "refactoring", ".", "util", ".", "RefactoringASTParser", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "ui", ".", "javaeditor", ".", "ASTProvider", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "ui", ".", "preferences", ".", "JavaPreferencesSettings", ";", "@", "Command", "(", "name", "=", "\"\"", ",", "options", "=", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", ")", "public", "class", "DelegateCommand", "extends", "ImplCommand", "{", "private", "ThreadLocal", "<", "IField", ">", "field", "=", "new", "ThreadLocal", "<", "IField", ">", "(", ")", ";", "@", "Override", "public", "Object", "execute", "(", "CommandLine", "commandLine", ")", "throws", "Exception", "{", "String", "project", "=", "commandLine", ".", "getValue", "(", "Options", ".", "PROJECT_OPTION", ")", ";", "String", "file", "=", "commandLine", ".", "getValue", "(", "Options", ".", "FILE_OPTION", ")", ";", "ICompilationUnit", "src", "=", "JavaUtils", ".", "getCompilationUnit", "(", "project", ",", "file", ")", ";", "IJavaElement", "element", "=", "null", ";", "if", "(", "commandLine", ".", "hasOption", "(", "Options", ".", "VARIABLE_OPTION", ")", ")", "{", "String", "var", "=", "commandLine", ".", "getValue", "(", "Options", ".", "VARIABLE_OPTION", ")", ";", "String", "[", "]", "parts", "=", "StringUtils", ".", "split", "(", "var", ",", "\".\"", ")", ";", "String", "varName", "=", "parts", "[", "parts", ".", "length", "-", "1", "]", ";", "IType", "type", "=", "getType", "(", "src", ",", "commandLine", ")", ";", "element", "=", "type", ".", "getField", "(", "varName", ")", ";", "}", "else", "{", "element", "=", "src", ".", "getElementAt", "(", "getOffset", "(", "commandLine", ")", ")", ";", "}", "if", "(", "element", "==", "null", "||", "element", ".", "getElementType", "(", ")", "!=", "IJavaElement", ".", "FIELD", ")", "{", "return", "Services", ".", "getMessage", "(", "\"not.a.field\"", ")", ";", "}", "IField", "field", "=", "(", "IField", ")", "element", ";", "String", "signature", "=", "field", ".", "getTypeSignature", "(", ")", ";", "IType", "delegateType", "=", "TypeUtils", ".", "findUnqualifiedType", "(", "src", ",", "Signature", ".", "getSignatureSimpleName", "(", "signature", ")", ")", ";", "if", "(", "delegateType", "==", "null", ")", "{", "return", "Services", ".", "getMessage", "(", "\"\"", ",", "src", ".", "getJavaProject", "(", ")", ".", "getElementName", "(", ")", ",", "Signature", ".", "getSignatureSimpleName", "(", "signature", ")", ")", "+", "\"", "\"", "+", "Services", ".", "getMessage", "(", "\"check.import\"", ")", ";", "}", "this", ".", "field", ".", "set", "(", "field", ")", ";", "return", "super", ".", "execute", "(", "commandLine", ")", ";", "}", "@", "Override", "protected", "IType", "getType", "(", "ICompilationUnit", "src", ",", "CommandLine", "commandLine", ")", "throws", "Exception", "{", "if", "(", "commandLine", ".", "hasOption", "(", "Options", ".", "VARIABLE_OPTION", ")", ")", "{", "String", "var", "=", "commandLine", ".", "getValue", "(", "Options", ".", "VARIABLE_OPTION", ")", ";", "String", "[", "]", "parts", "=", "StringUtils", ".", "split", "(", "var", ",", "\".\"", ")", ";", "String", "typeName", "=", "StringUtils", ".", "join", "(", "parts", ",", "'.'", ",", "0", ",", "parts", ".", "length", "-", "1", ")", ";", "return", "src", ".", "getJavaProject", "(", ")", ".", "findType", "(", "typeName", ".", "replace", "(", "'$'", ",", "'.'", ")", ")", ";", "}", "return", "super", ".", "getType", "(", "src", ",", "commandLine", ")", ";", "}", "@", "Override", "protected", "IWorkspaceRunnable", "getImplOperation", "(", "ICompilationUnit", "src", ",", "IType", "type", ",", "Set", "<", "String", ">", "chosen", ",", "IJavaElement", "sibling", ",", "int", "pos", ",", "CommandLine", "commandLine", ")", "throws", "Exception", "{", "RefactoringASTParser", "parser", "=", "new", "RefactoringASTParser", "(", "ASTProvider", ".", "SHARED_AST_LEVEL", ")", ";", "CompilationUnit", "cu", "=", "parser", ".", "parse", "(", "type", ".", "getCompilationUnit", "(", ")", ",", "true", ")", ";", "ITypeBinding", "typeBinding", "=", "ASTNodes", ".", "getTypeBinding", "(", "cu", ",", "type", ")", ";", "String", "superType", "=", "commandLine", ".", "getValue", "(", "Options", ".", "SUPERTYPE_OPTION", ")", ";", "List", "<", "DelegateEntry", ">", "delegatable", "=", "getDelegatableMethods", "(", "cu", ",", "typeBinding", ")", ";", "List", "<", "DelegateEntry", ">", "delegate", "=", "new", "ArrayList", "<", "DelegateEntry", ">", "(", ")", ";", "for", "(", "DelegateEntry", "entry", ":", "delegatable", ")", "{", "ITypeBinding", "declBinding", "=", "entry", ".", "delegateMethod", ".", "getDeclaringClass", "(", ")", ";", "String", "fqn", "=", "declBinding", ".", "getQualifiedName", "(", ")", ".", "replaceAll", "(", "\"<.*?>\"", ",", "\"\"", ")", ";", "if", "(", "fqn", ".", "equals", "(", "superType", ")", "&&", "isChosen", "(", "chosen", ",", "entry", ".", "delegateMethod", ")", ")", "{", "delegate", ".", "add", "(", "entry", ")", ";", "}", "}", "if", "(", "delegate", ".", "size", "(", ")", ">", "0", ")", "{", "CodeGenerationSettings", "settings", "=", "JavaPreferencesSettings", ".", "getCodeGenerationSettings", "(", "src", ".", "getJavaProject", "(", ")", ")", ";", "settings", ".", "createComments", "=", "true", ";", "return", "new", "AddDelegateMethodsOperation", "(", "cu", ",", "delegate", ".", "toArray", "(", "new", "DelegateEntry", "[", "delegate", ".", "size", "(", ")", "]", ")", ",", "sibling", ",", "settings", ",", "true", ",", "true", ")", ";", "}", "return", "null", ";", "}", "@", "Override", "protected", "ImplResult", "getImplResult", "(", "ICompilationUnit", "src", ",", "IType", "type", ")", "throws", "Exception", "{", "List", "<", "DelegateEntry", ">", "delegatable", "=", "getDelegatableMethods", "(", "src", ",", "type", ")", ";", "List", "<", "IMethodBinding", ">", "methods", "=", "new", "ArrayList", "<", "IMethodBinding", ">", "(", "delegatable", ".", "size", "(", ")", ")", ";", "for", "(", "DelegateEntry", "entry", ":", "delegatable", ")", "{", "methods", ".", "add", "(", "entry", ".", "delegateMethod", ")", ";", "}", "String", "name", "=", "type", ".", "getFullyQualifiedName", "(", ")", "+", "'.'", "+", "field", ".", "get", "(", ")", ".", "getElementName", "(", ")", ";", "return", "getImplResult", "(", "name", ",", "methods", ")", ";", "}", "private", "List", "<", "DelegateEntry", ">", "getDelegatableMethods", "(", "ICompilationUnit", "src", ",", "IType", "type", ")", "throws", "Exception", "{", "RefactoringASTParser", "parser", "=", "new", "RefactoringASTParser", "(", "ASTProvider", ".", "SHARED_AST_LEVEL", ")", ";", "CompilationUnit", "cu", "=", "parser", ".", "parse", "(", "type", ".", "getCompilationUnit", "(", ")", ",", "true", ")", ";", "ITypeBinding", "typeBinding", "=", "ASTNodes", ".", "getTypeBinding", "(", "cu", ",", "type", ")", ";", "return", "getDelegatableMethods", "(", "cu", ",", "typeBinding", ")", ";", "}", "private", "List", "<", "DelegateEntry", ">", "getDelegatableMethods", "(", "CompilationUnit", "cu", ",", "ITypeBinding", "typeBinding", ")", "throws", "Exception", "{", "IVariableBinding", "variable", "=", "ASTNodeSearchUtil", ".", "getFieldDeclarationFragmentNode", "(", "field", ".", "get", "(", ")", ",", "cu", ")", ".", "resolveBinding", "(", ")", ";", "DelegateEntry", "[", "]", "entries", "=", "StubUtility2", ".", "getDelegatableMethods", "(", "typeBinding", ")", ";", "ArrayList", "<", "DelegateEntry", ">", "delegatable", "=", "new", "ArrayList", "<", "DelegateEntry", ">", "(", ")", ";", "for", "(", "DelegateEntry", "entry", ":", "entries", ")", "{", "if", "(", "entry", ".", "field", ".", "equals", "(", "variable", ")", ")", "{", "delegatable", ".", "add", "(", "entry", ")", ";", "}", "}", "return", "delegatable", ";", "}", "}", "</s>" ]
1,258
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "preference", ";", "import", "java", ".", "util", ".", "Hashtable", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "org", ".", "eclim", ".", "Services", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "preference", ".", "Preferences", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "util", ".", "JavaUtils", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "IProject", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "ProjectScope", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "preferences", ".", "DefaultScope", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "preferences", ".", "IEclipsePreferences", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "preferences", ".", "IScopeContext", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "preferences", ".", "InstanceScope", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IJavaProject", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "JavaCore", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "ui", ".", "JavaUI", ";", "public", "class", "OptionHandler", "implements", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "preference", ".", "OptionHandler", "{", "private", "static", "final", "String", "NATURE", "=", "\"\"", ";", "public", "String", "getNature", "(", ")", "{", "return", "NATURE", ";", "}", "public", "Map", "<", "String", ",", "String", ">", "getValues", "(", ")", "throws", "Exception", "{", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "Map", "<", "String", ",", "String", ">", "coreOptions", "=", "JavaCore", ".", "getOptions", "(", ")", ";", "Map", "<", "String", ",", "String", ">", "options", "=", "new", "Hashtable", "<", "String", ",", "String", ">", "(", ")", ";", "options", ".", "putAll", "(", "coreOptions", ")", ";", "options", ".", "putAll", "(", "getUIValues", "(", "null", ")", ")", ";", "return", "options", ";", "}", "public", "Map", "<", "String", ",", "String", ">", "getValues", "(", "IProject", "project", ")", "throws", "Exception", "{", "IJavaProject", "javaProject", "=", "JavaCore", ".", "create", "(", "project", ")", ";", "if", "(", "!", "javaProject", ".", "exists", "(", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "Services", ".", "getMessage", "(", "\"\"", ",", "project", ".", "getName", "(", ")", ")", ")", ";", "}", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "Map", "<", "String", ",", "String", ">", "coreOptions", "=", "javaProject", ".", "getOptions", "(", "true", ")", ";", "Map", "<", "String", ",", "String", ">", "options", "=", "new", "Hashtable", "<", "String", ",", "String", ">", "(", ")", ";", "options", ".", "putAll", "(", "coreOptions", ")", ";", "options", ".", "putAll", "(", "getUIValues", "(", "project", ")", ")", ";", "return", "options", ";", "}", "private", "Map", "<", "String", ",", "String", ">", "getUIValues", "(", "IProject", "project", ")", "throws", "Exception", "{", "Hashtable", "<", "String", ",", "String", ">", "options", "=", "new", "Hashtable", "<", "String", ",", "String", ">", "(", ")", ";", "IScopeContext", "[", "]", "contexts", "=", "null", ";", "if", "(", "project", "!=", "null", ")", "{", "contexts", "=", "new", "IScopeContext", "[", "]", "{", "new", "ProjectScope", "(", "project", ")", ",", "InstanceScope", ".", "INSTANCE", ",", "DefaultScope", ".", "INSTANCE", ",", "}", ";", "}", "else", "{", "contexts", "=", "new", "IScopeContext", "[", "]", "{", "InstanceScope", ".", "INSTANCE", ",", "DefaultScope", ".", "INSTANCE", ",", "}", ";", "}", "String", "[", "]", "names", "=", "Preferences", ".", "getInstance", "(", ")", ".", "getOptionNames", "(", ")", ";", "for", "(", "String", "name", ":", "names", ")", "{", "if", "(", "name", ".", "startsWith", "(", "JavaUI", ".", "ID_PLUGIN", ")", ")", "{", "for", "(", "IScopeContext", "context", ":", "contexts", ")", "{", "IEclipsePreferences", "node", "=", "context", ".", "getNode", "(", "JavaUI", ".", "ID_PLUGIN", ")", ";", "String", "value", "=", "node", ".", "get", "(", "name", ",", "null", ")", ";", "if", "(", "value", "!=", "null", ")", "{", "options", ".", "put", "(", "name", ",", "value", ")", ";", "break", ";", "}", "}", "}", "}", "return", "options", ";", "}", "public", "void", "setOption", "(", "String", "name", ",", "String", "value", ")", "throws", "Exception", "{", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "Map", "<", "String", ",", "String", ">", "options", "=", "JavaCore", ".", "getOptions", "(", ")", ";", "if", "(", "name", ".", "equals", "(", "JavaCore", ".", "COMPILER_SOURCE", ")", ")", "{", "JavaUtils", ".", "setCompilerSourceCompliance", "(", "value", ")", ";", "}", "else", "if", "(", "name", ".", "startsWith", "(", "JavaUI", ".", "ID_PLUGIN", ")", ")", "{", "Preferences", ".", "getInstance", "(", ")", ".", "setPreference", "(", "JavaUI", ".", "ID_PLUGIN", ",", "null", ",", "name", ",", "value", ")", ";", "}", "else", "{", "options", ".", "put", "(", "name", ",", "value", ")", ";", "JavaCore", ".", "setOptions", "(", "(", "Hashtable", "<", "String", ",", "String", ">", ")", "options", ")", ";", "}", "}", "public", "void", "setOption", "(", "IProject", "project", ",", "String", "name", ",", "String", "value", ")", "throws", "Exception", "{", "IJavaProject", "javaProject", "=", "JavaCore", ".", "create", "(", "project", ")", ";", "if", "(", "!", "javaProject", ".", "exists", "(", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "Services", ".", "getMessage", "(", "\"\"", ",", "project", ".", "getName", "(", ")", ")", ")", ";", "}", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "Map", "<", "String", ",", "String", ">", "global", "=", "javaProject", ".", "getOptions", "(", "true", ")", ";", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "Map", "<", "String", ",", "String", ">", "options", "=", "javaProject", ".", "getOptions", "(", "false", ")", ";", "Object", "current", "=", "global", ".", "get", "(", "name", ")", ";", "if", "(", "current", "==", "null", "||", "!", "current", ".", "equals", "(", "value", ")", ")", "{", "if", "(", "name", ".", "equals", "(", "JavaCore", ".", "COMPILER_SOURCE", ")", ")", "{", "JavaUtils", ".", "setCompilerSourceCompliance", "(", "javaProject", ",", "value", ")", ";", "}", "else", "if", "(", "name", ".", "startsWith", "(", "JavaUI", ".", "ID_PLUGIN", ")", ")", "{", "Preferences", ".", "getInstance", "(", ")", ".", "setPreference", "(", "JavaUI", ".", "ID_PLUGIN", ",", "project", ",", "name", ",", "value", ")", ";", "}", "else", "{", "options", ".", "put", "(", "name", ",", "value", ")", ";", "javaProject", ".", "setOptions", "(", "options", ")", ";", "}", "}", "}", "}", "</s>" ]
1,259
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "project", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "io", ".", "FileInputStream", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "regex", ".", "Matcher", ";", "import", "java", ".", "util", ".", "regex", ".", "Pattern", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang", ".", "StringUtils", ";", "import", "org", ".", "eclim", ".", "Services", ";", "import", "org", ".", "eclim", ".", "command", ".", "CommandLine", ";", "import", "org", ".", "eclim", ".", "command", ".", "Error", ";", "import", "org", ".", "eclim", ".", "command", ".", "Options", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "project", ".", "ProjectManager", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "util", ".", "ProjectUtils", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "util", ".", "XmlUtils", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "PluginResources", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "project", ".", "classpath", ".", "Dependency", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "project", ".", "classpath", ".", "IvyParser", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "project", ".", "classpath", ".", "MvnParser", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "project", ".", "classpath", ".", "Parser", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "util", ".", "JavaUtils", ";", "import", "org", ".", "eclim", ".", "util", ".", "IOUtils", ";", "import", "org", ".", "eclim", ".", "util", ".", "file", ".", "FileOffsets", ";", "import", "org", ".", "eclim", ".", "util", ".", "file", ".", "FileUtils", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "IFile", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "IProject", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "IResource", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "IWorkspaceRoot", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "IPath", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IClasspathAttribute", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IClasspathEntry", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IJavaModelStatus", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IJavaProject", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "JavaConventions", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "JavaCore", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "core", ".", "JavaProject", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "ui", ".", "wizards", ".", "ClassPathDetector", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "ui", ".", "wizards", ".", "buildpaths", ".", "BuildPathsBlock", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "internal", ".", "ui", ".", "wizards", ".", "buildpaths", ".", "CPListElement", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "ui", ".", "PreferenceConstants", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "preference", ".", "IPreferenceStore", ";", "public", "class", "JavaProjectManager", "implements", "ProjectManager", "{", "private", "static", "final", "String", "PRESERVE", "=", "\"\"", ";", "private", "static", "final", "String", "CLASSPATH", "=", "\".classpath\"", ";", "private", "static", "final", "String", "CLASSPATH_XSD", "=", "\"\"", ";", "private", "static", "final", "HashMap", "<", "String", ",", "Parser", ">", "PARSERS", "=", "new", "HashMap", "<", "String", ",", "Parser", ">", "(", ")", ";", "static", "{", "PARSERS", ".", "put", "(", "\"ivy.xml\"", ",", "new", "IvyParser", "(", ")", ")", ";", "PARSERS", ".", "put", "(", "\"pom.xml\"", ",", "new", "MvnParser", "(", ")", ")", ";", "}", "public", "void", "create", "(", "IProject", "project", ",", "CommandLine", "commandLine", ")", "throws", "Exception", "{", "String", "depends", "=", "commandLine", ".", "getValue", "(", "Options", ".", "DEPENDS_OPTION", ")", ";", "create", "(", "project", ",", "depends", ")", ";", "}", "public", "List", "<", "Error", ">", "update", "(", "IProject", "project", ",", "CommandLine", "commandLine", ")", "throws", "Exception", "{", "String", "buildfile", "=", "commandLine", ".", "getValue", "(", "Options", ".", "BUILD_FILE_OPTION", ")", ";", "IJavaProject", "javaProject", "=", "JavaUtils", ".", "getJavaProject", "(", "project", ")", ";", "javaProject", ".", "getResource", "(", ")", ".", "refreshLocal", "(", "IResource", ".", "DEPTH_INFINITE", ",", "null", ")", ";", "PluginResources", "resources", "=", "(", "PluginResources", ")", "Services", ".", "getPluginResources", "(", "PluginResources", ".", "NAME", ")", ";", "List", "<", "Error", ">", "errors", "=", "XmlUtils", ".", "validateXml", "(", "javaProject", ".", "getProject", "(", ")", ".", "getName", "(", ")", ",", "CLASSPATH", ",", "resources", ".", "getResource", "(", "CLASSPATH_XSD", ")", ".", "toString", "(", ")", ")", ";", "if", "(", "errors", ".", "size", "(", ")", ">", "0", ")", "{", "return", "errors", ";", "}", "String", "dotclasspath", "=", "javaProject", ".", "getProject", "(", ")", ".", "getFile", "(", "CLASSPATH", ")", ".", "getRawLocation", "(", ")", ".", "toOSString", "(", ")", ";", "if", "(", "buildfile", "!=", "null", ")", "{", "String", "filename", "=", "FileUtils", ".", "getBaseName", "(", "buildfile", ")", ";", "Parser", "parser", "=", "PARSERS", ".", "get", "(", "filename", ")", ";", "IClasspathEntry", "[", "]", "entries", "=", "merge", "(", "javaProject", ",", "parser", ".", "parse", "(", "buildfile", ")", ")", ";", "errors", "=", "setClasspath", "(", "javaProject", ",", "entries", ",", "dotclasspath", ")", ";", "}", "else", "{", "IClasspathEntry", "[", "]", "entries", "=", "javaProject", ".", "readRawClasspath", "(", ")", ";", "errors", "=", "setClasspath", "(", "javaProject", ",", "entries", ",", "dotclasspath", ")", ";", "}", "if", "(", "errors", ".", "size", "(", ")", ">", "0", ")", "{", "return", "errors", ";", "}", "return", "null", ";", "}", "public", "void", "refresh", "(", "IProject", "project", ",", "CommandLine", "commandLine", ")", "throws", "Exception", "{", "}", "public", "void", "refresh", "(", "IProject", "project", ",", "IFile", "file", ")", "throws", "Exception", "{", "}", "public", "void", "delete", "(", "IProject", "project", ",", "CommandLine", "commandLine", ")", "throws", "Exception", "{", "}", "protected", "void", "create", "(", "IProject", "project", ",", "String", "depends", ")", "throws", "Exception", "{", "IJavaProject", "javaProject", "=", "JavaCore", ".", "create", "(", "project", ")", ";", "(", "(", "JavaProject", ")", "javaProject", ")", ".", "configure", "(", ")", ";", "if", "(", "!", "project", ".", "getFile", "(", "CLASSPATH", ")", ".", "exists", "(", ")", ")", "{", "ArrayList", "<", "IClasspathEntry", ">", "classpath", "=", "new", "ArrayList", "<", "IClasspathEntry", ">", "(", ")", ";", "boolean", "source", "=", "false", ";", "boolean", "container", "=", "false", ";", "ClassPathDetector", "detector", "=", "new", "ClassPathDetector", "(", "project", ",", "null", ")", ";", "for", "(", "IClasspathEntry", "entry", ":", "detector", ".", "getClasspath", "(", ")", ")", "{", "if", "(", "entry", ".", "getEntryKind", "(", ")", "==", "IClasspathEntry", ".", "CPE_SOURCE", ")", "{", "source", "=", "true", ";", "}", "else", "if", "(", "entry", ".", "getEntryKind", "(", ")", "==", "IClasspathEntry", ".", "CPE_CONTAINER", ")", "{", "container", "=", "true", ";", "}", "classpath", ".", "add", "(", "entry", ")", ";", "}", "if", "(", "!", "source", ")", "{", "IResource", "src", ";", "IPreferenceStore", "store", "=", "PreferenceConstants", ".", "getPreferenceStore", "(", ")", ";", "String", "name", "=", "store", ".", "getString", "(", "PreferenceConstants", ".", "SRCBIN_SRCNAME", ")", ";", "boolean", "srcBinFolders", "=", "store", ".", "getBoolean", "(", "PreferenceConstants", ".", "SRCBIN_FOLDERS_IN_NEWPROJ", ")", ";", "if", "(", "srcBinFolders", "&&", "name", ".", "length", "(", ")", ">", "0", ")", "{", "src", "=", "javaProject", ".", "getProject", "(", ")", ".", "getFolder", "(", "name", ")", ";", "}", "else", "{", "src", "=", "javaProject", ".", "getProject", "(", ")", ";", "}", "classpath", ".", "add", "(", "new", "CPListElement", "(", "javaProject", ",", "IClasspathEntry", ".", "CPE_SOURCE", ",", "src", ".", "getFullPath", "(", ")", ",", "src", ")", ".", "getClasspathEntry", "(", ")", ")", ";", "File", "srcPath", "=", "new", "File", "(", "ProjectUtils", ".", "getFilePath", "(", "project", ",", "src", ".", "getFullPath", "(", ")", ".", "toString", "(", ")", ")", ")", ";", "if", "(", "!", "srcPath", ".", "exists", "(", ")", ")", "{", "srcPath", ".", "mkdirs", "(", ")", ";", "}", "}", "if", "(", "!", "container", ")", "{", "for", "(", "IClasspathEntry", "entry", ":", "PreferenceConstants", ".", "getDefaultJRELibrary", "(", ")", ")", "{", "classpath", ".", "add", "(", "entry", ")", ";", "}", "}", "for", "(", "IClasspathEntry", "entry", ":", "createOrUpdateDependencies", "(", "javaProject", ",", "depends", ")", ")", "{", "classpath", ".", "add", "(", "entry", ")", ";", "}", "javaProject", ".", "setRawClasspath", "(", "classpath", ".", "toArray", "(", "new", "IClasspathEntry", "[", "classpath", ".", "size", "(", ")", "]", ")", ",", "null", ")", ";", "IPath", "output", "=", "detector", ".", "getOutputLocation", "(", ")", ";", "if", "(", "output", "==", "null", ")", "{", "output", "=", "BuildPathsBlock", ".", "getDefaultOutputLocation", "(", "javaProject", ")", ";", "}", "javaProject", ".", "setOutputLocation", "(", "output", ",", "null", ")", ";", "}", "javaProject", ".", "makeConsistent", "(", "null", ")", ";", "javaProject", ".", "save", "(", "null", ",", "false", ")", ";", "}", "protected", "IClasspathEntry", "[", "]", "createOrUpdateDependencies", "(", "IJavaProject", "project", ",", "String", "depends", ")", "throws", "Exception", "{", "if", "(", "depends", "!=", "null", ")", "{", "String", "[", "]", "dependPaths", "=", "StringUtils", ".", "split", "(", "depends", ",", "','", ")", ";", "IClasspathEntry", "[", "]", "entries", "=", "new", "IClasspathEntry", "[", "dependPaths", ".", "length", "]", ";", "for", "(", "int", "ii", "=", "0", ";", "ii", "<", "dependPaths", ".", "length", ";", "ii", "++", ")", "{", "IProject", "theProject", "=", "ProjectUtils", ".", "getProject", "(", "dependPaths", "[", "ii", "]", ")", ";", "if", "(", "!", "theProject", ".", "exists", "(", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "Services", ".", "getMessage", "(", "\"\"", ",", "dependPaths", "[", "ii", "]", ")", ")", ";", "}", "IJavaProject", "otherProject", "=", "JavaCore", ".", "create", "(", "theProject", ")", ";", "entries", "[", "ii", "]", "=", "JavaCore", ".", "newProjectEntry", "(", "otherProject", ".", "getPath", "(", ")", ",", "true", ")", ";", "}", "return", "entries", ";", "}", "return", "new", "IClasspathEntry", "[", "0", "]", ";", "}", "protected", "IClasspathEntry", "[", "]", "merge", "(", "IClasspathEntry", "[", "]", "[", "]", "entries", ")", "{", "ArrayList", "<", "IClasspathEntry", ">", "union", "=", "new", "ArrayList", "<", "IClasspathEntry", ">", "(", ")", ";", "if", "(", "entries", "!=", "null", ")", "{", "for", "(", "IClasspathEntry", "[", "]", "values", ":", "entries", ")", "{", "if", "(", "values", "!=", "null", ")", "{", "for", "(", "IClasspathEntry", "entry", ":", "values", ")", "{", "if", "(", "!", "union", ".", "contains", "(", "entry", ")", ")", "{", "union", ".", "add", "(", "entry", ")", ";", "}", "}", "}", "}", "}", "return", "(", "IClasspathEntry", "[", "]", ")", "union", ".", "toArray", "(", "new", "IClasspathEntry", "[", "union", ".", "size", "(", ")", "]", ")", ";", "}", "protected", "List", "<", "Error", ">", "setClasspath", "(", "IJavaProject", "javaProject", ",", "IClasspathEntry", "[", "]", "entries", ",", "String", "classpath", ")", "throws", "Exception", "{", "FileOffsets", "offsets", "=", "FileOffsets", ".", "compile", "(", "classpath", ")", ";", "String", "classpathValue", "=", "IOUtils", ".", "toString", "(", "new", "FileInputStream", "(", "classpath", ")", ")", ";", "ArrayList", "<", "Error", ">", "errors", "=", "new", "ArrayList", "<", "Error", ">", "(", ")", ";", "for", "(", "IClasspathEntry", "entry", ":", "entries", ")", "{", "IJavaModelStatus", "status", "=", "JavaConventions", ".", "validateClasspathEntry", "(", "javaProject", ",", "entry", ",", "true", ")", ";", "if", "(", "!", "status", ".", "isOK", "(", ")", ")", "{", "errors", ".", "add", "(", "createErrorForEntry", "(", "javaProject", ",", "entry", ",", "status", ",", "offsets", ",", "classpath", ",", "classpathValue", ")", ")", ";", "}", "}", "IJavaModelStatus", "status", "=", "JavaConventions", ".", "validateClasspath", "(", "javaProject", ",", "entries", ",", "javaProject", ".", "getOutputLocation", "(", ")", ")", ";", "javaProject", ".", "setRawClasspath", "(", "entries", ",", "null", ")", ";", "javaProject", ".", "makeConsistent", "(", "null", ")", ";", "if", "(", "!", "status", ".", "isOK", "(", ")", ")", "{", "errors", ".", "add", "(", "new", "Error", "(", "status", ".", "getMessage", "(", ")", ",", "classpath", ",", "1", ",", "1", ",", "false", ")", ")", ";", "}", "return", "errors", ";", "}", "protected", "Error", "createErrorForEntry", "(", "IJavaProject", "project", ",", "IClasspathEntry", "entry", ",", "IJavaModelStatus", "status", ",", "FileOffsets", "offsets", ",", "String", "filename", ",", "String", "contents", ")", "throws", "Exception", "{", "int", "line", "=", "0", ";", "int", "col", "=", "0", ";", "String", "path", "=", "entry", ".", "getPath", "(", ")", ".", "toOSString", "(", ")", ";", "path", "=", "path", ".", "replaceFirst", "(", "\"^/\"", "+", "project", ".", "getProject", "(", ")", ".", "getName", "(", ")", "+", "\"/\"", ",", "\"\"", ")", ";", "Matcher", "matcher", "=", "Pattern", ".", "compile", "(", "\"\"", "+", "path", "+", "\"\\\\E\\\\s*\\\\1\"", ")", ".", "matcher", "(", "contents", ")", ";", "if", "(", "matcher", ".", "find", "(", ")", ")", "{", "int", "[", "]", "position", "=", "offsets", ".", "offsetToLineColumn", "(", "matcher", ".", "start", "(", ")", ")", ";", "line", "=", "position", "[", "0", "]", ";", "col", "=", "position", "[", "1", "]", ";", "}", "return", "new", "Error", "(", "status", ".", "getMessage", "(", ")", ",", "filename", ",", "line", ",", "col", ",", "false", ")", ";", "}", "protected", "IClasspathEntry", "[", "]", "merge", "(", "IJavaProject", "project", ",", "Dependency", "[", "]", "dependencies", ")", "throws", "Exception", "{", "IWorkspaceRoot", "root", "=", "project", ".", "getProject", "(", ")", ".", "getWorkspace", "(", ")", ".", "getRoot", "(", ")", ";", "ArrayList", "<", "IClasspathEntry", ">", "results", "=", "new", "ArrayList", "<", "IClasspathEntry", ">", "(", ")", ";", "IClasspathEntry", "[", "]", "entries", "=", "project", ".", "getRawClasspath", "(", ")", ";", "for", "(", "int", "ii", "=", "0", ";", "ii", "<", "entries", ".", "length", ";", "ii", "++", ")", "{", "if", "(", "entries", "[", "ii", "]", ".", "getEntryKind", "(", ")", "!=", "IClasspathEntry", ".", "CPE_LIBRARY", "&&", "entries", "[", "ii", "]", ".", "getEntryKind", "(", ")", "!=", "IClasspathEntry", ".", "CPE_VARIABLE", ")", "{", "results", ".", "add", "(", "entries", "[", "ii", "]", ")", ";", "}", "else", "if", "(", "preserve", "(", "entries", "[", "ii", "]", ")", ")", "{", "results", ".", "add", "(", "entries", "[", "ii", "]", ")", ";", "}", "}", "for", "(", "int", "ii", "=", "0", ";", "ii", "<", "dependencies", ".", "length", ";", "ii", "++", ")", "{", "IClasspathEntry", "match", "=", "null", ";", "for", "(", "int", "jj", "=", "0", ";", "jj", "<", "entries", ".", "length", ";", "jj", "++", ")", "{", "if", "(", "entries", "[", "jj", "]", ".", "getEntryKind", "(", ")", "==", "IClasspathEntry", ".", "CPE_LIBRARY", "||", "entries", "[", "jj", "]", ".", "getEntryKind", "(", ")", "==", "IClasspathEntry", ".", "CPE_VARIABLE", ")", "{", "String", "path", "=", "entries", "[", "jj", "]", ".", "getPath", "(", ")", ".", "toOSString", "(", ")", ";", "String", "pattern", "=", "dependencies", "[", "ii", "]", ".", "getName", "(", ")", "+", "Dependency", ".", "VERSION_SEPARATOR", ";", "if", "(", "path", ".", "endsWith", "(", "dependencies", "[", "ii", "]", ".", "toString", "(", ")", ")", ")", "{", "match", "=", "entries", "[", "jj", "]", ";", "results", ".", "add", "(", "entries", "[", "jj", "]", ")", ";", "break", ";", "}", "else", "if", "(", "path", ".", "indexOf", "(", "pattern", ")", "!=", "-", "1", ")", "{", "break", ";", "}", "}", "else", "if", "(", "entries", "[", "jj", "]", ".", "getEntryKind", "(", ")", "==", "IClasspathEntry", ".", "CPE_PROJECT", ")", "{", "String", "path", "=", "entries", "[", "jj", "]", ".", "getPath", "(", ")", ".", "toOSString", "(", ")", ";", "if", "(", "path", ".", "endsWith", "(", "dependencies", "[", "ii", "]", ".", "getName", "(", ")", ")", ")", "{", "match", "=", "entries", "[", "jj", "]", ";", "break", ";", "}", "}", "}", "if", "(", "match", "==", "null", ")", "{", "IClasspathEntry", "entry", "=", "createEntry", "(", "root", ",", "project", ",", "dependencies", "[", "ii", "]", ")", ";", "results", ".", "add", "(", "entry", ")", ";", "}", "else", "{", "match", "=", "null", ";", "}", "}", "return", "(", "IClasspathEntry", "[", "]", ")", "results", ".", "toArray", "(", "new", "IClasspathEntry", "[", "results", ".", "size", "(", ")", "]", ")", ";", "}", "protected", "boolean", "preserve", "(", "IClasspathEntry", "entry", ")", "{", "IClasspathAttribute", "[", "]", "attributes", "=", "entry", ".", "getExtraAttributes", "(", ")", ";", "for", "(", "int", "ii", "=", "0", ";", "ii", "<", "attributes", ".", "length", ";", "ii", "++", ")", "{", "String", "name", "=", "attributes", "[", "ii", "]", ".", "getName", "(", ")", ";", "if", "(", "PRESERVE", ".", "equals", "(", "name", ")", ")", "{", "return", "Boolean", ".", "parseBoolean", "(", "attributes", "[", "ii", "]", ".", "getValue", "(", ")", ")", ";", "}", "}", "return", "false", ";", "}", "protected", "IClasspathEntry", "createEntry", "(", "IWorkspaceRoot", "root", ",", "IJavaProject", "project", ",", "Dependency", "dependency", ")", "throws", "Exception", "{", "if", "(", "dependency", ".", "isVariable", "(", ")", ")", "{", "return", "JavaCore", ".", "newVariableEntry", "(", "dependency", ".", "getPath", "(", ")", ",", "null", ",", "null", ",", "true", ")", ";", "}", "return", "JavaCore", ".", "newLibraryEntry", "(", "dependency", ".", "getPath", "(", ")", ",", "null", ",", "null", ",", "true", ")", ";", "}", "protected", "boolean", "startsWithVariable", "(", "String", "path", ")", "{", "String", "[", "]", "variables", "=", "JavaCore", ".", "getClasspathVariableNames", "(", ")", ";", "for", "(", "int", "ii", "=", "0", ";", "ii", "<", "variables", ".", "length", ";", "ii", "++", ")", "{", "if", "(", "path", ".", "startsWith", "(", "variables", "[", "ii", "]", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}", "}", "</s>" ]
1,260
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "project", ".", "classpath", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "IPath", ";", "public", "class", "Dependency", "{", "public", "static", "final", "String", "JAR", "=", "\".jar\"", ";", "public", "static", "final", "String", "SEPARATOR", "=", "\"/\"", ";", "public", "static", "final", "String", "VERSION_SEPARATOR", "=", "\"-\"", ";", "private", "String", "organization", ";", "private", "String", "name", ";", "private", "String", "version", ";", "private", "IPath", "path", ";", "private", "boolean", "variable", ";", "public", "Dependency", "(", "String", "org", ",", "String", "name", ",", "String", "version", ",", "IPath", "path", ")", "{", "this", ".", "organization", "=", "org", ";", "this", ".", "name", "=", "name", ";", "this", ".", "version", "=", "version", ";", "this", ".", "path", "=", "path", ".", "append", "(", "resolveArtifact", "(", ")", ")", ";", "}", "public", "String", "getOrganization", "(", ")", "{", "return", "this", ".", "organization", ";", "}", "public", "void", "setOrganization", "(", "String", "organization", ")", "{", "this", ".", "organization", "=", "organization", ";", "}", "public", "String", "getName", "(", ")", "{", "return", "this", ".", "name", ";", "}", "public", "void", "setName", "(", "String", "name", ")", "{", "this", ".", "name", "=", "name", ";", "}", "public", "String", "getVersion", "(", ")", "{", "return", "this", ".", "version", ";", "}", "public", "void", "setVersion", "(", "String", "version", ")", "{", "this", ".", "version", "=", "version", ";", "}", "public", "IPath", "getPath", "(", ")", "{", "return", "this", ".", "path", ";", "}", "public", "void", "setPath", "(", "IPath", "path", ")", "{", "this", ".", "path", "=", "path", ";", "}", "public", "boolean", "isVariable", "(", ")", "{", "return", "this", ".", "variable", ";", "}", "public", "void", "setVariable", "(", "boolean", "variable", ")", "{", "this", ".", "variable", "=", "variable", ";", "}", "public", "String", "resolveArtifact", "(", ")", "{", "return", "toString", "(", ")", ";", "}", "public", "String", "toString", "(", ")", "{", "StringBuffer", "buffer", "=", "new", "StringBuffer", "(", "getName", "(", ")", ")", ";", "if", "(", "getVersion", "(", ")", "!=", "null", "&&", "getVersion", "(", ")", ".", "trim", "(", ")", ".", "length", "(", ")", ">", "0", ")", "{", "buffer", ".", "append", "(", "VERSION_SEPARATOR", ")", ".", "append", "(", "getVersion", "(", ")", ")", ";", "}", "buffer", ".", "append", "(", "JAR", ")", ";", "return", "buffer", ".", "toString", "(", ")", ";", "}", "}", "</s>" ]
1,261
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "project", ".", "classpath", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "IPath", ";", "public", "class", "IvyDependency", "extends", "Dependency", "{", "private", "static", "final", "String", "JARS", "=", "\"jars\"", ";", "public", "IvyDependency", "(", "String", "org", ",", "String", "name", ",", "String", "version", ",", "IPath", "path", ")", "{", "super", "(", "org", ",", "name", ",", "version", ",", "path", ")", ";", "}", "public", "String", "resolveArtifact", "(", ")", "{", "StringBuffer", "buffer", "=", "new", "StringBuffer", "(", ")", ";", "buffer", ".", "append", "(", "getOrganization", "(", ")", ")", ".", "append", "(", "SEPARATOR", ")", ".", "append", "(", "getName", "(", ")", ")", ".", "append", "(", "SEPARATOR", ")", ".", "append", "(", "JARS", ")", ".", "append", "(", "SEPARATOR", ")", ".", "append", "(", "toString", "(", ")", ")", ";", "return", "buffer", ".", "toString", "(", ")", ";", "}", "}", "</s>" ]
1,262
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "project", ".", "classpath", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "IPath", ";", "public", "class", "MvnDependency", "extends", "Dependency", "{", "public", "MvnDependency", "(", "String", "org", ",", "String", "name", ",", "String", "version", ",", "IPath", "path", ")", "{", "super", "(", "org", ",", "name", ",", "version", ",", "path", ")", ";", "}", "public", "String", "resolveArtifact", "(", ")", "{", "StringBuffer", "buffer", "=", "new", "StringBuffer", "(", ")", ";", "buffer", ".", "append", "(", "getOrganization", "(", ")", ".", "replace", "(", "\".\"", ",", "SEPARATOR", ")", ")", ".", "append", "(", "SEPARATOR", ")", ".", "append", "(", "getName", "(", ")", ".", "replace", "(", "\".\"", ",", "SEPARATOR", ")", ")", ".", "append", "(", "SEPARATOR", ")", ".", "append", "(", "getVersion", "(", ")", ")", ".", "append", "(", "SEPARATOR", ")", ".", "append", "(", "toString", "(", ")", ")", ";", "return", "buffer", ".", "toString", "(", ")", ";", "}", "}", "</s>" ]
1,263
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "project", ".", "classpath", ";", "import", "javax", ".", "xml", ".", "xpath", ".", "XPathConstants", ";", "import", "javax", ".", "xml", ".", "xpath", ".", "XPathExpression", ";", "import", "org", ".", "eclim", ".", "Services", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "util", ".", "XmlUtils", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "IPath", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "Path", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "JavaCore", ";", "import", "org", ".", "w3c", ".", "dom", ".", "Document", ";", "import", "org", ".", "w3c", ".", "dom", ".", "Element", ";", "import", "org", ".", "w3c", ".", "dom", ".", "NodeList", ";", "public", "class", "IvyParser", "extends", "AbstractXmlParser", "{", "private", "static", "final", "String", "IVY_REPO", "=", "\"IVY_REPO\"", ";", "private", "static", "final", "String", "ORG", "=", "\"org\"", ";", "private", "static", "final", "String", "NAME", "=", "\"name\"", ";", "private", "static", "final", "String", "REVISION", "=", "\"rev\"", ";", "private", "static", "XPathExpression", "xpath", ";", "public", "Dependency", "[", "]", "parse", "(", "Document", "document", ")", "throws", "Exception", "{", "try", "{", "if", "(", "xpath", "==", "null", ")", "{", "xpath", "=", "XmlUtils", ".", "createXPathExpression", "(", "\"\"", ")", ";", "}", "if", "(", "JavaCore", ".", "getClasspathVariable", "(", "IVY_REPO", ")", "==", "null", ")", "{", "throw", "new", "IllegalStateException", "(", "Services", ".", "getMessage", "(", "\"\"", ",", "IVY_REPO", ")", ")", ";", "}", "IPath", "path", "=", "new", "Path", "(", "IVY_REPO", ")", ";", "NodeList", "results", "=", "(", "NodeList", ")", "xpath", ".", "evaluate", "(", "document", ",", "XPathConstants", ".", "NODESET", ")", ";", "Dependency", "[", "]", "dependencies", "=", "new", "Dependency", "[", "results", ".", "getLength", "(", ")", "]", ";", "for", "(", "int", "ii", "=", "0", ";", "ii", "<", "results", ".", "getLength", "(", ")", ";", "ii", "++", ")", "{", "Element", "element", "=", "(", "Element", ")", "results", ".", "item", "(", "ii", ")", ";", "dependencies", "[", "ii", "]", "=", "new", "IvyDependency", "(", "element", ".", "getAttribute", "(", "ORG", ")", ",", "element", ".", "getAttribute", "(", "NAME", ")", ",", "element", ".", "getAttribute", "(", "REVISION", ")", ",", "path", ")", ";", "dependencies", "[", "ii", "]", ".", "setVariable", "(", "true", ")", ";", "}", "return", "dependencies", ";", "}", "catch", "(", "IllegalStateException", "iae", ")", "{", "throw", "iae", ";", "}", "}", "}", "</s>" ]
1,264
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "project", ".", "classpath", ";", "public", "interface", "Parser", "{", "public", "Dependency", "[", "]", "parse", "(", "String", "filename", ")", "throws", "Exception", ";", "}", "</s>" ]
1,265
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "project", ".", "classpath", ";", "import", "java", ".", "io", ".", "File", ";", "import", "javax", ".", "xml", ".", "parsers", ".", "DocumentBuilderFactory", ";", "import", "org", ".", "w3c", ".", "dom", ".", "Document", ";", "public", "abstract", "class", "AbstractXmlParser", "implements", "Parser", "{", "private", "static", "DocumentBuilderFactory", "factory", ";", "public", "Dependency", "[", "]", "parse", "(", "String", "filename", ")", "throws", "Exception", "{", "if", "(", "factory", "==", "null", ")", "{", "factory", "=", "DocumentBuilderFactory", ".", "newInstance", "(", ")", ";", "}", "Document", "document", "=", "factory", ".", "newDocumentBuilder", "(", ")", ".", "parse", "(", "new", "File", "(", "filename", ")", ")", ";", "return", "parse", "(", "document", ")", ";", "}", "public", "abstract", "Dependency", "[", "]", "parse", "(", "Document", "document", ")", "throws", "Exception", ";", "}", "</s>" ]
1,266
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "project", ".", "classpath", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "javax", ".", "xml", ".", "xpath", ".", "XPathConstants", ";", "import", "javax", ".", "xml", ".", "xpath", ".", "XPathExpression", ";", "import", "org", ".", "eclim", ".", "Services", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "util", ".", "XmlUtils", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "IPath", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "Path", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "JavaCore", ";", "import", "org", ".", "w3c", ".", "dom", ".", "Document", ";", "import", "org", ".", "w3c", ".", "dom", ".", "Element", ";", "import", "org", ".", "w3c", ".", "dom", ".", "Node", ";", "import", "org", ".", "w3c", ".", "dom", ".", "NodeList", ";", "public", "class", "MvnParser", "extends", "AbstractXmlParser", "{", "private", "static", "final", "String", "MVN_REPO", "=", "\"M2_REPO\"", ";", "private", "static", "final", "String", "GROUP_ID", "=", "\"groupId\"", ";", "private", "static", "final", "String", "ARTIFACT_ID", "=", "\"artifactId\"", ";", "private", "static", "final", "String", "VERSION", "=", "\"version\"", ";", "private", "static", "XPathExpression", "xpath", ";", "public", "Dependency", "[", "]", "parse", "(", "Document", "document", ")", "throws", "Exception", "{", "try", "{", "if", "(", "xpath", "==", "null", ")", "{", "xpath", "=", "XmlUtils", ".", "createXPathExpression", "(", "\"\"", ")", ";", "}", "if", "(", "JavaCore", ".", "getClasspathVariable", "(", "MVN_REPO", ")", "==", "null", ")", "{", "throw", "new", "IllegalStateException", "(", "Services", ".", "getMessage", "(", "\"\"", ",", "MVN_REPO", ")", ")", ";", "}", "IPath", "path", "=", "new", "Path", "(", "MVN_REPO", ")", ";", "NodeList", "results", "=", "(", "NodeList", ")", "xpath", ".", "evaluate", "(", "document", ",", "XPathConstants", ".", "NODESET", ")", ";", "ArrayList", "<", "Dependency", ">", "dependencies", "=", "new", "ArrayList", "<", "Dependency", ">", "(", ")", ";", "for", "(", "int", "ii", "=", "0", ";", "ii", "<", "results", ".", "getLength", "(", ")", ";", "ii", "++", ")", "{", "Element", "element", "=", "(", "Element", ")", "results", ".", "item", "(", "ii", ")", ";", "NodeList", "group", "=", "element", ".", "getElementsByTagName", "(", "GROUP_ID", ")", ";", "NodeList", "artifact", "=", "element", ".", "getElementsByTagName", "(", "ARTIFACT_ID", ")", ";", "NodeList", "ver", "=", "element", ".", "getElementsByTagName", "(", "VERSION", ")", ";", "if", "(", "group", "==", "null", "||", "group", ".", "getLength", "(", ")", "<", "1", "||", "artifact", "==", "null", "||", "artifact", ".", "getLength", "(", ")", "<", "1", "||", "ver", "==", "null", "||", "ver", ".", "getLength", "(", ")", "<", "1", ")", "{", "continue", ";", "}", "Node", "groupId", "=", "group", ".", "item", "(", "0", ")", ".", "getFirstChild", "(", ")", ";", "Node", "artifactId", "=", "artifact", ".", "item", "(", "0", ")", ".", "getFirstChild", "(", ")", ";", "Node", "version", "=", "ver", ".", "item", "(", "0", ")", ".", "getFirstChild", "(", ")", ";", "if", "(", "groupId", "==", "null", "||", "artifactId", "==", "null", "||", "version", "==", "null", ")", "{", "continue", ";", "}", "String", "groupIdValue", "=", "groupId", ".", "getNodeValue", "(", ")", ".", "trim", "(", ")", ";", "String", "artifactIdValue", "=", "artifactId", ".", "getNodeValue", "(", ")", ".", "trim", "(", ")", ";", "String", "versionValue", "=", "version", ".", "getNodeValue", "(", ")", ".", "trim", "(", ")", ";", "if", "(", "groupIdValue", ".", "length", "(", ")", "==", "0", "||", "artifactIdValue", ".", "length", "(", ")", "==", "0", "||", "versionValue", ".", "length", "(", ")", "==", "0", ")", "{", "continue", ";", "}", "Dependency", "dependency", "=", "new", "MvnDependency", "(", "groupIdValue", ",", "artifactIdValue", ",", "versionValue", ",", "path", ")", ";", "dependency", ".", "setVariable", "(", "true", ")", ";", "dependencies", ".", "add", "(", "dependency", ")", ";", "}", "return", "(", "Dependency", "[", "]", ")", "dependencies", ".", "toArray", "(", "new", "Dependency", "[", "dependencies", ".", "size", "(", ")", "]", ")", ";", "}", "catch", "(", "IllegalStateException", "iae", ")", "{", "throw", "iae", ";", "}", "}", "}", "</s>" ]
1,267
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "ant", ";", "import", "org", ".", "eclim", ".", "Services", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "AbstractPluginResources", ";", "public", "class", "PluginResources", "extends", "AbstractPluginResources", "{", "public", "static", "final", "String", "NAME", "=", "\"\"", ";", "protected", "String", "getBundleBaseName", "(", ")", "{", "return", "\"\"", ";", "}", "}", "</s>" ]
1,268
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "ant", ".", "util", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "util", ".", "ProjectUtils", ";", "import", "org", ".", "eclipse", ".", "ant", ".", "internal", ".", "ui", ".", "AntUtil", ";", "import", "org", ".", "eclipse", ".", "ant", ".", "internal", ".", "ui", ".", "model", ".", "AntModel", ";", "import", "org", ".", "eclipse", ".", "ant", ".", "internal", ".", "ui", ".", "model", ".", "IAntModel", ";", "import", "org", ".", "eclipse", ".", "ant", ".", "internal", ".", "ui", ".", "model", ".", "IProblemRequestor", ";", "import", "org", ".", "eclipse", ".", "ant", ".", "internal", ".", "ui", ".", "model", ".", "LocationProvider", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "IFile", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "IResource", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "IPath", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "text", ".", "IDocument", ";", "public", "class", "AntUtils", "{", "public", "static", "IAntModel", "getAntModel", "(", "String", "project", ",", "String", "antFile", ")", "throws", "Exception", "{", "return", "getAntModel", "(", "project", ",", "antFile", ",", "null", ")", ";", "}", "public", "static", "IAntModel", "getAntModel", "(", "String", "project", ",", "String", "antFile", ",", "IProblemRequestor", "requestor", ")", "throws", "Exception", "{", "final", "IFile", "file", "=", "AntUtil", ".", "getFileForLocation", "(", "ProjectUtils", ".", "getFilePath", "(", "project", ",", "antFile", ")", ",", "null", ")", ";", "if", "(", "file", "==", "null", ")", "{", "throw", "new", "RuntimeException", "(", "\"\"", ")", ";", "}", "file", ".", "refreshLocal", "(", "IResource", ".", "DEPTH_INFINITE", ",", "null", ")", ";", "IDocument", "doc", "=", "ProjectUtils", ".", "getDocument", "(", "project", ",", "antFile", ")", ";", "LocationProvider", "provider", "=", "new", "LocationProvider", "(", "null", ")", "{", "public", "IFile", "getFile", "(", ")", "{", "return", "file", ";", "}", "public", "IPath", "getLocation", "(", ")", "{", "return", "file", ".", "getLocation", "(", ")", ";", "}", "}", ";", "return", "new", "AntModel", "(", "doc", ",", "requestor", ",", "provider", ",", "true", ",", "true", ",", "true", ")", ";", "}", "}", "</s>" ]
1,269
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "ant", ".", "command", ".", "complete", ";", "import", "org", ".", "eclim", ".", "eclipse", ".", "jface", ".", "text", ".", "contentassist", ".", "DummyContentAssistantExtension2", ";", "import", "org", ".", "eclipse", ".", "ant", ".", "internal", ".", "ui", ".", "model", ".", "AntModel", ";", "public", "class", "AntEditorCompletionProcessor", "extends", "org", ".", "eclipse", ".", "ant", ".", "internal", ".", "ui", ".", "editor", ".", "AntEditorCompletionProcessor", "{", "public", "AntEditorCompletionProcessor", "(", "AntModel", "model", ")", "{", "super", "(", "model", ")", ";", "super", ".", "fContentAssistant", "=", "new", "DummyContentAssistantExtension2", "(", ")", ";", "}", "}", "</s>" ]
1,270
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "ant", ".", "command", ".", "complete", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang", ".", "builder", ".", "EqualsBuilder", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang", ".", "builder", ".", "HashCodeBuilder", ";", "import", "org", ".", "eclim", ".", "annotation", ".", "Command", ";", "import", "org", ".", "eclim", ".", "command", ".", "CommandLine", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "ant", ".", "util", ".", "AntUtils", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "command", ".", "complete", ".", "AbstractCodeCompleteCommand", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "command", ".", "complete", ".", "CodeCompleteResult", ";", "import", "org", ".", "eclipse", ".", "ant", ".", "internal", ".", "ui", ".", "model", ".", "AntModel", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "text", ".", "contentassist", ".", "ICompletionProposal", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "text", ".", "contentassist", ".", "IContentAssistProcessor", ";", "@", "Command", "(", "name", "=", "\"ant_complete\"", ",", "options", "=", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", ")", "public", "class", "CodeCompleteCommand", "extends", "AbstractCodeCompleteCommand", "{", "@", "Override", "protected", "CodeCompleteResult", "createCodeCompletionResult", "(", "ICompletionProposal", "proposal", ")", "{", "return", "new", "AntCodeCompleteResult", "(", "getCompletion", "(", "proposal", ")", ",", "getMenu", "(", "proposal", ")", ",", "getInfo", "(", "proposal", ")", ")", ";", "}", "protected", "IContentAssistProcessor", "getContentAssistProcessor", "(", "CommandLine", "commandLine", ",", "String", "project", ",", "String", "file", ")", "throws", "Exception", "{", "AntModel", "model", "=", "(", "AntModel", ")", "AntUtils", ".", "getAntModel", "(", "project", ",", "file", ")", ";", "AntEditorCompletionProcessor", "processor", "=", "new", "AntEditorCompletionProcessor", "(", "model", ")", ";", "return", "processor", ";", "}", "protected", "String", "getCompletion", "(", "ICompletionProposal", "proposal", ")", "{", "String", "completion", "=", "super", ".", "getCompletion", "(", "proposal", ")", ";", "int", "index", "=", "completion", ".", "indexOf", "(", "\"", "-", "\"", ")", ";", "if", "(", "index", "!=", "-", "1", ")", "{", "completion", "=", "completion", ".", "substring", "(", "0", ",", "index", ")", ";", "}", "return", "completion", ";", "}", "private", "class", "AntCodeCompleteResult", "extends", "CodeCompleteResult", "{", "public", "AntCodeCompleteResult", "(", "String", "completion", ",", "String", "menu", ",", "String", "info", ")", "{", "super", "(", "completion", ",", "menu", ",", "info", ")", ";", "}", "@", "Override", "public", "boolean", "equals", "(", "Object", "other", ")", "{", "if", "(", "!", "(", "other", "instanceof", "AntCodeCompleteResult", ")", ")", "{", "return", "false", ";", "}", "if", "(", "this", "==", "other", ")", "{", "return", "true", ";", "}", "AntCodeCompleteResult", "result", "=", "(", "AntCodeCompleteResult", ")", "other", ";", "boolean", "equal", "=", "new", "EqualsBuilder", "(", ")", ".", "append", "(", "getCompletion", "(", ")", ",", "result", ".", "getCompletion", "(", ")", ")", ".", "isEquals", "(", ")", ";", "return", "equal", ";", "}", "@", "Override", "public", "int", "hashCode", "(", ")", "{", "return", "new", "HashCodeBuilder", "(", "18", ",", "40", ")", ".", "append", "(", "getCompletion", "(", ")", ")", ".", "toHashCode", "(", ")", ";", "}", "}", "}", "</s>" ]
1,271
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "ant", ".", "command", ".", "run", ";", "import", "java", ".", "text", ".", "Collator", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Collections", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "org", ".", "apache", ".", "tools", ".", "ant", ".", "Project", ";", "import", "org", ".", "eclim", ".", "annotation", ".", "Command", ";", "import", "org", ".", "eclim", ".", "command", ".", "CommandLine", ";", "import", "org", ".", "eclim", ".", "command", ".", "Options", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "ant", ".", "util", ".", "AntUtils", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "command", ".", "AbstractCommand", ";", "import", "org", ".", "eclipse", ".", "ant", ".", "internal", ".", "ui", ".", "model", ".", "AntModel", ";", "import", "org", ".", "eclipse", ".", "ant", ".", "internal", ".", "ui", ".", "model", ".", "AntProjectNode", ";", "@", "Command", "(", "name", "=", "\"ant_targets\"", ",", "options", "=", "\"\"", "+", "\"\"", ")", "public", "class", "TargetsCommand", "extends", "AbstractCommand", "{", "public", "Object", "execute", "(", "CommandLine", "commandLine", ")", "throws", "Exception", "{", "ArrayList", "<", "String", ">", "results", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "String", "project", "=", "commandLine", ".", "getValue", "(", "Options", ".", "PROJECT_OPTION", ")", ";", "String", "file", "=", "commandLine", ".", "getValue", "(", "Options", ".", "FILE_OPTION", ")", ";", "AntModel", "model", "=", "(", "AntModel", ")", "AntUtils", ".", "getAntModel", "(", "project", ",", "file", ")", ";", "AntProjectNode", "projectNode", "=", "model", ".", "getProjectNode", "(", "true", ")", ";", "Project", "antProject", "=", "projectNode", ".", "getProject", "(", ")", ";", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "Map", "<", "String", ",", "Object", ">", "targets", "=", "antProject", ".", "getTargets", "(", ")", ";", "for", "(", "String", "target", ":", "targets", ".", "keySet", "(", ")", ")", "{", "if", "(", "target", ".", "trim", "(", ")", ".", "length", "(", ")", ">", "0", ")", "{", "results", ".", "add", "(", "target", ")", ";", "}", "}", "Collections", ".", "sort", "(", "results", ",", "Collator", ".", "getInstance", "(", ")", ")", ";", "return", "results", ";", "}", "}", "</s>" ]
1,272
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "ant", ".", "command", ".", "validate", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "eclim", ".", "annotation", ".", "Command", ";", "import", "org", ".", "eclim", ".", "command", ".", "CommandLine", ";", "import", "org", ".", "eclim", ".", "command", ".", "Error", ";", "import", "org", ".", "eclim", ".", "command", ".", "Options", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "ant", ".", "util", ".", "AntUtils", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "util", ".", "ProjectUtils", ";", "import", "org", ".", "eclim", ".", "util", ".", "file", ".", "FileOffsets", ";", "import", "org", ".", "eclipse", ".", "ant", ".", "internal", ".", "ui", ".", "model", ".", "IAntModel", ";", "import", "org", ".", "eclipse", ".", "ant", ".", "internal", ".", "ui", ".", "model", ".", "IProblem", ";", "import", "org", ".", "eclipse", ".", "ant", ".", "internal", ".", "ui", ".", "model", ".", "IProblemRequestor", ";", "@", "Command", "(", "name", "=", "\"ant_validate\"", ",", "options", "=", "\"\"", "+", "\"\"", ")", "public", "class", "ValidateCommand", "extends", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "command", ".", "xml", ".", "ValidateCommand", "{", "public", "Object", "execute", "(", "CommandLine", "commandLine", ")", "throws", "Exception", "{", "String", "project", "=", "commandLine", ".", "getValue", "(", "Options", ".", "PROJECT_OPTION", ")", ";", "String", "file", "=", "commandLine", ".", "getValue", "(", "Options", ".", "FILE_OPTION", ")", ";", "List", "<", "Error", ">", "errors", "=", "super", ".", "validate", "(", "project", ",", "file", ",", "false", ",", "null", ")", ";", "ProblemRequestor", "requestor", "=", "new", "ProblemRequestor", "(", ")", ";", "IAntModel", "model", "=", "AntUtils", ".", "getAntModel", "(", "project", ",", "file", ",", "requestor", ")", ";", "model", ".", "reconcile", "(", ")", ";", "String", "filepath", "=", "ProjectUtils", ".", "getFilePath", "(", "project", ",", "file", ")", ";", "List", "<", "IProblem", ">", "problems", "=", "requestor", ".", "getProblems", "(", ")", ";", "FileOffsets", "offsets", "=", "FileOffsets", ".", "compile", "(", "filepath", ")", ";", "for", "(", "IProblem", "problem", ":", "problems", ")", "{", "int", "[", "]", "lineColumn", "=", "offsets", ".", "offsetToLineColumn", "(", "problem", ".", "getOffset", "(", ")", ")", ";", "Error", "error", "=", "new", "Error", "(", "problem", ".", "getUnmodifiedMessage", "(", ")", ",", "filepath", ",", "lineColumn", "[", "0", "]", ",", "lineColumn", "[", "1", "]", ",", "problem", ".", "isWarning", "(", ")", ")", ";", "if", "(", "!", "errors", ".", "contains", "(", "error", ")", ")", "{", "errors", ".", "add", "(", "error", ")", ";", "}", "}", "return", "errors", ";", "}", "private", "class", "ProblemRequestor", "implements", "IProblemRequestor", "{", "private", "ArrayList", "<", "IProblem", ">", "problems", "=", "new", "ArrayList", "<", "IProblem", ">", "(", ")", ";", "public", "List", "<", "IProblem", ">", "getProblems", "(", ")", "{", "return", "problems", ";", "}", "public", "void", "acceptProblem", "(", "IProblem", "problem", ")", "{", "problems", ".", "add", "(", "problem", ")", ";", "}", "public", "void", "beginReporting", "(", ")", "{", "}", "public", "void", "endReporting", "(", ")", "{", "}", "}", "}", "</s>" ]
1,273
[ "<s>", "package", "org", ".", "eclim", ".", "eclipse", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "io", ".", "FileFilter", ";", "import", "java", ".", "io", ".", "FileInputStream", ";", "import", "java", ".", "io", ".", "FilenameFilter", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "net", ".", "URL", ";", "import", "java", ".", "security", ".", "CodeSource", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "HashSet", ";", "import", "java", ".", "util", ".", "LinkedHashSet", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "java", ".", "util", ".", "Set", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang", ".", "StringUtils", ";", "import", "org", ".", "eclim", ".", "logging", ".", "Logger", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "util", ".", "ProjectUtils", ";", "import", "org", ".", "eclim", ".", "util", ".", "IOUtils", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "CoreException", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "FileLocator", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "IPath", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "NullProgressMonitor", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "Path", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "Platform", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "ClasspathContainerInitializer", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IClasspathAttribute", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IClasspathContainer", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IClasspathEntry", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IJavaProject", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "JavaCore", ";", "import", "org", ".", "eclipse", ".", "osgi", ".", "util", ".", "ManifestElement", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "SWT", ";", "import", "org", ".", "osgi", ".", "framework", ".", "Bundle", ";", "public", "class", "EclimClasspathInitializer", "extends", "ClasspathContainerInitializer", "{", "private", "static", "final", "Logger", "logger", "=", "Logger", ".", "getLogger", "(", "EclimClasspathInitializer", ".", "class", ")", ";", "private", "Map", "<", "IPath", ",", "Map", "<", "String", ",", "String", ">", ">", "docJars", "=", "new", "HashMap", "<", "IPath", ",", "Map", "<", "String", ",", "String", ">", ">", "(", ")", ";", "private", "Set", "<", "String", ">", "platformNames", "=", "new", "HashSet", "<", "String", ">", "(", ")", ";", "{", "platformNames", ".", "add", "(", "\"\"", ")", ";", "platformNames", ".", "add", "(", "\"\"", ")", ";", "platformNames", ".", "add", "(", "\"\"", ")", ";", "platformNames", ".", "add", "(", "\"\"", ")", ";", "platformNames", ".", "add", "(", "\"\"", ")", ";", "platformNames", ".", "add", "(", "\"\"", ")", ";", "platformNames", ".", "add", "(", "\"\"", ")", ";", "platformNames", ".", "add", "(", "\"\"", ")", ";", "platformNames", ".", "add", "(", "\"\"", ")", ";", "platformNames", ".", "add", "(", "\"\"", ")", ";", "platformNames", ".", "add", "(", "\"\"", ")", ";", "platformNames", ".", "add", "(", "\"\"", ")", ";", "platformNames", ".", "add", "(", "\"\"", ")", ";", "platformNames", ".", "add", "(", "\"\"", ")", ";", "platformNames", ".", "add", "(", "\"\"", ")", ";", "platformNames", ".", "add", "(", "\"\"", ")", ";", "}", "@", "Override", "public", "void", "initialize", "(", "IPath", "path", ",", "IJavaProject", "javaProject", ")", "throws", "CoreException", "{", "if", "(", "javaProject", ".", "getProject", "(", ")", ".", "getName", "(", ")", ".", "equals", "(", "\"eclim\"", ")", ")", "{", "EclimClasspathContainer", "container", "=", "new", "EclimClasspathContainer", "(", "path", ",", "computeClasspathEntries", "(", "javaProject", ")", ")", ";", "JavaCore", ".", "setClasspathContainer", "(", "path", ",", "new", "IJavaProject", "[", "]", "{", "javaProject", "}", ",", "new", "IClasspathContainer", "[", "]", "{", "container", "}", ",", "new", "NullProgressMonitor", "(", ")", ")", ";", "}", "}", "private", "IClasspathEntry", "[", "]", "computeClasspathEntries", "(", "IJavaProject", "javaProject", ")", "{", "final", "ArrayList", "<", "IClasspathEntry", ">", "list", "=", "new", "ArrayList", "<", "IClasspathEntry", ">", "(", ")", ";", "try", "{", "final", "LinkedHashSet", "<", "String", ">", "bundleNames", "=", "new", "LinkedHashSet", "<", "String", ">", "(", ")", ";", "final", "ArrayList", "<", "String", ">", "jarPaths", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "final", "String", "projectPath", "=", "ProjectUtils", ".", "getPath", "(", "javaProject", ".", "getProject", "(", ")", ")", ";", "new", "File", "(", "projectPath", ")", ".", "list", "(", "new", "FilenameFilter", "(", ")", "{", "public", "boolean", "accept", "(", "File", "dir", ",", "String", "name", ")", "{", "if", "(", "name", ".", "startsWith", "(", "\"org.eclim\"", ")", ")", "{", "File", "manifest", "=", "new", "File", "(", "dir", ".", "getPath", "(", ")", "+", "'/'", "+", "name", "+", "\"\"", ")", ";", "if", "(", "manifest", ".", "exists", "(", ")", ")", "{", "FileInputStream", "fin", "=", "null", ";", "try", "{", "fin", "=", "new", "FileInputStream", "(", "manifest", ")", ";", "HashMap", "<", "String", ",", "String", ">", "headers", "=", "new", "HashMap", "<", "String", ",", "String", ">", "(", ")", ";", "ManifestElement", ".", "parseBundleManifest", "(", "fin", ",", "headers", ")", ";", "String", "requiredBundles", "=", "headers", ".", "get", "(", "\"\"", ")", ";", "for", "(", "String", "bname", ":", "requiredBundles", ".", "split", "(", "\",\\\\s*\"", ")", ")", "{", "if", "(", "bname", ".", "startsWith", "(", "\"org.eclim\"", ")", ")", "{", "continue", ";", "}", "bundleNames", ".", "add", "(", "bname", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "logger", ".", "error", "(", "\"\"", "+", "manifest", ",", "e", ")", ";", "}", "finally", "{", "IOUtils", ".", "closeQuietly", "(", "fin", ")", ";", "}", "}", "File", "lib", "=", "new", "File", "(", "dir", ".", "getPath", "(", ")", "+", "'/'", "+", "name", "+", "\"/lib\"", ")", ";", "if", "(", "lib", ".", "exists", "(", ")", ")", "{", "for", "(", "String", "jar", ":", "lib", ".", "list", "(", ")", ")", "{", "if", "(", "jar", ".", "endsWith", "(", "\".jar\"", ")", ")", "{", "jarPaths", ".", "add", "(", "name", "+", "\"/lib/\"", "+", "jar", ")", ";", "}", "}", "}", "}", "return", "false", ";", "}", "}", ")", ";", "CodeSource", "source", "=", "SWT", ".", "class", ".", "getProtectionDomain", "(", ")", ".", "getCodeSource", "(", ")", ";", "if", "(", "source", "!=", "null", ")", "{", "URL", "swt", "=", "source", ".", "getLocation", "(", ")", ";", "if", "(", "swt", "!=", "null", ")", "{", "logger", ".", "debug", "(", "\"\"", ",", "swt", ".", "getPath", "(", ")", ")", ";", "Path", "path", "=", "new", "Path", "(", "swt", ".", "getPath", "(", ")", ")", ";", "list", ".", "add", "(", "JavaCore", ".", "newLibraryEntry", "(", "path", ",", "sourcePath", "(", "path", ")", ",", "null", ",", "null", ",", "attributes", "(", "path", ")", ",", "false", ")", ")", ";", "}", "}", "for", "(", "String", "name", ":", "bundleNames", ")", "{", "logger", ".", "debug", "(", "\"\"", ",", "name", ")", ";", "try", "{", "Bundle", "bundle", "=", "Platform", ".", "getBundle", "(", "name", ")", ";", "if", "(", "bundle", "!=", "null", ")", "{", "String", "pathName", "=", "FileLocator", ".", "getBundleFile", "(", "bundle", ")", ".", "getPath", "(", ")", ";", "Path", "path", "=", "new", "Path", "(", "pathName", ")", ";", "list", ".", "add", "(", "JavaCore", ".", "newLibraryEntry", "(", "path", ",", "sourcePath", "(", "path", ")", ",", "null", ",", "null", ",", "attributes", "(", "path", ")", ",", "false", ")", ")", ";", "if", "(", "path", ".", "toFile", "(", ")", ".", "isDirectory", "(", ")", ")", "{", "listFiles", "(", "path", ".", "toFile", "(", ")", ",", "new", "FileFilter", "(", ")", "{", "public", "boolean", "accept", "(", "File", "file", ")", "{", "if", "(", "file", ".", "getName", "(", ")", ".", "endsWith", "(", "\".jar\"", ")", ")", "{", "list", ".", "add", "(", "JavaCore", ".", "newLibraryEntry", "(", "new", "Path", "(", "file", ".", "getPath", "(", ")", ")", ",", "null", ",", "null", ",", "null", ",", "null", ",", "false", ")", ")", ";", "}", "else", "if", "(", "file", ".", "isDirectory", "(", ")", ")", "{", "listFiles", "(", "file", ",", "this", ")", ";", "}", "return", "false", ";", "}", "}", ")", ";", "}", "}", "}", "catch", "(", "IOException", "ioe", ")", "{", "logger", ".", "error", "(", "\"\"", "+", "name", ",", "ioe", ")", ";", "}", "}", "listFiles", "(", "new", "File", "(", "projectPath", "+", "\"\"", ")", ",", "new", "FileFilter", "(", ")", "{", "public", "boolean", "accept", "(", "File", "file", ")", "{", "if", "(", "file", ".", "getName", "(", ")", ".", "endsWith", "(", "\".jar\"", ")", ")", "{", "String", "jar", "=", "file", ".", "getPath", "(", ")", ".", "replace", "(", "projectPath", ",", "\"\"", ")", ";", "if", "(", "jar", ".", "startsWith", "(", "\"/\"", ")", ")", "{", "jar", "=", "jar", ".", "substring", "(", "1", ")", ";", "}", "jarPaths", ".", "add", "(", "jar", ")", ";", "}", "if", "(", "file", ".", "isDirectory", "(", ")", ")", "{", "listFiles", "(", "file", ",", "this", ")", ";", "}", "return", "false", ";", "}", "}", ")", ";", "for", "(", "String", "jarPath", ":", "jarPaths", ")", "{", "logger", ".", "debug", "(", "\"\"", ",", "jarPath", ")", ";", "list", ".", "add", "(", "JavaCore", ".", "newLibraryEntry", "(", "new", "Path", "(", "projectPath", "+", "'/'", "+", "jarPath", ")", ",", "null", ",", "null", ",", "null", ",", "null", ",", "false", ")", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "logger", ".", "error", "(", "\"\"", ",", "e", ")", ";", "}", "return", "(", "IClasspathEntry", "[", "]", ")", "list", ".", "toArray", "(", "new", "IClasspathEntry", "[", "list", ".", "size", "(", ")", "]", ")", ";", "}", "private", "void", "listFiles", "(", "File", "dir", ",", "FileFilter", "filter", ")", "{", "dir", ".", "listFiles", "(", "filter", ")", ";", "}", "private", "Path", "sourcePath", "(", "Path", "path", ")", "{", "Path", "sourcePath", "=", "null", ";", "if", "(", "path", ".", "lastSegment", "(", ")", ".", "indexOf", "(", "\".x86_64_\"", ")", "!=", "-", "1", ")", "{", "sourcePath", "=", "new", "Path", "(", "path", ".", "uptoSegment", "(", "path", ".", "segmentCount", "(", ")", "-", "1", ")", ".", "toString", "(", ")", "+", "File", ".", "separator", "+", "path", ".", "lastSegment", "(", ")", ".", "replace", "(", "\".x86_64_\"", ",", "\"\"", ")", ")", ";", "}", "else", "{", "String", "[", "]", "parts", "=", "StringUtils", ".", "split", "(", "path", ".", "lastSegment", "(", ")", ",", "\"_\"", ",", "2", ")", ";", "sourcePath", "=", "parts", ".", "length", "==", "2", "?", "new", "Path", "(", "path", ".", "uptoSegment", "(", "path", ".", "segmentCount", "(", ")", "-", "1", ")", ".", "toString", "(", ")", "+", "File", ".", "separator", "+", "parts", "[", "0", "]", "+", "\".source_\"", "+", "parts", "[", "1", "]", ")", ":", "null", ";", "}", "return", "sourcePath", "!=", "null", "&&", "sourcePath", ".", "toFile", "(", ")", ".", "exists", "(", ")", "?", "sourcePath", ":", "null", ";", "}", "private", "IClasspathAttribute", "[", "]", "attributes", "(", "Path", "path", ")", "{", "String", "name", "=", "null", ";", "if", "(", "path", ".", "lastSegment", "(", ")", ".", "indexOf", "(", "\".x86_64_\"", ")", "!=", "-", "1", ")", "{", "name", "=", "path", ".", "lastSegment", "(", ")", ".", "replaceFirst", "(", "\".x86_64_.*\"", ",", "\"\"", ")", ";", "}", "else", "{", "String", "[", "]", "parts", "=", "StringUtils", ".", "split", "(", "path", ".", "lastSegment", "(", ")", ",", "\"_\"", ",", "2", ")", ";", "name", "=", "parts", "[", "0", "]", ";", "}", "if", "(", "!", "name", ".", "startsWith", "(", "\"org.eclipse.\"", ")", ")", "{", "return", "null", ";", "}", "final", "IPath", "dir", "=", "path", ".", "uptoSegment", "(", "path", ".", "segmentCount", "(", ")", "-", "1", ")", ";", "if", "(", "!", "docJars", ".", "containsKey", "(", "dir", ")", ")", "{", "docJars", ".", "put", "(", "dir", ",", "new", "HashMap", "<", "String", ",", "String", ">", "(", ")", ")", ";", "dir", ".", "toFile", "(", ")", ".", "list", "(", "new", "FilenameFilter", "(", ")", "{", "public", "boolean", "accept", "(", "File", "path", ",", "String", "name", ")", "{", "if", "(", "name", ".", "endsWith", "(", "\".jar\"", ")", "&&", "name", ".", "indexOf", "(", "\".doc.isv_\"", ")", "!=", "-", "1", ")", "{", "String", "url", "=", "\"jar:file:\"", "+", "path", "+", "'/'", "+", "name", "+", "\"\"", ";", "String", "bundleName", "=", "name", ".", "replaceFirst", "(", "\"\"", ",", "\"\"", ")", ";", "docJars", ".", "get", "(", "dir", ")", ".", "put", "(", "bundleName", ",", "url", ")", ";", "}", "return", "false", ";", "}", "}", ")", ";", "}", "String", "url", "=", "null", ";", "Map", "<", "String", ",", "String", ">", "jars", "=", "docJars", ".", "get", "(", "dir", ")", ";", "String", "shortName", "=", "StringUtils", ".", "join", "(", "StringUtils", ".", "split", "(", "name", ",", "\".\"", ",", "4", ")", ",", "\".\"", ",", "0", ",", "3", ")", ";", "if", "(", "jars", ".", "containsKey", "(", "shortName", ")", ")", "{", "url", "=", "jars", ".", "get", "(", "shortName", ")", ";", "}", "else", "if", "(", "platformNames", ".", "contains", "(", "shortName", ")", "&&", "docJars", ".", "containsKey", "(", "\"\"", ")", ")", "{", "url", "=", "jars", ".", "get", "(", "\"\"", ")", ";", "}", "if", "(", "url", "!=", "null", ")", "{", "return", "new", "IClasspathAttribute", "[", "]", "{", "JavaCore", ".", "newClasspathAttribute", "(", "IClasspathAttribute", ".", "JAVADOC_LOCATION_ATTRIBUTE_NAME", ",", "url", ")", "}", ";", "}", "return", "null", ";", "}", "}", "</s>" ]
1,274
[ "<s>", "package", "org", ".", "eclim", ".", "eclipse", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "IPath", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IClasspathContainer", ";", "import", "org", ".", "eclipse", ".", "jdt", ".", "core", ".", "IClasspathEntry", ";", "public", "class", "EclimClasspathContainer", "implements", "IClasspathContainer", "{", "private", "IPath", "path", ";", "private", "IClasspathEntry", "[", "]", "entries", ";", "public", "EclimClasspathContainer", "(", "IPath", "path", ",", "IClasspathEntry", "[", "]", "entries", ")", "{", "this", ".", "path", "=", "path", ";", "this", ".", "entries", "=", "entries", ";", "}", "public", "IClasspathEntry", "[", "]", "getClasspathEntries", "(", ")", "{", "return", "entries", ";", "}", "public", "String", "getDescription", "(", ")", "{", "return", "\"\"", ";", "}", "public", "int", "getKind", "(", ")", "{", "return", "IClasspathContainer", ".", "K_DEFAULT_SYSTEM", ";", "}", "public", "IPath", "getPath", "(", ")", "{", "return", "path", ";", "}", "}", "</s>" ]
1,275
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "maven", ".", "command", ".", "dependency", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "org", ".", "eclim", ".", "Eclim", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "maven", ".", "Maven", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "*", ";", "public", "class", "SearchCommandTest", "{", "private", "static", "final", "String", "TEST_FILE", "=", "\"pom.xml\"", ";", "@", "Test", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "void", "execute", "(", ")", "{", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", "results", "=", "(", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"\"", ",", "\"-p\"", ",", "Maven", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "TEST_FILE", ",", "\"-t\"", ",", "\"mvn\"", ",", "\"-s\"", ",", "\"junit\"", "}", ")", ";", "assertEquals", "(", "\"ant\"", ",", "results", ".", "get", "(", "0", ")", ".", "get", "(", "\"groupId\"", ")", ")", ";", "Map", "<", "String", ",", "Object", ">", "junit381", "=", "null", ";", "for", "(", "Map", "<", "String", ",", "Object", ">", "result", ":", "results", ")", "{", "if", "(", "result", ".", "get", "(", "\"artifactId\"", ")", ".", "equals", "(", "\"junit\"", ")", "&&", "result", ".", "get", "(", "\"version\"", ")", ".", "equals", "(", "\"3.8.1\"", ")", ")", "{", "junit381", "=", "result", ";", "break", ";", "}", "}", "assertNotNull", "(", "junit381", ")", ";", "assertEquals", "(", "true", ",", "junit381", ".", "get", "(", "\"existing\"", ")", ")", ";", "}", "}", "</s>" ]
1,276
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "maven", ";", "public", "class", "Maven", "{", "public", "static", "final", "String", "TEST_PROJECT", "=", "\"\"", ";", "}", "</s>" ]
1,277
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "log4j", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "org", ".", "eclim", ".", "Eclim", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "Jdt", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "*", ";", "public", "class", "ValidateCommandTest", "{", "private", "static", "final", "String", "TEST_FILE", "=", "\"\"", ";", "@", "Test", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "void", "validateXmlErrors", "(", ")", "{", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", "results", "=", "(", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"\"", ",", "\"-p\"", ",", "Jdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "TEST_FILE", "}", ")", ";", "assertEquals", "(", "\"\"", ",", "6", ",", "results", ".", "size", "(", ")", ")", ";", "String", "file", "=", "Eclim", ".", "resolveFile", "(", "Jdt", ".", "TEST_PROJECT", ",", "TEST_FILE", ")", ";", "Map", "<", "String", ",", "Object", ">", "error", "=", "results", ".", "get", "(", "0", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"filename\"", ")", ",", "file", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"message\"", ")", ",", "\"\"", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"line\"", ")", ",", "23", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"column\"", ")", ",", "45", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"warning\"", ")", ",", "false", ")", ";", "error", "=", "results", ".", "get", "(", "1", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"filename\"", ")", ",", "file", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"message\"", ")", ",", "\"\"", "+", "\"\"", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"line\"", ")", ",", "27", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"column\"", ")", ",", "14", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"warning\"", ")", ",", "false", ")", ";", "error", "=", "results", ".", "get", "(", "2", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"filename\"", ")", ",", "file", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"message\"", ")", ",", "\"\"", "+", "\"\"", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"line\"", ")", ",", "9", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"column\"", ")", ",", "1", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"warning\"", ")", ",", "false", ")", ";", "error", "=", "results", ".", "get", "(", "3", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"filename\"", ")", ",", "file", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"message\"", ")", ",", "\"\"", "+", "\"\"", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"line\"", ")", ",", "14", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"column\"", ")", ",", "1", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"warning\"", ")", ",", "false", ")", ";", "error", "=", "results", ".", "get", "(", "4", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"filename\"", ")", ",", "file", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"message\"", ")", ",", "\"\"", "+", "\"\"", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"line\"", ")", ",", "22", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"column\"", ")", ",", "1", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"warning\"", ")", ",", "false", ")", ";", "error", "=", "results", ".", "get", "(", "5", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"filename\"", ")", ",", "file", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"message\"", ")", ",", "\"\"", "+", "\"\"", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"line\"", ")", ",", "24", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"column\"", ")", ",", "1", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"warning\"", ")", ",", "false", ")", ";", "}", "}", "</s>" ]
1,278
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "complete", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "org", ".", "eclim", ".", "Eclim", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "Jdt", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "*", ";", "public", "class", "CodeCompleteCommandTest", "{", "private", "static", "final", "String", "TEST_FILE", "=", "\"\"", ";", "@", "Test", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "void", "completionAllMembers", "(", ")", "{", "assertTrue", "(", "\"\"", ",", "Eclim", ".", "projectExists", "(", "Jdt", ".", "TEST_PROJECT", ")", ")", ";", "Map", "<", "String", ",", "Object", ">", "results", "=", "(", "Map", "<", "String", ",", "Object", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"\"", ",", "\"-p\"", ",", "Jdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "TEST_FILE", ",", "\"-o\"", ",", "\"184\"", ",", "\"-e\"", ",", "\"utf-8\"", ",", "\"-l\"", ",", "\"standard\"", "}", ")", ";", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", "completions", "=", "(", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", ")", "results", ".", "get", "(", "\"completions\"", ")", ";", "assertTrue", "(", "\"\"", ",", "completions", ".", "size", "(", ")", ">", "30", ")", ";", "Map", "<", "String", ",", "Object", ">", "result", "=", "completions", ".", "get", "(", "0", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"completion\"", ")", ",", "\"add(\"", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"menu\"", ")", ",", "\"\"", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"info\"", ")", ",", "\"\"", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"type\"", ")", ",", "\"f\"", ")", ";", "result", "=", "completions", ".", "get", "(", "completions", ".", "size", "(", ")", "-", "1", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"completion\"", ")", ",", "\"wait()\"", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"menu\"", ")", ",", "\"\"", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"info\"", ")", ",", "\"\"", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"type\"", ")", ",", "\"f\"", ")", ";", "}", "@", "Test", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "void", "completionByPrefix", "(", ")", "{", "assertTrue", "(", "\"\"", ",", "Eclim", ".", "projectExists", "(", "Jdt", ".", "TEST_PROJECT", ")", ")", ";", "Map", "<", "String", ",", "Object", ">", "results", "=", "(", "Map", "<", "String", ",", "Object", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"\"", ",", "\"-p\"", ",", "Jdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "TEST_FILE", ",", "\"-o\"", ",", "\"266\"", ",", "\"-e\"", ",", "\"utf-8\"", ",", "\"-l\"", ",", "\"standard\"", "}", ")", ";", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", "completions", "=", "(", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", ")", "results", ".", "get", "(", "\"completions\"", ")", ";", "assertEquals", "(", "\"\"", ",", "4", ",", "completions", ".", "size", "(", ")", ")", ";", "Map", "<", "String", ",", "Object", ">", "result", "=", "completions", ".", "get", "(", "0", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"completion\"", ")", ",", "\"add(\"", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"menu\"", ")", ",", "\"\"", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"info\"", ")", ",", "\"\"", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"type\"", ")", ",", "\"f\"", ")", ";", "result", "=", "completions", ".", "get", "(", "completions", ".", "size", "(", ")", "-", "1", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"completion\"", ")", ",", "\"addAll(\"", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"menu\"", ")", ",", "\"\"", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"info\"", ")", ",", "\"\"", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"type\"", ")", ",", "\"f\"", ")", ";", "}", "@", "Test", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "void", "completionMissingImport", "(", ")", "{", "Map", "<", "String", ",", "Object", ">", "results", "=", "(", "Map", "<", "String", ",", "Object", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"\"", ",", "\"-p\"", ",", "Jdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "TEST_FILE", ",", "\"-o\"", ",", "\"371\"", ",", "\"-e\"", ",", "\"utf-8\"", ",", "\"-l\"", ",", "\"standard\"", "}", ")", ";", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", "completions", "=", "(", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", ")", "results", ".", "get", "(", "\"completions\"", ")", ";", "assertEquals", "(", "\"\"", ",", "0", ",", "completions", ".", "size", "(", ")", ")", ";", "assertTrue", "(", "\"\"", ",", "results", ".", "containsKey", "(", "\"imports\"", ")", ")", ";", "ArrayList", "<", "String", ">", "imports", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "imports", ".", "add", "(", "\"\"", ")", ";", "assertEquals", "(", "\"\"", ",", "imports", ",", "results", ".", "get", "(", "\"imports\"", ")", ")", ";", "assertTrue", "(", "\"\"", ",", "results", ".", "containsKey", "(", "\"error\"", ")", ")", ";", "Map", "<", "String", ",", "Object", ">", "error", "=", "(", "Map", "<", "String", ",", "Object", ">", ")", "results", ".", "get", "(", "\"error\"", ")", ";", "assertEquals", "(", "\"\"", ",", "\"\"", ",", "error", ".", "get", "(", "\"message\"", ")", ")", ";", "}", "@", "Test", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "void", "completionMissingImportStatic", "(", ")", "{", "Map", "<", "String", ",", "Object", ">", "results", "=", "(", "Map", "<", "String", ",", "Object", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"\"", ",", "\"-p\"", ",", "Jdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "TEST_FILE", ",", "\"-o\"", ",", "\"436\"", ",", "\"-e\"", ",", "\"utf-8\"", ",", "\"-l\"", ",", "\"standard\"", "}", ")", ";", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", "completions", "=", "(", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", ")", "results", ".", "get", "(", "\"completions\"", ")", ";", "assertEquals", "(", "\"\"", ",", "0", ",", "completions", ".", "size", "(", ")", ")", ";", "assertTrue", "(", "\"\"", ",", "results", ".", "containsKey", "(", "\"imports\"", ")", ")", ";", "ArrayList", "<", "String", ">", "imports", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "imports", ".", "add", "(", "\"\"", ")", ";", "assertEquals", "(", "\"\"", ",", "imports", ",", "results", ".", "get", "(", "\"imports\"", ")", ")", ";", "assertTrue", "(", "\"\"", ",", "results", ".", "containsKey", "(", "\"error\"", ")", ")", ";", "Map", "<", "String", ",", "Object", ">", "error", "=", "(", "Map", "<", "String", ",", "Object", ">", ")", "results", ".", "get", "(", "\"error\"", ")", ";", "assertEquals", "(", "\"\"", ",", "\"\"", ",", "error", ".", "get", "(", "\"message\"", ")", ")", ";", "}", "}", "</s>" ]
1,279
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "junit", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "eclim", ".", "Eclim", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "Jdt", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "*", ";", "public", "class", "JUnitTestsCommandTest", "{", "@", "Test", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "void", "execute", "(", ")", "{", "assertTrue", "(", "\"\"", ",", "Eclim", ".", "projectExists", "(", "Jdt", ".", "TEST_PROJECT", ")", ")", ";", "List", "<", "String", ">", "results", "=", "(", "List", "<", "String", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"\"", ",", "\"-p\"", ",", "Jdt", ".", "TEST_PROJECT", "}", ")", ";", "results", ".", "remove", "(", "\"\"", ")", ";", "assertEquals", "(", "3", ",", "results", ".", "size", "(", ")", ")", ";", "assertEquals", "(", "\"\"", ",", "results", ".", "get", "(", "0", ")", ")", ";", "assertEquals", "(", "\"\"", ",", "results", ".", "get", "(", "1", ")", ")", ";", "assertEquals", "(", "\"\"", ",", "results", ".", "get", "(", "2", ")", ")", ";", "}", "}", "</s>" ]
1,280
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "junit", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "org", ".", "eclim", ".", "Eclim", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "Jdt", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "*", ";", "public", "class", "JUnitFindTestCommandTest", "{", "private", "static", "final", "String", "CLASS", "=", "\"\"", ";", "private", "static", "final", "String", "TEST", "=", "\"\"", ";", "@", "Test", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "void", "executeClassToTest", "(", ")", "{", "assertTrue", "(", "\"\"", ",", "Eclim", ".", "projectExists", "(", "Jdt", ".", "TEST_PROJECT", ")", ")", ";", "Map", "<", "String", ",", "Object", ">", "result", "=", "(", "Map", "<", "String", ",", "Object", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"\"", ",", "\"-p\"", ",", "Jdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "CLASS", ",", "\"-o\"", ",", "\"0\"", ",", "\"-e\"", ",", "\"utf-8\"", ",", "}", ")", ";", "assertEquals", "(", "Eclim", ".", "resolveFile", "(", "Jdt", ".", "TEST_PROJECT", ",", "TEST", ")", ",", "result", ".", "get", "(", "\"filename\"", ")", ")", ";", "assertEquals", "(", "\"FooTest\"", ",", "result", ".", "get", "(", "\"message\"", ")", ")", ";", "assertEquals", "(", "7", ",", "result", ".", "get", "(", "\"line\"", ")", ")", ";", "assertEquals", "(", "1", ",", "result", ".", "get", "(", "\"column\"", ")", ")", ";", "result", "=", "(", "Map", "<", "String", ",", "Object", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"\"", ",", "\"-p\"", ",", "Jdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "CLASS", ",", "\"-o\"", ",", "\"70\"", ",", "\"-e\"", ",", "\"utf-8\"", ",", "}", ")", ";", "assertEquals", "(", "Eclim", ".", "resolveFile", "(", "Jdt", ".", "TEST_PROJECT", ",", "TEST", ")", ",", "result", ".", "get", "(", "\"filename\"", ")", ")", ";", "assertEquals", "(", "\"foo\"", ",", "result", ".", "get", "(", "\"message\"", ")", ")", ";", "assertEquals", "(", "9", ",", "result", ".", "get", "(", "\"line\"", ")", ")", ";", "assertEquals", "(", "3", ",", "result", ".", "get", "(", "\"column\"", ")", ")", ";", "result", "=", "(", "Map", "<", "String", ",", "Object", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"\"", ",", "\"-p\"", ",", "Jdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "CLASS", ",", "\"-o\"", ",", "\"163\"", ",", "\"-e\"", ",", "\"utf-8\"", ",", "}", ")", ";", "assertEquals", "(", "Eclim", ".", "resolveFile", "(", "Jdt", ".", "TEST_PROJECT", ",", "TEST", ")", ",", "result", ".", "get", "(", "\"filename\"", ")", ")", ";", "assertEquals", "(", "\"fooString\"", ",", "result", ".", "get", "(", "\"message\"", ")", ")", ";", "assertEquals", "(", "16", ",", "result", ".", "get", "(", "\"line\"", ")", ")", ";", "assertEquals", "(", "3", ",", "result", ".", "get", "(", "\"column\"", ")", ")", ";", "}", "@", "Test", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "void", "executeTestToClass", "(", ")", "{", "assertTrue", "(", "\"\"", ",", "Eclim", ".", "projectExists", "(", "Jdt", ".", "TEST_PROJECT", ")", ")", ";", "Map", "<", "String", ",", "Object", ">", "result", "=", "(", "Map", "<", "String", ",", "Object", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"\"", ",", "\"-p\"", ",", "Jdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "TEST", ",", "\"-o\"", ",", "\"0\"", ",", "\"-e\"", ",", "\"utf-8\"", ",", "}", ")", ";", "assertEquals", "(", "Eclim", ".", "resolveFile", "(", "Jdt", ".", "TEST_PROJECT", ",", "CLASS", ")", ",", "result", ".", "get", "(", "\"filename\"", ")", ")", ";", "assertEquals", "(", "\"Foo\"", ",", "result", ".", "get", "(", "\"message\"", ")", ")", ";", "assertEquals", "(", "3", ",", "result", ".", "get", "(", "\"line\"", ")", ")", ";", "assertEquals", "(", "1", ",", "result", ".", "get", "(", "\"column\"", ")", ")", ";", "result", "=", "(", "Map", "<", "String", ",", "Object", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"\"", ",", "\"-p\"", ",", "Jdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "TEST", ",", "\"-o\"", ",", "\"178\"", ",", "\"-e\"", ",", "\"utf-8\"", ",", "}", ")", ";", "assertEquals", "(", "Eclim", ".", "resolveFile", "(", "Jdt", ".", "TEST_PROJECT", ",", "CLASS", ")", ",", "result", ".", "get", "(", "\"filename\"", ")", ")", ";", "assertEquals", "(", "\"foo\"", ",", "result", ".", "get", "(", "\"message\"", ")", ")", ";", "assertEquals", "(", "5", ",", "result", ".", "get", "(", "\"line\"", ")", ")", ";", "assertEquals", "(", "3", ",", "result", ".", "get", "(", "\"column\"", ")", ")", ";", "result", "=", "(", "Map", "<", "String", ",", "Object", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"\"", ",", "\"-p\"", ",", "Jdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "TEST", ",", "\"-o\"", ",", "\"374\"", ",", "\"-e\"", ",", "\"utf-8\"", ",", "}", ")", ";", "assertEquals", "(", "Eclim", ".", "resolveFile", "(", "Jdt", ".", "TEST_PROJECT", ",", "CLASS", ")", ",", "result", ".", "get", "(", "\"filename\"", ")", ")", ";", "assertEquals", "(", "\"foo\"", ",", "result", ".", "get", "(", "\"message\"", ")", ")", ";", "assertEquals", "(", "10", ",", "result", ".", "get", "(", "\"line\"", ")", ")", ";", "assertEquals", "(", "3", ",", "result", ".", "get", "(", "\"column\"", ")", ")", ";", "}", "}", "</s>" ]
1,281
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "junit", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang", ".", "StringUtils", ";", "import", "org", ".", "eclim", ".", "Eclim", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "Jdt", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "*", ";", "public", "class", "JUnitCommandTest", "{", "private", "static", "final", "String", "CLASS", "=", "\"\"", ";", "private", "static", "final", "String", "TEST", "=", "\"\"", ";", "@", "Test", "public", "void", "executeTest", "(", ")", "{", "assertTrue", "(", "\"\"", ",", "Eclim", ".", "projectExists", "(", "Jdt", ".", "TEST_PROJECT", ")", ")", ";", "String", "result", "=", "(", "String", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"java_junit\"", ",", "\"-p\"", ",", "Jdt", ".", "TEST_PROJECT", ",", "\"-t\"", ",", "\"\"", ",", "}", ",", "false", ")", ";", "String", "[", "]", "lines", "=", "StringUtils", ".", "split", "(", "result", ",", "'\\n'", ")", ";", "assertEquals", "(", "\"\"", ",", "lines", "[", "1", "]", ")", ";", "assertTrue", "(", "lines", "[", "3", "]", ".", "startsWith", "(", "\"\"", ")", ")", ";", "assertTrue", "(", "lines", "[", "4", "]", ".", "startsWith", "(", "\"\"", ")", ")", ";", "assertTrue", "(", "lines", "[", "5", "]", ".", "startsWith", "(", "\"\"", ")", ")", ";", "assertTrue", "(", "lines", "[", "6", "]", ".", "startsWith", "(", "\"\"", ")", ")", ";", "}", "@", "Test", "public", "void", "executeMethod", "(", ")", "{", "assertTrue", "(", "\"\"", ",", "Eclim", ".", "projectExists", "(", "Jdt", ".", "TEST_PROJECT", ")", ")", ";", "String", "result", "=", "(", "String", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"java_junit\"", ",", "\"-p\"", ",", "Jdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "TEST", ",", "\"-o\"", ",", "\"127\"", ",", "\"-e\"", ",", "\"utf-8\"", ",", "}", ",", "false", ")", ";", "String", "[", "]", "lines", "=", "StringUtils", ".", "split", "(", "result", ",", "'\\n'", ")", ";", "assertEquals", "(", "\"\"", ",", "lines", "[", "1", "]", ")", ";", "assertTrue", "(", "lines", "[", "3", "]", ".", "startsWith", "(", "\"\"", ")", ")", ";", "assertTrue", "(", "lines", "[", "4", "]", ".", "startsWith", "(", "\"\"", ")", ")", ";", "result", "=", "(", "String", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"java_junit\"", ",", "\"-p\"", ",", "Jdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "CLASS", ",", "\"-o\"", ",", "\"151\"", ",", "\"-e\"", ",", "\"utf-8\"", ",", "}", ",", "false", ")", ";", "lines", "=", "StringUtils", ".", "split", "(", "result", ",", "'\\n'", ")", ";", "assertEquals", "(", "\"\"", ",", "lines", "[", "1", "]", ")", ";", "assertTrue", "(", "lines", "[", "3", "]", ".", "startsWith", "(", "\"\"", ")", ")", ";", "assertTrue", "(", "lines", "[", "4", "]", ".", "startsWith", "(", "\"\"", ")", ")", ";", "}", "@", "Test", "public", "void", "executePattern", "(", ")", "{", "assertTrue", "(", "\"\"", ",", "Eclim", ".", "projectExists", "(", "Jdt", ".", "TEST_PROJECT", ")", ")", ";", "String", "result", "=", "(", "String", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"java_junit\"", ",", "\"-p\"", ",", "Jdt", ".", "TEST_PROJECT", ",", "\"-t\"", ",", "\"**/run/*Test\"", ",", "}", ",", "false", ")", ";", "String", "[", "]", "lines", "=", "StringUtils", ".", "split", "(", "result", ",", "'\\n'", ")", ";", "assertEquals", "(", "\"\"", ",", "lines", "[", "1", "]", ")", ";", "assertTrue", "(", "lines", "[", "3", "]", ".", "startsWith", "(", "\"\"", ")", ")", ";", "assertTrue", "(", "lines", "[", "4", "]", ".", "startsWith", "(", "\"\"", ")", ")", ";", "assertEquals", "(", "\"\"", ",", "lines", "[", "6", "]", ")", ";", "assertTrue", "(", "lines", "[", "8", "]", ".", "startsWith", "(", "\"\"", ")", ")", ";", "assertTrue", "(", "lines", "[", "9", "]", ".", "startsWith", "(", "\"\"", ")", ")", ";", "assertTrue", "(", "lines", "[", "10", "]", ".", "startsWith", "(", "\"\"", ")", ")", ";", "assertTrue", "(", "lines", "[", "11", "]", ".", "startsWith", "(", "\"\"", ")", ")", ";", "}", "}", "</s>" ]
1,282
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "junit", ";", "import", "java", ".", "util", ".", "HashSet", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "java", ".", "util", ".", "regex", ".", "Pattern", ";", "import", "org", ".", "eclim", ".", "Eclim", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "Jdt", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "*", ";", "public", "class", "JUnitImplCommandTest", "{", "private", "static", "final", "String", "TEST_FILE", "=", "\"\"", ";", "private", "static", "final", "String", "TEST_FILE_DIFF_PACK", "=", "\"\"", ";", "@", "Test", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "void", "execute", "(", ")", "{", "assertTrue", "(", "\"\"", ",", "Eclim", ".", "projectExists", "(", "Jdt", ".", "TEST_PROJECT", ")", ")", ";", "Map", "<", "String", ",", "Object", ">", "result", "=", "(", "Map", "<", "String", ",", "Object", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"\"", ",", "\"-p\"", ",", "Jdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "TEST_FILE", ",", "}", ")", ";", "assertEquals", "(", "\"\"", ",", "result", ".", "get", "(", "\"type\"", ")", ")", ";", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", "types", "=", "(", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", ")", "result", ".", "get", "(", "\"superTypes\"", ")", ";", "assertEquals", "(", "3", ",", "types", ".", "size", "(", ")", ")", ";", "assertEquals", "(", "\"\"", ",", "types", ".", "get", "(", "0", ")", ".", "get", "(", "\"packageName\"", ")", ")", ";", "assertEquals", "(", "\"\"", ",", "types", ".", "get", "(", "0", ")", ".", "get", "(", "\"signature\"", ")", ")", ";", "HashSet", "<", "String", ">", "methods", "=", "new", "HashSet", "<", "String", ">", "(", "(", "List", "<", "String", ">", ")", "types", ".", "get", "(", "0", ")", ".", "get", "(", "\"methods\"", ")", ")", ";", "assertTrue", "(", "methods", ".", "contains", "(", "\"\"", ")", ")", ";", "assertTrue", "(", "methods", ".", "contains", "(", "\"\"", ")", ")", ";", "assertTrue", "(", "methods", ".", "contains", "(", "\"\"", ")", ")", ";", "result", "=", "(", "Map", "<", "String", ",", "Object", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"\"", ",", "\"-p\"", ",", "Jdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "TEST_FILE", ",", "\"-t\"", ",", "\"\"", ",", "\"-s\"", ",", "\"\"", ",", "\"-m\"", ",", "\"\"", "}", ")", ";", "String", "contents", "=", "Eclim", ".", "fileToString", "(", "Jdt", ".", "TEST_PROJECT", ",", "TEST_FILE", ")", ";", "assertTrue", "(", "\"\"", ",", "Pattern", ".", "compile", "(", "\"\"", ")", ".", "matcher", "(", "contents", ")", ".", "find", "(", ")", ")", ";", "types", "=", "(", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", ")", "result", ".", "get", "(", "\"superTypes\"", ")", ";", "assertEquals", "(", "\"\"", ",", "types", ".", "get", "(", "0", ")", ".", "get", "(", "\"packageName\"", ")", ")", ";", "assertEquals", "(", "\"\"", ",", "types", ".", "get", "(", "0", ")", ".", "get", "(", "\"signature\"", ")", ")", ";", "methods", "=", "new", "HashSet", "<", "String", ">", "(", "(", "List", "<", "String", ">", ")", "types", ".", "get", "(", "0", ")", ".", "get", "(", "\"methods\"", ")", ")", ";", "assertFalse", "(", "methods", ".", "contains", "(", "\"\"", ")", ")", ";", "assertFalse", "(", "methods", ".", "contains", "(", "\"\"", ")", ")", ";", "assertTrue", "(", "methods", ".", "contains", "(", "\"\"", ")", ")", ";", "}", "@", "Test", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "void", "executeDifferentPackage", "(", ")", "{", "assertTrue", "(", "\"\"", ",", "Eclim", ".", "projectExists", "(", "Jdt", ".", "TEST_PROJECT", ")", ")", ";", "Map", "<", "String", ",", "Object", ">", "result", "=", "(", "Map", "<", "String", ",", "Object", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"\"", ",", "\"-p\"", ",", "Jdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "TEST_FILE_DIFF_PACK", ",", "}", ")", ";", "assertEquals", "(", "\"\"", ",", "result", ".", "get", "(", "\"type\"", ")", ")", ";", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", "types", "=", "(", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", ")", "result", ".", "get", "(", "\"superTypes\"", ")", ";", "assertEquals", "(", "2", ",", "types", ".", "size", "(", ")", ")", ";", "assertEquals", "(", "\"\"", ",", "types", ".", "get", "(", "0", ")", ".", "get", "(", "\"packageName\"", ")", ")", ";", "assertEquals", "(", "\"class", "Testme\"", ",", "types", ".", "get", "(", "0", ")", ".", "get", "(", "\"signature\"", ")", ")", ";", "HashSet", "<", "String", ">", "methods", "=", "new", "HashSet", "<", "String", ">", "(", "(", "List", "<", "String", ">", ")", "types", ".", "get", "(", "0", ")", ".", "get", "(", "\"methods\"", ")", ")", ";", "assertTrue", "(", "methods", ".", "contains", "(", "\"\"", ")", ")", ";", "}", "}", "</s>" ]
1,283
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "classpath", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "org", ".", "eclim", ".", "Eclim", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "Jdt", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "*", ";", "public", "class", "ClasspathVariableCommandsTest", "{", "private", "static", "final", "String", "TEST_VARIABLE", "=", "\"\"", ";", "private", "static", "final", "String", "TEST_PATH", "=", "\"/tmp\"", ";", "@", "Test", "public", "void", "createVariable", "(", ")", "{", "assertTrue", "(", "\"\"", ",", "Eclim", ".", "projectExists", "(", "Jdt", ".", "TEST_PROJECT", ")", ")", ";", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"\"", ",", "\"-n\"", ",", "TEST_VARIABLE", "}", ")", ";", "assertFalse", "(", "\"\"", ",", "variableExists", "(", ")", ")", ";", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"\"", ",", "\"-n\"", ",", "TEST_VARIABLE", ",", "\"-p\"", ",", "TEST_PATH", "}", ")", ";", "assertTrue", "(", "\"\"", ",", "variableExists", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "deleteVariable", "(", ")", "{", "assertTrue", "(", "\"\"", ",", "Eclim", ".", "projectExists", "(", "Jdt", ".", "TEST_PROJECT", ")", ")", ";", "assertTrue", "(", "\"\"", ",", "variableExists", "(", ")", ")", ";", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"\"", ",", "\"-n\"", ",", "TEST_VARIABLE", "}", ")", ";", "assertFalse", "(", "\"\"", ",", "variableExists", "(", ")", ")", ";", "}", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "private", "boolean", "variableExists", "(", ")", "{", "List", "<", "Map", "<", "String", ",", "String", ">", ">", "list", "=", "(", "List", "<", "Map", "<", "String", ",", "String", ">", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"\"", "}", ")", ";", "Map", "<", "String", ",", "String", ">", "var", "=", "new", "HashMap", "<", "String", ",", "String", ">", "(", ")", ";", "var", ".", "put", "(", "\"name\"", ",", "TEST_VARIABLE", ")", ";", "var", ".", "put", "(", "\"path\"", ",", "TEST_PATH", ")", ";", "return", "list", ".", "contains", "(", "var", ")", ";", "}", "}", "</s>" ]
1,284
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "impl", ";", "import", "java", ".", "util", ".", "HashSet", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "java", ".", "util", ".", "regex", ".", "Pattern", ";", "import", "org", ".", "eclim", ".", "Eclim", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "Jdt", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "*", ";", "public", "class", "DelegateCommandTest", "{", "private", "static", "final", "String", "TEST_FILE", "=", "\"\"", ";", "@", "Test", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "void", "execute", "(", ")", "{", "assertTrue", "(", "\"\"", ",", "Eclim", ".", "projectExists", "(", "Jdt", ".", "TEST_PROJECT", ")", ")", ";", "Map", "<", "String", ",", "Object", ">", "result", "=", "(", "Map", "<", "String", ",", "Object", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"\"", ",", "\"-p\"", ",", "Jdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "TEST_FILE", ",", "\"-o\"", ",", "\"120\"", ",", "\"-e\"", ",", "\"utf-8\"", "}", ")", ";", "assertEquals", "(", "\"\"", ",", "result", ".", "get", "(", "\"type\"", ")", ")", ";", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", "types", "=", "(", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", ")", "result", ".", "get", "(", "\"superTypes\"", ")", ";", "assertEquals", "(", "1", ",", "types", ".", "size", "(", ")", ")", ";", "assertEquals", "(", "\"java.util\"", ",", "types", ".", "get", "(", "0", ")", ".", "get", "(", "\"packageName\"", ")", ")", ";", "assertEquals", "(", "\"\"", ",", "types", ".", "get", "(", "0", ")", ".", "get", "(", "\"signature\"", ")", ")", ";", "HashSet", "<", "String", ">", "methods", "=", "new", "HashSet", "<", "String", ">", "(", "(", "List", "<", "String", ">", ")", "types", ".", "get", "(", "0", ")", ".", "get", "(", "\"methods\"", ")", ")", ";", "assertTrue", "(", "methods", ".", "contains", "(", "\"\"", ")", ")", ";", "assertTrue", "(", "methods", ".", "contains", "(", "\"\"", ")", ")", ";", "result", "=", "(", "Map", "<", "String", ",", "Object", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"\"", ",", "\"-p\"", ",", "Jdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "TEST_FILE", ",", "\"-o\"", ",", "\"120\"", ",", "\"-e\"", ",", "\"utf-8\"", ",", "\"-v\"", ",", "\"\"", ",", "\"-s\"", ",", "\"\"", ",", "\"-m\"", ",", "\"\"", "}", ")", ";", "String", "contents", "=", "Eclim", ".", "fileToString", "(", "Jdt", ".", "TEST_PROJECT", ",", "TEST_FILE", ")", ";", "assertTrue", "(", "\"\"", ",", "Pattern", ".", "compile", "(", "\"\"", "+", "\"\"", ")", ".", "matcher", "(", "contents", ")", ".", "find", "(", ")", ")", ";", "assertTrue", "(", "\"\"", ",", "Pattern", ".", "compile", "(", "\"\"", "+", "\"\"", ")", ".", "matcher", "(", "contents", ")", ".", "find", "(", ")", ")", ";", "types", "=", "(", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", ")", "result", ".", "get", "(", "\"superTypes\"", ")", ";", "methods", "=", "new", "HashSet", "<", "String", ">", "(", "(", "List", "<", "String", ">", ")", "types", ".", "get", "(", "0", ")", ".", "get", "(", "\"methods\"", ")", ")", ";", "assertFalse", "(", "methods", ".", "contains", "(", "\"\"", ")", ")", ";", "assertFalse", "(", "methods", ".", "contains", "(", "\"\"", ")", ")", ";", "}", "}", "</s>" ]
1,285
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "impl", ";", "import", "java", ".", "util", ".", "regex", ".", "Pattern", ";", "import", "org", ".", "eclim", ".", "Eclim", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "Jdt", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "*", ";", "public", "class", "BeanPropertiesCommandTest", "{", "private", "static", "final", "String", "TEST_FILE", "=", "\"\"", ";", "@", "Test", "public", "void", "executeGet", "(", ")", "{", "assertTrue", "(", "\"\"", ",", "Eclim", ".", "projectExists", "(", "Jdt", ".", "TEST_PROJECT", ")", ")", ";", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"\"", ",", "\"-p\"", ",", "Jdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "TEST_FILE", ",", "\"-o\"", ",", "\"1\"", ",", "\"-e\"", ",", "\"utf-8\"", ",", "\"-t\"", ",", "\"getter\"", ",", "\"-r\"", ",", "\"name\"", "}", ")", ";", "String", "contents", "=", "Eclim", ".", "fileToString", "(", "Jdt", ".", "TEST_PROJECT", ",", "TEST_FILE", ")", ";", "assertTrue", "(", "\"\"", ",", "Pattern", ".", "compile", "(", "\"\"", ")", ".", "matcher", "(", "contents", ")", ".", "find", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "executeSet", "(", ")", "{", "assertTrue", "(", "\"\"", ",", "Eclim", ".", "projectExists", "(", "Jdt", ".", "TEST_PROJECT", ")", ")", ";", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"\"", ",", "\"-p\"", ",", "Jdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "TEST_FILE", ",", "\"-o\"", ",", "\"1\"", ",", "\"-e\"", ",", "\"utf-8\"", ",", "\"-t\"", ",", "\"setter\"", ",", "\"-r\"", ",", "\"name\"", "}", ")", ";", "String", "contents", "=", "Eclim", ".", "fileToString", "(", "Jdt", ".", "TEST_PROJECT", ",", "TEST_FILE", ")", ";", "assertTrue", "(", "\"\"", ",", "Pattern", ".", "compile", "(", "\"\"", ")", ".", "matcher", "(", "contents", ")", ".", "find", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "executeGetSet", "(", ")", "{", "assertTrue", "(", "\"\"", ",", "Eclim", ".", "projectExists", "(", "Jdt", ".", "TEST_PROJECT", ")", ")", ";", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"\"", ",", "\"-p\"", ",", "Jdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "TEST_FILE", ",", "\"-o\"", ",", "\"1\"", ",", "\"-e\"", ",", "\"utf-8\"", ",", "\"-t\"", ",", "\"\"", ",", "\"-r\"", ",", "\"valid\"", "}", ")", ";", "String", "contents", "=", "Eclim", ".", "fileToString", "(", "Jdt", ".", "TEST_PROJECT", ",", "TEST_FILE", ")", ";", "assertTrue", "(", "\"\"", ",", "Pattern", ".", "compile", "(", "\"\"", ")", ".", "matcher", "(", "contents", ")", ".", "find", "(", ")", ")", ";", "assertTrue", "(", "\"\"", ",", "Pattern", ".", "compile", "(", "\"\"", ")", ".", "matcher", "(", "contents", ")", ".", "find", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "executeGetSetIndex", "(", ")", "{", "assertTrue", "(", "\"\"", ",", "Eclim", ".", "projectExists", "(", "Jdt", ".", "TEST_PROJECT", ")", ")", ";", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"\"", ",", "\"-p\"", ",", "Jdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "TEST_FILE", ",", "\"-o\"", ",", "\"1\"", ",", "\"-e\"", ",", "\"utf-8\"", ",", "\"-t\"", ",", "\"\"", ",", "\"-r\"", ",", "\"ids\"", ",", "\"-i\"", "}", ")", ";", "String", "contents", "=", "Eclim", ".", "fileToString", "(", "Jdt", ".", "TEST_PROJECT", ",", "TEST_FILE", ")", ";", "assertTrue", "(", "\"\"", ",", "Pattern", ".", "compile", "(", "\"\"", ")", ".", "matcher", "(", "contents", ")", ".", "find", "(", ")", ")", ";", "assertTrue", "(", "\"\"", ",", "Pattern", ".", "compile", "(", "\"\"", ")", ".", "matcher", "(", "contents", ")", ".", "find", "(", ")", ")", ";", "assertTrue", "(", "\"\"", ",", "Pattern", ".", "compile", "(", "\"\"", ")", ".", "matcher", "(", "contents", ")", ".", "find", "(", ")", ")", ";", "assertTrue", "(", "\"\"", ",", "Pattern", ".", "compile", "(", "\"\"", ")", ".", "matcher", "(", "contents", ")", ".", "find", "(", ")", ")", ";", "}", "}", "</s>" ]
1,286
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "impl", ";", "import", "java", ".", "util", ".", "HashSet", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "java", ".", "util", ".", "regex", ".", "Pattern", ";", "import", "org", ".", "eclim", ".", "Eclim", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "Jdt", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "*", ";", "public", "class", "ImplCommandTest", "{", "private", "static", "final", "String", "TEST_FILE", "=", "\"\"", ";", "private", "static", "final", "String", "TEST_SUB_FILE", "=", "\"\"", ";", "@", "Test", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "void", "execute", "(", ")", "{", "assertTrue", "(", "\"\"", ",", "Eclim", ".", "projectExists", "(", "Jdt", ".", "TEST_PROJECT", ")", ")", ";", "Map", "<", "String", ",", "Object", ">", "result", "=", "(", "Map", "<", "String", ",", "Object", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"java_impl\"", ",", "\"-p\"", ",", "Jdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "TEST_FILE", ",", "\"-o\"", ",", "\"83\"", ",", "\"-e\"", ",", "\"utf-8\"", "}", ")", ";", "assertEquals", "(", "\"\"", ",", "result", ".", "get", "(", "\"type\"", ")", ")", ";", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", "superTypes", "=", "(", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", ")", "result", ".", "get", "(", "\"superTypes\"", ")", ";", "assertEquals", "(", "4", ",", "superTypes", ".", "size", "(", ")", ")", ";", "assertEquals", "(", "\"java.util\"", ",", "superTypes", ".", "get", "(", "1", ")", ".", "get", "(", "\"packageName\"", ")", ")", ";", "assertEquals", "(", "\"\"", ",", "superTypes", ".", "get", "(", "0", ")", ".", "get", "(", "\"signature\"", ")", ")", ";", "HashSet", "<", "String", ">", "methods", "=", "new", "HashSet", "<", "String", ">", "(", "(", "List", "<", "String", ">", ")", "superTypes", ".", "get", "(", "0", ")", ".", "get", "(", "\"methods\"", ")", ")", ";", "assertTrue", "(", "methods", ".", "contains", "(", "\"\"", ")", ")", ";", "assertTrue", "(", "methods", ".", "contains", "(", "\"\"", ")", ")", ";", "assertTrue", "(", "methods", ".", "contains", "(", "\"\"", ")", ")", ";", "assertEquals", "(", "\"java.util\"", ",", "superTypes", ".", "get", "(", "3", ")", ".", "get", "(", "\"packageName\"", ")", ")", ";", "assertEquals", "(", "\"\"", ",", "superTypes", ".", "get", "(", "3", ")", ".", "get", "(", "\"signature\"", ")", ")", ";", "methods", "=", "new", "HashSet", "<", "String", ">", "(", "(", "List", "<", "String", ">", ")", "superTypes", ".", "get", "(", "3", ")", ".", "get", "(", "\"methods\"", ")", ")", ";", "assertTrue", "(", "methods", ".", "contains", "(", "\"\"", ")", ")", ";", "result", "=", "(", "Map", "<", "String", ",", "Object", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"java_impl\"", ",", "\"-p\"", ",", "Jdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "TEST_FILE", ",", "\"-t\"", ",", "\"\"", ",", "\"-s\"", ",", "\"\"", ",", "\"-m\"", ",", "\"\"", "}", ")", ";", "String", "contents", "=", "Eclim", ".", "fileToString", "(", "Jdt", ".", "TEST_PROJECT", ",", "TEST_FILE", ")", ";", "assertTrue", "(", "\"\"", ",", "Pattern", ".", "compile", "(", "\"\"", ")", ".", "matcher", "(", "contents", ")", ".", "find", "(", ")", ")", ";", "superTypes", "=", "(", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", ")", "result", ".", "get", "(", "\"superTypes\"", ")", ";", "assertEquals", "(", "\"java.util\"", ",", "superTypes", ".", "get", "(", "0", ")", ".", "get", "(", "\"packageName\"", ")", ")", ";", "assertEquals", "(", "\"\"", ",", "superTypes", ".", "get", "(", "0", ")", ".", "get", "(", "\"signature\"", ")", ")", ";", "methods", "=", "new", "HashSet", "<", "String", ">", "(", "(", "List", "<", "String", ">", ")", "superTypes", ".", "get", "(", "0", ")", ".", "get", "(", "\"methods\"", ")", ")", ";", "assertFalse", "(", "methods", ".", "contains", "(", "\"\"", ")", ")", ";", "}", "@", "Test", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "void", "executeSub", "(", ")", "{", "assertTrue", "(", "\"\"", ",", "Eclim", ".", "projectExists", "(", "Jdt", ".", "TEST_PROJECT", ")", ")", ";", "Map", "<", "String", ",", "Object", ">", "result", "=", "(", "Map", "<", "String", ",", "Object", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"java_impl\"", ",", "\"-p\"", ",", "Jdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "TEST_SUB_FILE", ",", "\"-o\"", ",", "\"83\"", ",", "\"-e\"", ",", "\"utf-8\"", "}", ")", ";", "assertEquals", "(", "\"\"", ",", "result", ".", "get", "(", "\"type\"", ")", ")", ";", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", "superTypes", "=", "(", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", ")", "result", ".", "get", "(", "\"superTypes\"", ")", ";", "assertEquals", "(", "\"\"", ",", "superTypes", ".", "get", "(", "0", ")", ".", "get", "(", "\"packageName\"", ")", ")", ";", "assertEquals", "(", "\"\"", ",", "superTypes", ".", "get", "(", "0", ")", ".", "get", "(", "\"signature\"", ")", ")", ";", "HashSet", "<", "String", ">", "methods", "=", "new", "HashSet", "<", "String", ">", "(", "(", "List", "<", "String", ">", ")", "superTypes", ".", "get", "(", "0", ")", ".", "get", "(", "\"methods\"", ")", ")", ";", "assertTrue", "(", "methods", ".", "contains", "(", "\"\"", ")", ")", ";", "result", "=", "(", "Map", "<", "String", ",", "Object", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"java_impl\"", ",", "\"-p\"", ",", "Jdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "TEST_SUB_FILE", ",", "\"-t\"", ",", "\"\"", ",", "\"-s\"", ",", "\"\"", ",", "\"-m\"", ",", "\"\"", "}", ")", ";", "String", "contents", "=", "Eclim", ".", "fileToString", "(", "Jdt", ".", "TEST_PROJECT", ",", "TEST_SUB_FILE", ")", ";", "assertTrue", "(", "\"\"", ",", "Pattern", ".", "compile", "(", "\"\"", ")", ".", "matcher", "(", "contents", ")", ".", "find", "(", ")", ")", ";", "superTypes", "=", "(", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", ")", "result", ".", "get", "(", "\"superTypes\"", ")", ";", "assertEquals", "(", "\"java.util\"", ",", "superTypes", ".", "get", "(", "1", ")", ".", "get", "(", "\"packageName\"", ")", ")", ";", "assertEquals", "(", "\"\"", ",", "superTypes", ".", "get", "(", "0", ")", ".", "get", "(", "\"signature\"", ")", ")", ";", "methods", "=", "new", "HashSet", "<", "String", ">", "(", "(", "List", "<", "String", ">", ")", "superTypes", ".", "get", "(", "0", ")", ".", "get", "(", "\"methods\"", ")", ")", ";", "assertFalse", "(", "methods", ".", "contains", "(", "\"\"", ")", ")", ";", "assertEquals", "(", "\"java.util\"", ",", "superTypes", ".", "get", "(", "3", ")", ".", "get", "(", "\"packageName\"", ")", ")", ";", "assertEquals", "(", "\"\"", ",", "superTypes", ".", "get", "(", "3", ")", ".", "get", "(", "\"signature\"", ")", ")", ";", "methods", "=", "new", "HashSet", "<", "String", ">", "(", "(", "List", "<", "String", ">", ")", "superTypes", ".", "get", "(", "3", ")", ".", "get", "(", "\"methods\"", ")", ")", ";", "assertTrue", "(", "methods", ".", "contains", "(", "\"\"", ")", ")", ";", "result", "=", "(", "Map", "<", "String", ",", "Object", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"java_impl\"", ",", "\"-p\"", ",", "Jdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "TEST_SUB_FILE", ",", "\"-t\"", ",", "\"\"", ",", "\"-s\"", ",", "\"\"", ",", "}", ")", ";", "contents", "=", "Eclim", ".", "fileToString", "(", "Jdt", ".", "TEST_PROJECT", ",", "TEST_SUB_FILE", ")", ";", "assertTrue", "(", "\"\"", ",", "Pattern", ".", "compile", "(", "\"\"", ")", ".", "matcher", "(", "contents", ")", ".", "find", "(", ")", ")", ";", "superTypes", "=", "(", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", ")", "result", ".", "get", "(", "\"superTypes\"", ")", ";", "assertEquals", "(", "3", ",", "superTypes", ".", "size", "(", ")", ")", ";", "}", "}", "</s>" ]
1,287
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "impl", ";", "import", "java", ".", "util", ".", "regex", ".", "Pattern", ";", "import", "org", ".", "eclim", ".", "Eclim", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "Jdt", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "*", ";", "public", "class", "ConstructorCommandTest", "{", "private", "static", "final", "String", "TEST_FILE", "=", "\"\"", ";", "private", "static", "final", "String", "TEST_ENUM_FILE", "=", "\"\"", ";", "private", "static", "final", "String", "TEST_SUPER_FILE", "=", "\"\"", ";", "@", "Test", "public", "void", "emptyConstructor", "(", ")", "{", "assertTrue", "(", "\"\"", ",", "Eclim", ".", "projectExists", "(", "Jdt", ".", "TEST_PROJECT", ")", ")", ";", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"\"", ",", "\"-p\"", ",", "Jdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "TEST_ENUM_FILE", ",", "\"-o\"", ",", "\"1\"", ",", "\"-e\"", ",", "\"utf-8\"", "}", ")", ";", "String", "contents", "=", "Eclim", ".", "fileToString", "(", "Jdt", ".", "TEST_PROJECT", ",", "TEST_ENUM_FILE", ")", ";", "assertTrue", "(", "\"\"", ",", "Pattern", ".", "compile", "(", "\"\"", ",", "Pattern", ".", "MULTILINE", ")", ".", "matcher", "(", "contents", ")", ".", "find", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "argConstructor", "(", ")", "{", "assertTrue", "(", "\"\"", ",", "Eclim", ".", "projectExists", "(", "Jdt", ".", "TEST_PROJECT", ")", ")", ";", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"\"", ",", "\"-p\"", ",", "Jdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "TEST_SUPER_FILE", ",", "\"-o\"", ",", "\"1\"", ",", "\"-e\"", ",", "\"utf-8\"", ",", "\"-r\"", ",", "\"\"", "}", ")", ";", "String", "contents", "=", "Eclim", ".", "fileToString", "(", "Jdt", ".", "TEST_PROJECT", ",", "TEST_SUPER_FILE", ")", ";", "assertTrue", "(", "\"\"", ",", "Pattern", ".", "compile", "(", "\"\"", ")", ".", "matcher", "(", "contents", ")", ".", "find", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "nestedConstructor", "(", ")", "{", "assertTrue", "(", "\"\"", ",", "Eclim", ".", "projectExists", "(", "Jdt", ".", "TEST_PROJECT", ")", ")", ";", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"\"", ",", "\"-p\"", ",", "Jdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "TEST_FILE", ",", "\"-o\"", ",", "\"255\"", ",", "\"-e\"", ",", "\"utf-8\"", "}", ")", ";", "String", "contents", "=", "Eclim", ".", "fileToString", "(", "Jdt", ".", "TEST_PROJECT", ",", "TEST_FILE", ")", ";", "assertTrue", "(", "\"\"", ",", "Pattern", ".", "compile", "(", "\"\"", ")", ".", "matcher", "(", "contents", ")", ".", "find", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "nestedArgConstructor", "(", ")", "{", "assertTrue", "(", "\"\"", ",", "Eclim", ".", "projectExists", "(", "Jdt", ".", "TEST_PROJECT", ")", ")", ";", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"\"", ",", "\"-p\"", ",", "Jdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "TEST_FILE", ",", "\"-o\"", ",", "\"255\"", ",", "\"-e\"", ",", "\"utf-8\"", ",", "\"-r\"", ",", "\"[\\\"subName\\\"]\"", "}", ")", ";", "String", "contents", "=", "Eclim", ".", "fileToString", "(", "Jdt", ".", "TEST_PROJECT", ",", "TEST_FILE", ")", ";", "assertTrue", "(", "\"\"", ",", "Pattern", ".", "compile", "(", "\"\"", ")", ".", "matcher", "(", "contents", ")", ".", "find", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "enumConstructor", "(", ")", "{", "assertTrue", "(", "\"\"", ",", "Eclim", ".", "projectExists", "(", "Jdt", ".", "TEST_PROJECT", ")", ")", ";", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"\"", ",", "\"-p\"", ",", "Jdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "TEST_ENUM_FILE", ",", "\"-o\"", ",", "\"1\"", ",", "\"-e\"", ",", "\"utf-8\"", ",", "\"-r\"", ",", "\"[\\\"number\\\"]\"", "}", ")", ";", "String", "contents", "=", "Eclim", ".", "fileToString", "(", "Jdt", ".", "TEST_PROJECT", ",", "TEST_ENUM_FILE", ")", ";", "assertTrue", "(", "\"\"", ",", "Pattern", ".", "compile", "(", "\"\"", ",", "Pattern", ".", "MULTILINE", ")", ".", "matcher", "(", "contents", ")", ".", "find", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "anonymousConstructor", "(", ")", "{", "assertTrue", "(", "\"\"", ",", "Eclim", ".", "projectExists", "(", "Jdt", ".", "TEST_PROJECT", ")", ")", ";", "String", "result", "=", "(", "String", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"\"", ",", "\"-p\"", ",", "Jdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "TEST_FILE", ",", "\"-o\"", ",", "\"217\"", ",", "\"-e\"", ",", "\"utf-8\"", ",", "\"-r\"", ",", "\"[\\\"number\\\"]\"", "}", ")", ";", "System", ".", "out", ".", "println", "(", "result", ")", ";", "assertEquals", "(", "\"\"", ",", "result", ")", ";", "}", "@", "Test", "public", "void", "superConstructor", "(", ")", "{", "assertTrue", "(", "\"\"", ",", "Eclim", ".", "projectExists", "(", "Jdt", ".", "TEST_PROJECT", ")", ")", ";", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"\"", ",", "\"-p\"", ",", "Jdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "TEST_FILE", ",", "\"-o\"", ",", "\"1\"", ",", "\"-e\"", ",", "\"utf-8\"", ",", "\"-s\"", "}", ")", ";", "String", "contents", "=", "Eclim", ".", "fileToString", "(", "Jdt", ".", "TEST_PROJECT", ",", "TEST_FILE", ")", ";", "assertTrue", "(", "\"\"", ",", "Pattern", ".", "compile", "(", "\"\"", ")", ".", "matcher", "(", "contents", ")", ".", "find", "(", ")", ")", ";", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"\"", ",", "\"-p\"", ",", "Jdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "TEST_FILE", ",", "\"-o\"", ",", "\"1\"", ",", "\"-e\"", ",", "\"utf-8\"", ",", "\"-s\"", ",", "\"-r\"", ",", "\"[\\\"names\\\"]\"", "}", ")", ";", "contents", "=", "Eclim", ".", "fileToString", "(", "Jdt", ".", "TEST_PROJECT", ",", "TEST_FILE", ")", ";", "assertTrue", "(", "\"\"", ",", "Pattern", ".", "compile", "(", "\"\"", ")", ".", "matcher", "(", "contents", ")", ".", "find", "(", ")", ")", ";", "}", "}", "</s>" ]
1,288
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "src", ";", "import", "java", ".", "io", ".", "FileWriter", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang", ".", "StringUtils", ";", "import", "org", ".", "eclim", ".", "Eclim", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "Jdt", ";", "import", "org", ".", "junit", ".", "Before", ";", "import", "org", ".", "junit", ".", "BeforeClass", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "*", ";", "public", "class", "FormatCommandTest", "{", "private", "static", "final", "String", "TEST_FILE", "=", "\"\"", ";", "private", "static", "String", "contents", ";", "@", "BeforeClass", "public", "static", "void", "setupClass", "(", ")", "{", "contents", "=", "Eclim", ".", "fileToString", "(", "Jdt", ".", "TEST_PROJECT", ",", "TEST_FILE", ")", ";", "}", "@", "Before", "public", "void", "setupTest", "(", ")", "throws", "Exception", "{", "String", "path", "=", "Eclim", ".", "resolveFile", "(", "Jdt", ".", "TEST_PROJECT", ",", "TEST_FILE", ")", ";", "FileWriter", "writer", "=", "new", "FileWriter", "(", "path", ")", ";", "writer", ".", "write", "(", "contents", ")", ";", "writer", ".", "close", "(", ")", ";", "}", "@", "Test", "public", "void", "execute", "(", ")", "{", "assertTrue", "(", "\"\"", ",", "Eclim", ".", "projectExists", "(", "Jdt", ".", "TEST_PROJECT", ")", ")", ";", "String", "contents", "=", "Eclim", ".", "fileToString", "(", "Jdt", ".", "TEST_PROJECT", ",", "TEST_FILE", ")", ";", "String", "[", "]", "lines", "=", "StringUtils", ".", "split", "(", "contents", ",", "'\\n'", ")", ";", "assertEquals", "(", "\"\"", ",", "\"\"", ",", "lines", "[", "6", "]", ")", ";", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"java_format\"", ",", "\"-p\"", ",", "Jdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "TEST_FILE", ",", "\"-h\"", ",", "\"109\"", ",", "\"-t\"", ",", "\"146\"", ",", "\"-e\"", ",", "\"utf-8\"", "}", ")", ";", "contents", "=", "Eclim", ".", "fileToString", "(", "Jdt", ".", "TEST_PROJECT", ",", "TEST_FILE", ")", ";", "lines", "=", "StringUtils", ".", "split", "(", "contents", ".", "replace", "(", "\"t\"", ",", "\"", "\"", ")", ",", "'\\n'", ")", ";", "assertEquals", "(", "\"\"", ",", "\"\"", ",", "lines", "[", "6", "]", ")", ";", "contents", "=", "Eclim", ".", "fileToString", "(", "Jdt", ".", "TEST_PROJECT", ",", "TEST_FILE", ")", ";", "lines", "=", "StringUtils", ".", "split", "(", "contents", ",", "'\\n'", ")", ";", "assertEquals", "(", "\"\"", ",", "\"if(true){\"", ",", "lines", "[", "7", "]", ")", ";", "assertEquals", "(", "\"\"", ",", "\"\"", ",", "lines", "[", "8", "]", ")", ";", "assertEquals", "(", "\"\"", ",", "\"}\"", ",", "lines", "[", "9", "]", ")", ";", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"java_format\"", ",", "\"-p\"", ",", "Jdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "TEST_FILE", ",", "\"-h\"", ",", "\"150\"", ",", "\"-t\"", ",", "\"200\"", ",", "\"-e\"", ",", "\"utf-8\"", "}", ")", ";", "contents", "=", "Eclim", ".", "fileToString", "(", "Jdt", ".", "TEST_PROJECT", ",", "TEST_FILE", ")", ";", "lines", "=", "StringUtils", ".", "split", "(", "contents", ".", "replace", "(", "\"t\"", ",", "\"", "\"", ")", ",", "'\\n'", ")", ";", "assertEquals", "(", "\"\"", ",", "\"\"", ",", "lines", "[", "7", "]", ")", ";", "assertEquals", "(", "\"\"", ",", "\"\"", ",", "lines", "[", "8", "]", ")", ";", "assertEquals", "(", "\"\"", ",", "\"", "}\"", ",", "lines", "[", "9", "]", ")", ";", "assertTrue", "(", "\"\"", ",", "Eclim", ".", "projectExists", "(", "Jdt", ".", "TEST_PROJECT", ")", ")", ";", "contents", "=", "Eclim", ".", "fileToString", "(", "Jdt", ".", "TEST_PROJECT", ",", "TEST_FILE", ")", ";", "lines", "=", "StringUtils", ".", "split", "(", "contents", ",", "'\\n'", ")", ";", "assertEquals", "(", "\"\"", ",", "\"public\"", ",", "lines", "[", "2", "]", ")", ";", "assertEquals", "(", "\"\"", ",", "\"\"", ",", "lines", "[", "3", "]", ")", ";", "assertEquals", "(", "\"\"", ",", "\"\"", ",", "lines", "[", "4", "]", ")", ";", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"java_format\"", ",", "\"-p\"", ",", "Jdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "TEST_FILE", ",", "\"-h\"", ",", "\"0\"", ",", "\"-t\"", ",", "\"211\"", ",", "\"-e\"", ",", "\"utf-8\"", "}", ")", ";", "contents", "=", "Eclim", ".", "fileToString", "(", "Jdt", ".", "TEST_PROJECT", ",", "TEST_FILE", ")", ";", "lines", "=", "StringUtils", ".", "split", "(", "contents", ".", "replace", "(", "\"t\"", ",", "\"", "\"", ")", ",", "'\\n'", ")", ";", "assertEquals", "(", "\"\"", ",", "\"\"", ",", "lines", "[", "2", "]", ")", ";", "assertEquals", "(", "\"\"", ",", "\"\"", ",", "lines", "[", "3", "]", ")", ";", "}", "}", "</s>" ]
1,289
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "src", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "io", ".", "FileInputStream", ";", "import", "org", ".", "eclim", ".", "Eclim", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "Jdt", ";", "import", "org", ".", "eclim", ".", "util", ".", "IOUtils", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "*", ";", "public", "class", "ClassPrototypeCommandTest", "{", "@", "Test", "public", "void", "execute", "(", ")", "throws", "Exception", "{", "assertTrue", "(", "\"\"", ",", "Eclim", ".", "projectExists", "(", "Jdt", ".", "TEST_PROJECT", ")", ")", ";", "String", "result", "=", "(", "String", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"\"", ",", "\"-p\"", ",", "Jdt", ".", "TEST_PROJECT", ",", "\"-c\"", ",", "\"\"", "}", ")", ";", "File", "file", "=", "new", "File", "(", "result", ")", ";", "assertTrue", "(", "\"\"", ",", "file", ".", "exists", "(", ")", ")", ";", "FileInputStream", "fin", "=", "null", ";", "try", "{", "fin", "=", "new", "FileInputStream", "(", "file", ")", ";", "String", "contents", "=", "IOUtils", ".", "toString", "(", "fin", ")", ";", "System", ".", "out", ".", "println", "(", "\"Contents:", "n\"", "+", "contents", ")", ";", "assertTrue", "(", "\"\"", ",", "contents", ".", "indexOf", "(", "\"\"", ")", "!=", "-", "1", ")", ";", "assertTrue", "(", "\"\"", ",", "contents", ".", "indexOf", "(", "\"\"", ")", "!=", "-", "1", ")", ";", "assertTrue", "(", "\"\"", ",", "contents", ".", "indexOf", "(", "\"\"", ")", "!=", "-", "1", ")", ";", "assertTrue", "(", "\"\"", ",", "contents", ".", "indexOf", "(", "\"\"", ")", "!=", "-", "1", ")", ";", "}", "finally", "{", "IOUtils", ".", "closeQuietly", "(", "fin", ")", ";", "}", "}", "}", "</s>" ]
1,290
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "src", ";", "import", "org", ".", "eclim", ".", "Eclim", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "Jdt", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "*", ";", "public", "class", "SrcFileExistsCommandTest", "{", "private", "static", "final", "String", "TEST_FILE", "=", "\"\"", ";", "@", "Test", "public", "void", "execute", "(", ")", "{", "assertTrue", "(", "\"\"", ",", "Eclim", ".", "projectExists", "(", "Jdt", ".", "TEST_PROJECT", ")", ")", ";", "String", "result", "=", "(", "String", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"\"", ",", "\"-p\"", ",", "Jdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "TEST_FILE", "}", ")", ";", "assertEquals", "(", "\"\"", ",", "\"true\"", ",", "result", ")", ";", "result", "=", "(", "String", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"\"", ",", "\"-p\"", ",", "Jdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "TEST_FILE", ".", "replace", "(", "'t'", ",", "'o'", ")", "}", ")", ";", "assertEquals", "(", "\"\"", ",", "\"false\"", ",", "result", ")", ";", "}", "}", "</s>" ]
1,291
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "src", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "org", ".", "eclim", ".", "Eclim", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "Jdt", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "*", ";", "public", "class", "SrcUpdateCommandTest", "{", "private", "static", "final", "String", "TEST_FILE", "=", "\"\"", ";", "@", "Test", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "void", "update", "(", ")", "{", "assertTrue", "(", "\"\"", ",", "Eclim", ".", "projectExists", "(", "Jdt", ".", "TEST_PROJECT", ")", ")", ";", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", "results", "=", "(", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"\"", ",", "\"-p\"", ",", "Jdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "TEST_FILE", ",", "\"-v\"", "}", ")", ";", "assertEquals", "(", "\"\"", ",", "3", ",", "results", ".", "size", "(", ")", ")", ";", "String", "file", "=", "Eclim", ".", "resolveFile", "(", "Jdt", ".", "TEST_PROJECT", ",", "TEST_FILE", ")", ";", "Map", "<", "String", ",", "Object", ">", "error", "=", "results", ".", "get", "(", "0", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"filename\"", ")", ",", "file", ")", ";", "assertTrue", "(", "(", "(", "String", ")", "error", ".", "get", "(", "\"message\"", ")", ")", ".", "indexOf", "(", "\"\"", ")", "!=", "-", "1", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"line\"", ")", ",", "10", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"column\"", ")", ",", "5", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"warning\"", ")", ",", "true", ")", ";", "error", "=", "results", ".", "get", "(", "1", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"filename\"", ")", ",", "file", ")", ";", "assertTrue", "(", "(", "(", "String", ")", "error", ".", "get", "(", "\"message\"", ")", ")", ".", "indexOf", "(", "\"\"", ")", "!=", "-", "1", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"line\"", ")", ",", "10", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"column\"", ")", ",", "21", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"warning\"", ")", ",", "true", ")", ";", "error", "=", "results", ".", "get", "(", "2", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"filename\"", ")", ",", "file", ")", ";", "assertTrue", "(", "(", "(", "String", ")", "error", ".", "get", "(", "\"message\"", ")", ")", ".", "indexOf", "(", "\"\"", ")", "!=", "-", "1", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"line\"", ")", ",", "11", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"column\"", ")", ",", "10", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"warning\"", ")", ",", "false", ")", ";", "}", "}", "</s>" ]
1,292
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "src", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "org", ".", "eclim", ".", "Eclim", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "Jdt", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "*", ";", "public", "class", "CheckstyleCommandTest", "{", "private", "static", "final", "String", "TEST_FILE", "=", "\"\"", ";", "@", "Test", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "void", "execute", "(", ")", "{", "assertTrue", "(", "\"\"", ",", "Eclim", ".", "projectExists", "(", "Jdt", ".", "TEST_PROJECT", ")", ")", ";", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", "results", "=", "(", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"\"", ",", "\"-p\"", ",", "Jdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "TEST_FILE", ",", "}", ")", ";", "assertEquals", "(", "\"\"", ",", "4", ",", "results", ".", "size", "(", ")", ")", ";", "String", "file", "=", "Eclim", ".", "resolveFile", "(", "Jdt", ".", "TEST_PROJECT", ",", "TEST_FILE", ")", ";", "Map", "<", "String", ",", "Object", ">", "error", "=", "results", ".", "get", "(", "0", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"filename\"", ")", ",", "file", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"message\"", ")", ",", "\"\"", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"line\"", ")", ",", "5", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"column\"", ")", ",", "19", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"warning\"", ")", ",", "true", ")", ";", "error", "=", "results", ".", "get", "(", "1", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"filename\"", ")", ",", "file", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"message\"", ")", ",", "\"\"", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"line\"", ")", ",", "6", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"column\"", ")", ",", "12", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"warning\"", ")", ",", "true", ")", ";", "error", "=", "results", ".", "get", "(", "2", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"filename\"", ")", ",", "file", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"message\"", ")", ",", "\"\"", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"line\"", ")", ",", "6", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"column\"", ")", ",", "26", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"warning\"", ")", ",", "true", ")", ";", "error", "=", "results", ".", "get", "(", "3", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"filename\"", ")", ",", "file", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"message\"", ")", ",", "\"\"", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"line\"", ")", ",", "9", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"column\"", ")", ",", "33", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"warning\"", ")", ",", "true", ")", ";", "}", "}", "</s>" ]
1,293
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "src", ";", "import", "org", ".", "eclim", ".", "Eclim", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "Jdt", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "*", ";", "public", "class", "SrcFindCommandTest", "{", "private", "static", "final", "String", "TEST_FILE", "=", "\"\"", ";", "@", "Test", "public", "void", "execute", "(", ")", "{", "assertTrue", "(", "\"\"", ",", "Eclim", ".", "projectExists", "(", "Jdt", ".", "TEST_PROJECT", ")", ")", ";", "String", "result", "=", "(", "String", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"\"", ",", "\"-p\"", ",", "Jdt", ".", "TEST_PROJECT", ",", "\"-c\"", ",", "\"\"", "}", ")", ";", "assertEquals", "(", "\"\"", ",", "Eclim", ".", "resolveFile", "(", "Jdt", ".", "TEST_PROJECT", ",", "TEST_FILE", ")", ",", "result", ")", ";", "result", "=", "(", "String", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"\"", ",", "\"-p\"", ",", "Jdt", ".", "TEST_PROJECT", ",", "\"-c\"", ",", "\"\"", "}", ")", ";", "assertEquals", "(", "\"\"", ",", "\"\"", ",", "result", ")", ";", "}", "}", "</s>" ]
1,294
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "include", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "java", ".", "util", ".", "regex", ".", "Pattern", ";", "import", "org", ".", "eclim", ".", "Eclim", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "Jdt", ";", "import", "org", ".", "junit", ".", "BeforeClass", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "*", ";", "public", "class", "ImportCommandTest", "{", "private", "static", "final", "String", "TEST_FILE", "=", "\"\"", ";", "@", "BeforeClass", "public", "static", "void", "setUp", "(", ")", "{", "Eclim", ".", "setProjectSetting", "(", "Jdt", ".", "TEST_PROJECT", ",", "\"\"", ",", "\"-1\"", ")", ";", "}", "@", "Test", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "void", "execute", "(", ")", "{", "assertTrue", "(", "\"\"", ",", "Eclim", ".", "projectExists", "(", "Jdt", ".", "TEST_PROJECT", ")", ")", ";", "Pattern", "listImport", "=", "Pattern", ".", "compile", "(", "\"\"", ")", ";", "String", "file", "=", "Eclim", ".", "fileToString", "(", "Jdt", ".", "TEST_PROJECT", ",", "TEST_FILE", ")", ";", "assertFalse", "(", "listImport", ".", "matcher", "(", "file", ")", ".", "find", "(", ")", ")", ";", "List", "<", "String", ">", "results", "=", "(", "List", "<", "String", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"java_import\"", ",", "\"-p\"", ",", "Jdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "TEST_FILE", ",", "\"-o\"", ",", "\"72\"", ",", "\"-e\"", ",", "\"utf-8\"", ",", "}", ")", ";", "assertEquals", "(", "2", ",", "results", ".", "size", "(", ")", ")", ";", "assertEquals", "(", "\"\"", ",", "results", ".", "get", "(", "0", ")", ")", ";", "assertEquals", "(", "\"\"", ",", "results", ".", "get", "(", "1", ")", ")", ";", "file", "=", "Eclim", ".", "fileToString", "(", "Jdt", ".", "TEST_PROJECT", ",", "TEST_FILE", ")", ";", "assertFalse", "(", "listImport", ".", "matcher", "(", "file", ")", ".", "find", "(", ")", ")", ";", "Map", "<", "String", ",", "Object", ">", "position", "=", "(", "Map", "<", "String", ",", "Object", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"java_import\"", ",", "\"-p\"", ",", "Jdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "TEST_FILE", ",", "\"-o\"", ",", "\"72\"", ",", "\"-e\"", ",", "\"utf-8\"", ",", "\"-t\"", ",", "\"\"", ",", "}", ")", ";", "file", "=", "Eclim", ".", "fileToString", "(", "Jdt", ".", "TEST_PROJECT", ",", "TEST_FILE", ")", ";", "assertTrue", "(", "listImport", ".", "matcher", "(", "file", ")", ".", "find", "(", ")", ")", ";", "assertEquals", "(", "96", ",", "position", ".", "get", "(", "\"offset\"", ")", ")", ";", "assertEquals", "(", "7", ",", "position", ".", "get", "(", "\"line\"", ")", ")", ";", "assertEquals", "(", "14", ",", "position", ".", "get", "(", "\"column\"", ")", ")", ";", "position", "=", "(", "Map", "<", "String", ",", "Object", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"java_import\"", ",", "\"-p\"", ",", "Jdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "TEST_FILE", ",", "\"-o\"", ",", "\"109\"", ",", "\"-e\"", ",", "\"utf-8\"", ",", "}", ")", ";", "Pattern", "arrayListImport", "=", "Pattern", ".", "compile", "(", "\"\"", ")", ";", "file", "=", "Eclim", ".", "fileToString", "(", "Jdt", ".", "TEST_PROJECT", ",", "TEST_FILE", ")", ";", "assertTrue", "(", "arrayListImport", ".", "matcher", "(", "file", ")", ".", "find", "(", ")", ")", ";", "assertEquals", "(", "137", ",", "position", ".", "get", "(", "\"offset\"", ")", ")", ";", "assertEquals", "(", "8", ",", "position", ".", "get", "(", "\"line\"", ")", ")", ";", "assertEquals", "(", "27", ",", "position", ".", "get", "(", "\"column\"", ")", ")", ";", "position", "=", "(", "Map", "<", "String", ",", "Object", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"java_import\"", ",", "\"-p\"", ",", "Jdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "TEST_FILE", ",", "\"-o\"", ",", "\"163\"", ",", "\"-e\"", ",", "\"utf-8\"", ",", "}", ")", ";", "Pattern", "patternImport", "=", "Pattern", ".", "compile", "(", "\"\"", ")", ";", "file", "=", "Eclim", ".", "fileToString", "(", "Jdt", ".", "TEST_PROJECT", ",", "TEST_FILE", ")", ";", "assertTrue", "(", "patternImport", ".", "matcher", "(", "file", ")", ".", "find", "(", ")", ")", ";", "assertEquals", "(", "196", ",", "position", ".", "get", "(", "\"offset\"", ")", ")", ";", "assertEquals", "(", "11", ",", "position", ".", "get", "(", "\"line\"", ")", ")", ";", "assertEquals", "(", "14", ",", "position", ".", "get", "(", "\"column\"", ")", ")", ";", "position", "=", "(", "Map", "<", "String", ",", "Object", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"java_import\"", ",", "\"-p\"", ",", "Jdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "TEST_FILE", ",", "\"-o\"", ",", "\"220\"", ",", "\"-e\"", ",", "\"utf-8\"", ",", "}", ")", ";", "Pattern", "fileImport", "=", "Pattern", ".", "compile", "(", "\"\"", ")", ";", "file", "=", "Eclim", ".", "fileToString", "(", "Jdt", ".", "TEST_PROJECT", ",", "TEST_FILE", ")", ";", "assertTrue", "(", "fileImport", ".", "matcher", "(", "file", ")", ".", "find", "(", ")", ")", ";", "assertEquals", "(", "242", ",", "position", ".", "get", "(", "\"offset\"", ")", ")", ";", "assertEquals", "(", "14", ",", "position", ".", "get", "(", "\"line\"", ")", ")", ";", "assertEquals", "(", "11", ",", "position", ".", "get", "(", "\"column\"", ")", ")", ";", "}", "}", "</s>" ]
1,295
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "include", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "java", ".", "util", ".", "regex", ".", "Pattern", ";", "import", "org", ".", "eclim", ".", "Eclim", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "Jdt", ";", "import", "org", ".", "junit", ".", "BeforeClass", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "*", ";", "public", "class", "ImportOrganizeCommandTest", "{", "private", "static", "final", "String", "TEST_FILE", "=", "\"\"", ";", "@", "BeforeClass", "public", "static", "void", "setUp", "(", ")", "{", "Eclim", ".", "setProjectSetting", "(", "Jdt", ".", "TEST_PROJECT", ",", "\"\"", ",", "\"-1\"", ")", ";", "}", "@", "Test", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "void", "execute", "(", ")", "{", "assertTrue", "(", "\"\"", ",", "Eclim", ".", "projectExists", "(", "Jdt", ".", "TEST_PROJECT", ")", ")", ";", "Pattern", "listImport", "=", "Pattern", ".", "compile", "(", "\"\"", ")", ";", "String", "file", "=", "Eclim", ".", "fileToString", "(", "Jdt", ".", "TEST_PROJECT", ",", "TEST_FILE", ")", ";", "assertFalse", "(", "listImport", ".", "matcher", "(", "file", ")", ".", "find", "(", ")", ")", ";", "List", "<", "List", "<", "String", ">", ">", "results", "=", "(", "List", "<", "List", "<", "String", ">", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"\"", ",", "\"-p\"", ",", "Jdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "TEST_FILE", ",", "\"-o\"", ",", "\"185\"", ",", "\"-e\"", ",", "\"utf-8\"", ",", "}", ")", ";", "assertEquals", "(", "2", ",", "results", ".", "size", "(", ")", ")", ";", "List", "<", "String", ">", "entries", "=", "results", ".", "get", "(", "0", ")", ";", "assertEquals", "(", "\"\"", ",", "entries", ".", "get", "(", "0", ")", ")", ";", "assertEquals", "(", "\"\"", ",", "entries", ".", "get", "(", "1", ")", ")", ";", "assertEquals", "(", "\"\"", ",", "entries", ".", "get", "(", "2", ")", ")", ";", "List", "<", "String", ">", "lists", "=", "results", ".", "get", "(", "1", ")", ";", "assertEquals", "(", "\"\"", ",", "lists", ".", "get", "(", "0", ")", ")", ";", "assertEquals", "(", "\"\"", ",", "lists", ".", "get", "(", "1", ")", ")", ";", "file", "=", "Eclim", ".", "fileToString", "(", "Jdt", ".", "TEST_PROJECT", ",", "TEST_FILE", ")", ";", "assertFalse", "(", "listImport", ".", "matcher", "(", "file", ")", ".", "find", "(", ")", ")", ";", "Map", "<", "String", ",", "Object", ">", "position", "=", "(", "Map", "<", "String", ",", "Object", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"\"", ",", "\"-p\"", ",", "Jdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "TEST_FILE", ",", "\"-o\"", ",", "\"185\"", ",", "\"-e\"", ",", "\"utf-8\"", ",", "\"-t\"", ",", "\"\"", ",", "}", ")", ";", "file", "=", "Eclim", ".", "fileToString", "(", "Jdt", ".", "TEST_PROJECT", ",", "TEST_FILE", ")", ";", "assertTrue", "(", "listImport", ".", "matcher", "(", "file", ")", ".", "find", "(", ")", ")", ";", "assertEquals", "(", "238", ",", "position", ".", "get", "(", "\"offset\"", ")", ")", ";", "assertEquals", "(", "13", ",", "position", ".", "get", "(", "\"line\"", ")", ")", ";", "assertEquals", "(", "16", ",", "position", ".", "get", "(", "\"column\"", ")", ")", ";", "}", "}", "</s>" ]
1,296
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "refactoring", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "org", ".", "eclim", ".", "Eclim", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "Jdt", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "*", ";", "public", "class", "MoveCommandTest", "{", "private", "static", "final", "String", "TEST_FILE", "=", "\"\"", ";", "@", "Test", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "void", "execute", "(", ")", "throws", "Exception", "{", "String", "p", "=", "Eclim", ".", "resolveFile", "(", "Jdt", ".", "TEST_PROJECT", ",", "\"\"", ")", ";", "Map", "<", "String", ",", "Object", ">", "result", "=", "(", "Map", "<", "String", ",", "Object", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"\"", ",", "\"-p\"", ",", "Jdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "TEST_FILE", ",", "\"-n\"", ",", "\"\"", "}", ")", ";", "assertTrue", "(", "result", ".", "containsKey", "(", "\"errors\"", ")", ")", ";", "List", "<", "String", ">", "errors", "=", "(", "List", "<", "String", ">", ")", "result", ".", "get", "(", "\"errors\"", ")", ";", "assertEquals", "(", "1", ",", "errors", ".", "size", "(", ")", ")", ";", "assertEquals", "(", "\"\"", ",", "errors", ".", "get", "(", "0", ")", ")", ";", "List", "<", "Map", "<", "String", ",", "String", ">", ">", "results", "=", "(", "List", "<", "Map", "<", "String", ",", "String", ">", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"\"", ",", "\"-p\"", ",", "Jdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "TEST_FILE", ",", "\"-n\"", ",", "\"\"", "}", ")", ";", "assertEquals", "(", "p", "+", "\"\"", ",", "results", ".", "get", "(", "0", ")", ".", "get", "(", "\"file\"", ")", ")", ";", "assertEquals", "(", "p", "+", "\"\"", ",", "results", ".", "get", "(", "1", ")", ".", "get", "(", "\"from\"", ")", ")", ";", "assertEquals", "(", "p", "+", "\"\"", ",", "results", ".", "get", "(", "1", ")", ".", "get", "(", "\"to\"", ")", ")", ";", "results", "=", "(", "List", "<", "Map", "<", "String", ",", "String", ">", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"\"", "}", ")", ";", "assertEquals", "(", "p", "+", "\"\"", ",", "results", ".", "get", "(", "0", ")", ".", "get", "(", "\"from\"", ")", ")", ";", "assertEquals", "(", "p", "+", "\"\"", ",", "results", ".", "get", "(", "0", ")", ".", "get", "(", "\"to\"", ")", ")", ";", "assertEquals", "(", "p", "+", "\"\"", ",", "results", ".", "get", "(", "1", ")", ".", "get", "(", "\"file\"", ")", ")", ";", "}", "}", "</s>" ]
1,297
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "refactoring", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "org", ".", "eclim", ".", "Eclim", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "Jdt", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "*", ";", "public", "class", "RenameCommandTest", "{", "@", "Test", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "void", "executeRenameField", "(", ")", "throws", "Exception", "{", "String", "p", "=", "Eclim", ".", "resolveFile", "(", "Jdt", ".", "TEST_PROJECT", ",", "\"\"", ")", ";", "String", "tn1Contents", "=", "Eclim", ".", "fileToString", "(", "Jdt", ".", "TEST_PROJECT", ",", "\"\"", ")", ";", "assertTrue", "(", "\"\"", ",", "tn1Contents", ".", "indexOf", "(", "\"\"", ")", ">", "0", ")", ";", "String", "tn2Contents", "=", "Eclim", ".", "fileToString", "(", "Jdt", ".", "TEST_PROJECT", ",", "\"\"", ")", ";", "assertTrue", "(", "\"\"", ",", "tn2Contents", ".", "indexOf", "(", "\"\"", ")", ">", "0", ")", ";", "assertTrue", "(", "\"\"", ",", "tn2Contents", ".", "indexOf", "(", "\"\"", ")", ">", "0", ")", ";", "Map", "<", "String", ",", "Object", ">", "preview", "=", "(", "Map", "<", "String", ",", "Object", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"\"", ",", "\"-p\"", ",", "Jdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "\"\"", ",", "\"-n\"", ",", "\"BAR\"", ",", "\"-o\"", ",", "\"98\"", ",", "\"-l\"", ",", "\"3\"", ",", "\"-e\"", ",", "\"utf-8\"", ",", "\"-v\"", ",", "}", ")", ";", "assertEquals", "(", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", ",", "preview", ".", "get", "(", "\"apply\"", ")", ")", ";", "List", "<", "Map", "<", "String", ",", "String", ">", ">", "changes", "=", "(", "List", "<", "Map", "<", "String", ",", "String", ">", ">", ")", "preview", ".", "get", "(", "\"changes\"", ")", ";", "assertEquals", "(", "2", ",", "changes", ".", "size", "(", ")", ")", ";", "assertEquals", "(", "\"diff\"", ",", "changes", ".", "get", "(", "0", ")", ".", "get", "(", "\"type\"", ")", ")", ";", "assertEquals", "(", "p", "+", "\"\"", ",", "changes", ".", "get", "(", "0", ")", ".", "get", "(", "\"file\"", ")", ")", ";", "assertEquals", "(", "\"diff\"", ",", "changes", ".", "get", "(", "1", ")", ".", "get", "(", "\"type\"", ")", ")", ";", "assertEquals", "(", "p", "+", "\"\"", ",", "changes", ".", "get", "(", "1", ")", ".", "get", "(", "\"file\"", ")", ")", ";", "String", "diff", "=", "(", "String", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"\"", ",", "\"-p\"", ",", "Jdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "\"\"", ",", "\"-n\"", ",", "\"BAR\"", ",", "\"-o\"", ",", "\"98\"", ",", "\"-l\"", ",", "\"3\"", ",", "\"-e\"", ",", "\"utf-8\"", ",", "\"-v\"", ",", "\"-d\"", ",", "Eclim", ".", "resolveFile", "(", "Jdt", ".", "TEST_PROJECT", ",", "\"\"", ")", ",", "}", ")", ";", "assertEquals", "(", "\"\"", ",", "tn2Contents", ".", "replaceAll", "(", "\"FOO\"", ",", "\"BAR\"", ")", ",", "diff", ")", ";", "List", "<", "Map", "<", "String", ",", "String", ">", ">", "result", "=", "(", "List", "<", "Map", "<", "String", ",", "String", ">", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"\"", ",", "\"-p\"", ",", "Jdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "\"\"", ",", "\"-n\"", ",", "\"BAR\"", ",", "\"-o\"", ",", "\"98\"", ",", "\"-l\"", ",", "\"3\"", ",", "\"-e\"", ",", "\"utf-8\"", ",", "}", ")", ";", "assertEquals", "(", "p", "+", "\"\"", ",", "result", ".", "get", "(", "0", ")", ".", "get", "(", "\"file\"", ")", ")", ";", "assertEquals", "(", "p", "+", "\"\"", ",", "result", ".", "get", "(", "1", ")", ".", "get", "(", "\"file\"", ")", ")", ";", "String", "tn1NewContents", "=", "Eclim", ".", "fileToString", "(", "Jdt", ".", "TEST_PROJECT", ",", "\"\"", ")", ";", "assertEquals", "(", "\"\"", ",", "tn1Contents", ".", "replaceAll", "(", "\"FOO\"", ",", "\"BAR\"", ")", ",", "tn1NewContents", ")", ";", "String", "tn2NewContents", "=", "Eclim", ".", "fileToString", "(", "Jdt", ".", "TEST_PROJECT", ",", "\"\"", ")", ";", "assertEquals", "(", "\"\"", ",", "tn2Contents", ".", "replaceAll", "(", "\"FOO\"", ",", "\"BAR\"", ")", ",", "tn2NewContents", ")", ";", "}", "@", "Test", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "void", "executeRenameMethod", "(", ")", "throws", "Exception", "{", "String", "p", "=", "Eclim", ".", "resolveFile", "(", "Jdt", ".", "TEST_PROJECT", ",", "\"\"", ")", ";", "String", "tn1Contents", "=", "Eclim", ".", "fileToString", "(", "Jdt", ".", "TEST_PROJECT", ",", "\"\"", ")", ";", "assertTrue", "(", "\"\"", ",", "tn1Contents", ".", "indexOf", "(", "\"\"", ")", ">", "0", ")", ";", "String", "tn2Contents", "=", "Eclim", ".", "fileToString", "(", "Jdt", ".", "TEST_PROJECT", ",", "\"\"", ")", ";", "assertTrue", "(", "\"\"", ",", "tn2Contents", ".", "indexOf", "(", "\"\"", ")", ">", "0", ")", ";", "Map", "<", "String", ",", "Object", ">", "preview", "=", "(", "Map", "<", "String", ",", "Object", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"\"", ",", "\"-p\"", ",", "Jdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "\"\"", ",", "\"-n\"", ",", "\"testRename\"", ",", "\"-o\"", ",", "\"310\"", ",", "\"-l\"", ",", "\"10\"", ",", "\"-e\"", ",", "\"utf-8\"", ",", "\"-v\"", ",", "}", ")", ";", "assertEquals", "(", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", ",", "preview", ".", "get", "(", "\"apply\"", ")", ")", ";", "List", "<", "Map", "<", "String", ",", "String", ">", ">", "changes", "=", "(", "List", "<", "Map", "<", "String", ",", "String", ">", ">", ")", "preview", ".", "get", "(", "\"changes\"", ")", ";", "assertEquals", "(", "2", ",", "changes", ".", "size", "(", ")", ")", ";", "assertEquals", "(", "\"diff\"", ",", "changes", ".", "get", "(", "0", ")", ".", "get", "(", "\"type\"", ")", ")", ";", "assertEquals", "(", "p", "+", "\"\"", ",", "changes", ".", "get", "(", "0", ")", ".", "get", "(", "\"file\"", ")", ")", ";", "assertEquals", "(", "\"diff\"", ",", "changes", ".", "get", "(", "1", ")", ".", "get", "(", "\"type\"", ")", ")", ";", "assertEquals", "(", "p", "+", "\"\"", ",", "changes", ".", "get", "(", "1", ")", ".", "get", "(", "\"file\"", ")", ")", ";", "String", "diff", "=", "(", "String", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"\"", ",", "\"-p\"", ",", "Jdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "\"\"", ",", "\"-n\"", ",", "\"testRename\"", ",", "\"-o\"", ",", "\"310\"", ",", "\"-l\"", ",", "\"10\"", ",", "\"-e\"", ",", "\"utf-8\"", ",", "\"-v\"", ",", "\"-d\"", ",", "Eclim", ".", "resolveFile", "(", "Jdt", ".", "TEST_PROJECT", ",", "\"\"", ")", ",", "}", ")", ";", "assertEquals", "(", "\"\"", ",", "tn1Contents", ".", "replaceAll", "(", "\"testMethod\"", ",", "\"testRename\"", ")", ",", "diff", ")", ";", "List", "<", "Map", "<", "String", ",", "String", ">", ">", "result", "=", "(", "List", "<", "Map", "<", "String", ",", "String", ">", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"\"", ",", "\"-p\"", ",", "Jdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "\"\"", ",", "\"-n\"", ",", "\"testRename\"", ",", "\"-o\"", ",", "\"310\"", ",", "\"-l\"", ",", "\"10\"", ",", "\"-e\"", ",", "\"utf-8\"", ",", "}", ")", ";", "assertEquals", "(", "p", "+", "\"\"", ",", "result", ".", "get", "(", "0", ")", ".", "get", "(", "\"file\"", ")", ")", ";", "assertEquals", "(", "p", "+", "\"\"", ",", "result", ".", "get", "(", "1", ")", ".", "get", "(", "\"file\"", ")", ")", ";", "String", "tn1NewContents", "=", "Eclim", ".", "fileToString", "(", "Jdt", ".", "TEST_PROJECT", ",", "\"\"", ")", ";", "assertEquals", "(", "\"\"", ",", "tn1Contents", ".", "replaceAll", "(", "\"testMethod\"", ",", "\"testRename\"", ")", ",", "tn1NewContents", ")", ";", "String", "tn2NewContents", "=", "Eclim", ".", "fileToString", "(", "Jdt", ".", "TEST_PROJECT", ",", "\"\"", ")", ";", "assertEquals", "(", "\"\"", ",", "tn2Contents", ".", "replaceAll", "(", "\"testMethod\"", ",", "\"testRename\"", ")", ",", "tn2NewContents", ")", ";", "}", "@", "Test", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "void", "executeRenameType", "(", ")", "throws", "Exception", "{", "String", "p", "=", "Eclim", ".", "resolveFile", "(", "Jdt", ".", "TEST_PROJECT", ",", "\"\"", ")", ";", "String", "tn1Contents", "=", "Eclim", ".", "fileToString", "(", "Jdt", ".", "TEST_PROJECT", ",", "\"\"", ")", ";", "assertTrue", "(", "\"\"", ",", "tn1Contents", ".", "indexOf", "(", "\"\"", ")", ">", "0", ")", ";", "String", "tn2Contents", "=", "Eclim", ".", "fileToString", "(", "Jdt", ".", "TEST_PROJECT", ",", "\"\"", ")", ";", "assertTrue", "(", "\"\"", ",", "tn2Contents", ".", "indexOf", "(", "\"\"", ")", ">", "0", ")", ";", "Map", "<", "String", ",", "Object", ">", "preview", "=", "(", "Map", "<", "String", ",", "Object", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"\"", ",", "\"-p\"", ",", "Jdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "\"\"", ",", "\"-n\"", ",", "\"TestR1\"", ",", "\"-o\"", ",", "\"60\"", ",", "\"-l\"", ",", "\"6\"", ",", "\"-e\"", ",", "\"utf-8\"", ",", "\"-v\"", ",", "}", ")", ";", "assertEquals", "(", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", ",", "preview", ".", "get", "(", "\"apply\"", ")", ")", ";", "List", "<", "Map", "<", "String", ",", "String", ">", ">", "changes", "=", "(", "List", "<", "Map", "<", "String", ",", "String", ">", ">", ")", "preview", ".", "get", "(", "\"changes\"", ")", ";", "assertEquals", "(", "2", ",", "changes", ".", "size", "(", ")", ")", ";", "assertEquals", "(", "\"diff\"", ",", "changes", ".", "get", "(", "0", ")", ".", "get", "(", "\"type\"", ")", ")", ";", "assertEquals", "(", "p", "+", "\"\"", ",", "changes", ".", "get", "(", "0", ")", ".", "get", "(", "\"file\"", ")", ")", ";", "assertEquals", "(", "\"other\"", ",", "changes", ".", "get", "(", "1", ")", ".", "get", "(", "\"type\"", ")", ")", ";", "assertEquals", "(", "\"\"", ",", "changes", ".", "get", "(", "1", ")", ".", "get", "(", "\"message\"", ")", ")", ";", "String", "diff", "=", "(", "String", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"\"", ",", "\"-p\"", ",", "Jdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "\"\"", ",", "\"-n\"", ",", "\"TestR1\"", ",", "\"-o\"", ",", "\"60\"", ",", "\"-l\"", ",", "\"6\"", ",", "\"-e\"", ",", "\"utf-8\"", ",", "\"-v\"", ",", "\"-d\"", ",", "Eclim", ".", "resolveFile", "(", "Jdt", ".", "TEST_PROJECT", ",", "\"\"", ")", ",", "}", ")", ";", "assertEquals", "(", "\"\"", ",", "tn2Contents", ".", "replaceAll", "(", "\"TestN1\"", ",", "\"TestR1\"", ")", ",", "diff", ")", ";", "List", "<", "Map", "<", "String", ",", "String", ">", ">", "result", "=", "(", "List", "<", "Map", "<", "String", ",", "String", ">", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"\"", ",", "\"-p\"", ",", "Jdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "\"\"", ",", "\"-n\"", ",", "\"TestR1\"", ",", "\"-o\"", ",", "\"60\"", ",", "\"-l\"", ",", "\"6\"", ",", "\"-e\"", ",", "\"utf-8\"", ",", "}", ")", ";", "assertEquals", "(", "p", "+", "\"\"", ",", "result", ".", "get", "(", "0", ")", ".", "get", "(", "\"from\"", ")", ")", ";", "assertEquals", "(", "p", "+", "\"\"", ",", "result", ".", "get", "(", "0", ")", ".", "get", "(", "\"to\"", ")", ")", ";", "assertEquals", "(", "p", "+", "\"\"", ",", "result", ".", "get", "(", "1", ")", ".", "get", "(", "\"file\"", ")", ")", ";", "assertFalse", "(", "new", "File", "(", "Eclim", ".", "resolveFile", "(", "Jdt", ".", "TEST_PROJECT", ",", "\"\"", ")", ")", ".", "exists", "(", ")", ")", ";", "String", "tn1NewContents", "=", "Eclim", ".", "fileToString", "(", "Jdt", ".", "TEST_PROJECT", ",", "\"\"", ")", ";", "assertEquals", "(", "\"\"", ",", "tn1Contents", ".", "replaceAll", "(", "\"TestN1\"", ",", "\"TestR1\"", ")", ",", "tn1NewContents", ")", ";", "String", "tn2NewContents", "=", "Eclim", ".", "fileToString", "(", "Jdt", ".", "TEST_PROJECT", ",", "\"\"", ")", ";", "assertEquals", "(", "\"\"", ",", "tn2Contents", ".", "replaceAll", "(", "\"TestN1\"", ",", "\"TestR1\"", ")", ",", "tn2NewContents", ")", ";", "}", "@", "Test", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "void", "executeRenamePackage", "(", ")", "throws", "Exception", "{", "String", "p", "=", "Eclim", ".", "resolveFile", "(", "Jdt", ".", "TEST_PROJECT", ",", "\"\"", ")", ";", "String", "tr1Contents", "=", "Eclim", ".", "fileToString", "(", "Jdt", ".", "TEST_PROJECT", ",", "\"\"", ")", ";", "assertTrue", "(", "\"\"", ",", "tr1Contents", ".", "indexOf", "(", "\"\"", ")", "!=", "-", "1", ")", ";", "String", "tn2Contents", "=", "Eclim", ".", "fileToString", "(", "Jdt", ".", "TEST_PROJECT", ",", "\"\"", ")", ";", "assertTrue", "(", "\"\"", ",", "tn2Contents", ".", "indexOf", "(", "\"\"", ")", "!=", "-", "1", ")", ";", "Map", "<", "String", ",", "Object", ">", "preview", "=", "(", "Map", "<", "String", ",", "Object", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"\"", ",", "\"-p\"", ",", "Jdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "\"\"", ",", "\"-n\"", ",", "\"\"", ",", "\"-o\"", ",", "\"42\"", ",", "\"-l\"", ",", "\"2\"", ",", "\"-e\"", ",", "\"utf-8\"", ",", "\"-v\"", ",", "}", ")", ";", "assertEquals", "(", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", ",", "preview", ".", "get", "(", "\"apply\"", ")", ")", ";", "List", "<", "Map", "<", "String", ",", "String", ">", ">", "changes", "=", "(", "List", "<", "Map", "<", "String", ",", "String", ">", ">", ")", "preview", ".", "get", "(", "\"changes\"", ")", ";", "assertEquals", "(", "2", ",", "changes", ".", "size", "(", ")", ")", ";", "assertEquals", "(", "\"diff\"", ",", "changes", ".", "get", "(", "0", ")", ".", "get", "(", "\"type\"", ")", ")", ";", "assertEquals", "(", "p", "+", "\"\"", ",", "changes", ".", "get", "(", "0", ")", ".", "get", "(", "\"file\"", ")", ")", ";", "assertEquals", "(", "\"other\"", ",", "changes", ".", "get", "(", "1", ")", ".", "get", "(", "\"type\"", ")", ")", ";", "assertEquals", "(", "\"\"", "+", "\"\"", ",", "changes", ".", "get", "(", "1", ")", ".", "get", "(", "\"message\"", ")", ")", ";", "String", "diff", "=", "(", "String", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"\"", ",", "\"-p\"", ",", "Jdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "\"\"", ",", "\"-n\"", ",", "\"\"", ",", "\"-o\"", ",", "\"42\"", ",", "\"-l\"", ",", "\"2\"", ",", "\"-e\"", ",", "\"utf-8\"", ",", "\"-v\"", ",", "\"-d\"", ",", "Eclim", ".", "resolveFile", "(", "Jdt", ".", "TEST_PROJECT", ",", "\"\"", ")", ",", "}", ")", ";", "assertEquals", "(", "\"\"", ",", "tn2Contents", ".", "replaceAll", "(", "\"n1\\\\.TestR1\"", ",", "\"r1.TestR1\"", ")", ",", "diff", ")", ";", "List", "<", "Map", "<", "String", ",", "String", ">", ">", "result", "=", "(", "List", "<", "Map", "<", "String", ",", "String", ">", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"\"", ",", "\"-p\"", ",", "Jdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "\"\"", ",", "\"-n\"", ",", "\"\"", ",", "\"-o\"", ",", "\"42\"", ",", "\"-l\"", ",", "\"2\"", ",", "\"-e\"", ",", "\"utf-8\"", ",", "}", ")", ";", "assertEquals", "(", "p", "+", "\"\"", ",", "result", ".", "get", "(", "0", ")", ".", "get", "(", "\"from\"", ")", ")", ";", "assertEquals", "(", "p", "+", "\"\"", ",", "result", ".", "get", "(", "0", ")", ".", "get", "(", "\"to\"", ")", ")", ";", "assertEquals", "(", "p", "+", "\"\"", ",", "result", ".", "get", "(", "1", ")", ".", "get", "(", "\"from\"", ")", ")", ";", "assertEquals", "(", "p", "+", "\"\"", ",", "result", ".", "get", "(", "1", ")", ".", "get", "(", "\"to\"", ")", ")", ";", "assertEquals", "(", "p", "+", "\"\"", ",", "result", ".", "get", "(", "2", ")", ".", "get", "(", "\"from\"", ")", ")", ";", "assertEquals", "(", "p", "+", "\"\"", ",", "result", ".", "get", "(", "2", ")", ".", "get", "(", "\"to\"", ")", ")", ";", "assertFalse", "(", "new", "File", "(", "Eclim", ".", "resolveFile", "(", "Jdt", ".", "TEST_PROJECT", ",", "\"\"", ")", ")", ".", "exists", "(", ")", ")", ";", "String", "tn1NewContents", "=", "Eclim", ".", "fileToString", "(", "Jdt", ".", "TEST_PROJECT", ",", "\"\"", ")", ";", "assertEquals", "(", "\"\"", ",", "tr1Contents", ".", "replaceAll", "(", "\"n1\"", ",", "\"r1\"", ")", ",", "tn1NewContents", ")", ";", "assertFalse", "(", "new", "File", "(", "Eclim", ".", "resolveFile", "(", "Jdt", ".", "TEST_PROJECT", ",", "\"\"", ")", ")", ".", "exists", "(", ")", ")", ";", "String", "tn2NewContents", "=", "Eclim", ".", "fileToString", "(", "Jdt", ".", "TEST_PROJECT", ",", "\"\"", ")", ";", "assertEquals", "(", "\"\"", ",", "tn2Contents", ".", "replaceAll", "(", "\"n1\"", ",", "\"r1\"", ")", ",", "tn2NewContents", ")", ";", "}", "}", "</s>" ]
1,298
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "correct", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "java", ".", "util", ".", "regex", ".", "Pattern", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang", ".", "StringUtils", ";", "import", "org", ".", "eclim", ".", "Eclim", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "Jdt", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "*", ";", "public", "class", "CorrectCommandTest", "{", "private", "static", "final", "String", "TEST_FILE", "=", "\"\"", ";", "private", "static", "final", "String", "TEST_FILE_PACKAGE", "=", "\"\"", ";", "@", "Test", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "void", "suggest", "(", ")", "{", "assertTrue", "(", "\"\"", ",", "Eclim", ".", "projectExists", "(", "Jdt", ".", "TEST_PROJECT", ")", ")", ";", "Map", "<", "String", ",", "Object", ">", "result", "=", "(", "Map", "<", "String", ",", "Object", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"java_correct\"", ",", "\"-p\"", ",", "Jdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "TEST_FILE", ",", "\"-l\"", ",", "\"5\"", ",", "\"-o\"", ",", "\"74\"", ",", "\"-e\"", ",", "\"utf-8\"", "}", ")", ";", "assertEquals", "(", "\"\"", ",", "result", ".", "get", "(", "\"message\"", ")", ")", ";", "assertEquals", "(", "70", ",", "result", ".", "get", "(", "\"offset\"", ")", ")", ";", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", "results", "=", "(", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", ")", "result", ".", "get", "(", "\"corrections\"", ")", ";", "assertEquals", "(", "0", ",", "results", ".", "get", "(", "0", ")", ".", "get", "(", "\"index\"", ")", ")", ";", "assertEquals", "(", "\"\"", ",", "results", ".", "get", "(", "0", ")", ".", "get", "(", "\"description\"", ")", ")", ";", "}", "@", "Test", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "void", "apply", "(", ")", "{", "assertTrue", "(", "\"\"", ",", "Eclim", ".", "projectExists", "(", "Jdt", ".", "TEST_PROJECT", ")", ")", ";", "Map", "<", "String", ",", "Object", ">", "result", "=", "(", "Map", "<", "String", ",", "Object", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"java_correct\"", ",", "\"-p\"", ",", "Jdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "TEST_FILE", ",", "\"-l\"", ",", "\"5\"", ",", "\"-o\"", ",", "\"74\"", ",", "\"-e\"", ",", "\"utf-8\"", "}", ")", ";", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", "results", "=", "(", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", ")", "result", ".", "get", "(", "\"corrections\"", ")", ";", "int", "apply", "=", "-", "1", ";", "for", "(", "Map", "<", "String", ",", "Object", ">", "r", ":", "results", ")", "{", "if", "(", "r", ".", "get", "(", "\"description\"", ")", ".", "equals", "(", "\"\"", ")", ")", "{", "apply", "=", "(", "(", "Integer", ")", "r", ".", "get", "(", "\"index\"", ")", ")", ".", "intValue", "(", ")", ";", "break", ";", "}", "}", "assertTrue", "(", "\"\"", ",", "apply", ">", "-", "1", ")", ";", "List", "<", "Map", "<", "String", ",", "String", ">", ">", "changes", "=", "(", "List", "<", "Map", "<", "String", ",", "String", ">", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"java_correct\"", ",", "\"-p\"", ",", "Jdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "TEST_FILE", ",", "\"-l\"", ",", "\"5\"", ",", "\"-o\"", ",", "\"74\"", ",", "\"-e\"", ",", "\"utf-8\"", ",", "\"-a\"", ",", "String", ".", "valueOf", "(", "apply", ")", "}", ")", ";", "assertEquals", "(", "1", ",", "changes", ".", "size", "(", ")", ")", ";", "assertEquals", "(", "Eclim", ".", "resolveFile", "(", "Jdt", ".", "TEST_PROJECT", ",", "TEST_FILE", ")", ",", "changes", ".", "get", "(", "0", ")", ".", "get", "(", "\"file\"", ")", ")", ";", "String", "file", "=", "Eclim", ".", "fileToString", "(", "Jdt", ".", "TEST_PROJECT", ",", "TEST_FILE", ")", ";", "assertTrue", "(", "\"\"", ",", "Pattern", ".", "compile", "(", "\"\"", ")", ".", "matcher", "(", "file", ")", ".", "find", "(", ")", ")", ";", "}", "@", "Test", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "void", "suggestPackage", "(", ")", "{", "assertTrue", "(", "\"\"", ",", "Eclim", ".", "projectExists", "(", "Jdt", ".", "TEST_PROJECT", ")", ")", ";", "Map", "<", "String", ",", "Object", ">", "result", "=", "(", "Map", "<", "String", ",", "Object", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"java_correct\"", ",", "\"-p\"", ",", "Jdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "TEST_FILE_PACKAGE", ",", "\"-l\"", ",", "\"1\"", ",", "\"-o\"", ",", "\"0\"", ",", "\"-e\"", ",", "\"utf-8\"", "}", ")", ";", "assertEquals", "(", "\"\"", "+", "\"\"", ",", "result", ".", "get", "(", "\"message\"", ")", ")", ";", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", "results", "=", "(", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", ")", "result", ".", "get", "(", "\"corrections\"", ")", ";", "assertEquals", "(", "\"\"", ",", "results", ".", "get", "(", "1", ")", ".", "get", "(", "\"description\"", ")", ")", ";", "assertEquals", "(", "\"\"", ",", "results", ".", "get", "(", "1", ")", ".", "get", "(", "\"preview\"", ")", ")", ";", "}", "@", "Test", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "void", "applyPackage", "(", ")", "{", "assertTrue", "(", "\"\"", ",", "Eclim", ".", "projectExists", "(", "Jdt", ".", "TEST_PROJECT", ")", ")", ";", "List", "<", "Map", "<", "String", ",", "String", ">", ">", "changes", "=", "(", "List", "<", "Map", "<", "String", ",", "String", ">", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"java_correct\"", ",", "\"-p\"", ",", "Jdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "TEST_FILE_PACKAGE", ",", "\"-l\"", ",", "\"1\"", ",", "\"-o\"", ",", "\"0\"", ",", "\"-e\"", ",", "\"utf-8\"", ",", "\"-a\"", ",", "\"1\"", "}", ")", ";", "assertEquals", "(", "1", ",", "changes", ".", "size", "(", ")", ")", ";", "assertEquals", "(", "Eclim", ".", "resolveFile", "(", "Jdt", ".", "TEST_PROJECT", ",", "TEST_FILE_PACKAGE", ")", ",", "changes", ".", "get", "(", "0", ")", ".", "get", "(", "\"file\"", ")", ")", ";", "String", "file", "=", "Eclim", ".", "fileToString", "(", "Jdt", ".", "TEST_PROJECT", ",", "TEST_FILE_PACKAGE", ")", ";", "String", "[", "]", "lines", "=", "StringUtils", ".", "split", "(", "file", ",", "'\\n'", ")", ";", "assertEquals", "(", "\"\"", ",", "\"\"", ",", "lines", "[", "0", "]", ")", ";", "}", "}", "</s>" ]
1,299
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "command", ".", "search", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "org", ".", "eclim", ".", "Eclim", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "jdt", ".", "Jdt", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "*", ";", "public", "class", "SearchCommandTest", "{", "private", "static", "final", "String", "TEST_FILE", "=", "\"\"", ";", "@", "Test", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "void", "searchCamelCase", "(", ")", "{", "assertTrue", "(", "\"\"", ",", "Eclim", ".", "projectExists", "(", "Jdt", ".", "TEST_PROJECT", ")", ")", ";", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", "results", "=", "(", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"java_search\"", ",", "\"-n\"", ",", "Jdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "TEST_FILE", ",", "\"-p\"", ",", "\"NPE\"", ",", "\"-s\"", ",", "\"project\"", "}", ")", ";", "assertEquals", "(", "\"\"", ",", "2", ",", "results", ".", "size", "(", ")", ")", ";", "Map", "<", "String", ",", "Object", ">", "result", "=", "results", ".", "get", "(", "0", ")", ";", "assertTrue", "(", "(", "(", "String", ")", "result", ".", "get", "(", "\"filename\"", ")", ")", ".", "endsWith", "(", "\"\"", ")", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"message\"", ")", ",", "\"\"", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"line\"", ")", ",", "48", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"column\"", ")", ",", "7", ")", ";", "result", "=", "results", ".", "get", "(", "1", ")", ";", "assertTrue", "(", "(", "(", "String", ")", "result", ".", "get", "(", "\"filename\"", ")", ")", ".", "endsWith", "(", "\"\"", ")", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"message\"", ")", ",", "\"\"", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"line\"", ")", ",", "42", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"column\"", ")", ",", "14", ")", ";", "}", "@", "Test", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "void", "searchElement", "(", ")", "{", "assertTrue", "(", "\"\"", ",", "Eclim", ".", "projectExists", "(", "Jdt", ".", "TEST_PROJECT", ")", ")", ";", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", "results", "=", "(", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"java_search\"", ",", "\"-n\"", ",", "Jdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "TEST_FILE", ",", "\"-o\"", ",", "\"180\"", ",", "\"-e\"", ",", "\"utf-8\"", ",", "\"-l\"", ",", "\"4\"", "}", ")", ";", "Map", "<", "String", ",", "Object", ">", "result", "=", "results", ".", "get", "(", "0", ")", ";", "assertTrue", "(", "(", "(", "String", ")", "result", ".", "get", "(", "\"filename\"", ")", ")", ".", "endsWith", "(", "\"\"", ")", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"message\"", ")", ",", "\"\"", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"line\"", ")", ",", "8", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"column\"", ")", ",", "16", ")", ";", "}", "@", "Test", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "void", "searchPattern", "(", ")", "{", "assertTrue", "(", "\"\"", ",", "Eclim", ".", "projectExists", "(", "Jdt", ".", "TEST_PROJECT", ")", ")", ";", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", "results", "=", "(", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"java_search\"", ",", "\"-n\"", ",", "Jdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "TEST_FILE", ",", "\"-p\"", ",", "\"\"", "}", ")", ";", "assertEquals", "(", "\"\"", ",", "2", ",", "results", ".", "size", "(", ")", ")", ";", "Map", "<", "String", ",", "Object", ">", "result", "=", "results", ".", "get", "(", "0", ")", ";", "assertTrue", "(", "(", "(", "String", ")", "result", ".", "get", "(", "\"filename\"", ")", ")", ".", "endsWith", "(", "\"\"", ")", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"message\"", ")", ",", "\"\"", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"line\"", ")", ",", "6", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"column\"", ")", ",", "14", ")", ";", "result", "=", "results", ".", "get", "(", "1", ")", ";", "assertTrue", "(", "(", "(", "String", ")", "result", ".", "get", "(", "\"filename\"", ")", ")", ".", "endsWith", "(", "\"\"", ")", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"message\"", ")", ",", "\"\"", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"line\"", ")", ",", "6", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"column\"", ")", ",", "14", ")", ";", "}", "@", "Test", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "void", "searchField", "(", ")", "{", "assertTrue", "(", "\"\"", ",", "Eclim", ".", "projectExists", "(", "Jdt", ".", "TEST_PROJECT", ")", ")", ";", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", "results", "=", "(", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"java_search\"", ",", "\"-n\"", ",", "Jdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "TEST_FILE", ",", "\"-p\"", ",", "\"\"", ",", "\"-t\"", ",", "\"field\"", "}", ")", ";", "Map", "<", "String", ",", "Object", ">", "result", "=", "results", ".", "get", "(", "0", ")", ";", "assertTrue", "(", "(", "(", "String", ")", "result", ".", "get", "(", "\"filename\"", ")", ")", ".", "endsWith", "(", "\"\"", ")", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"message\"", ")", ",", "\"\"", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"line\"", ")", ",", "8", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"column\"", ")", ",", "16", ")", ";", "}", "}", "</s>" ]