id
int32
0
12.9k
code
sequencelengths
2
264k
1,400
[ "<s>", "package", "org", ".", "vimplugin", ".", "listeners", ";", "import", "org", ".", "vimplugin", ".", "VimConnection", ";", "import", "org", ".", "vimplugin", ".", "VimEvent", ";", "import", "org", ".", "vimplugin", ".", "VimException", ";", "import", "org", ".", "vimplugin", ".", "VimPlugin", ";", "import", "org", ".", "vimplugin", ".", "VimServer", ";", "import", "org", ".", "vimplugin", ".", "editors", ".", "VimEditor", ";", "public", "class", "FileUnmodified", "implements", "IVimListener", "{", "public", "void", "handleEvent", "(", "VimEvent", "ve", ")", "throws", "VimException", "{", "String", "event", "=", "ve", ".", "getEvent", "(", ")", ";", "if", "(", "event", ".", "equals", "(", "\"unmodified\"", ")", "||", "(", "event", ".", "equals", "(", "\"keyCommand\"", ")", "&&", "ve", ".", "getArgument", "(", "0", ")", ".", "equals", "(", "\"\\\"unmodified\\\"\"", ")", ")", ")", "{", "VimPlugin", "plugin", "=", "VimPlugin", ".", "getDefault", "(", ")", ";", "VimConnection", "vc", "=", "ve", ".", "getConnection", "(", ")", ";", "VimServer", "server", "=", "vc", "!=", "null", "?", "plugin", ".", "getVimserver", "(", "vc", ".", "getVimID", "(", ")", ")", ":", "null", ";", "if", "(", "server", "!=", "null", ")", "{", "for", "(", "VimEditor", "editor", ":", "server", ".", "getEditors", "(", ")", ")", "{", "if", "(", "editor", "!=", "null", "&&", "editor", ".", "getBufferID", "(", ")", "==", "ve", ".", "getBufferID", "(", ")", ")", "{", "editor", ".", "setDirty", "(", "false", ")", ";", "}", "}", "}", "}", "}", "}", "</s>" ]
1,401
[ "<s>", "package", "org", ".", "vimplugin", ".", "listeners", ";", "import", "org", ".", "vimplugin", ".", "VimEvent", ";", "public", "class", "Logger", "implements", "IVimListener", "{", "private", "static", "final", "org", ".", "eclim", ".", "logging", ".", "Logger", "logger", "=", "org", ".", "eclim", ".", "logging", ".", "Logger", ".", "getLogger", "(", "Logger", ".", "class", ")", ";", "public", "void", "handleEvent", "(", "VimEvent", "ve", ")", "{", "logger", ".", "debug", "(", "ve", ".", "getLine", "(", ")", ")", ";", "}", "}", "</s>" ]
1,402
[ "<s>", "package", "org", ".", "vimplugin", ".", "listeners", ";", "import", "org", ".", "vimplugin", ".", "VimEvent", ";", "import", "org", ".", "vimplugin", ".", "VimException", ";", "public", "interface", "IVimListener", "{", "public", "void", "handleEvent", "(", "VimEvent", "ve", ")", "throws", "VimException", ";", "}", "</s>" ]
1,403
[ "<s>", "package", "org", ".", "vimplugin", ".", "listeners", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "org", ".", "eclim", ".", "logging", ".", "Logger", ";", "import", "org", ".", "eclim", ".", "util", ".", "StringUtils", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "bindings", ".", "keys", ".", "KeyStroke", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Point", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Display", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Event", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Shell", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "IEditorPart", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "IWorkbenchPage", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "PlatformUI", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "internal", ".", "Workbench", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "internal", ".", "keys", ".", "BindingService", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "internal", ".", "keys", ".", "WorkbenchKeyboard", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "keys", ".", "IBindingService", ";", "import", "org", ".", "vimplugin", ".", "DisplayUtils", ";", "import", "org", ".", "vimplugin", ".", "VimEvent", ";", "import", "org", ".", "vimplugin", ".", "VimException", ";", "public", "class", "FeedKeys", "implements", "IVimListener", "{", "private", "static", "final", "Logger", "logger", "=", "Logger", ".", "getLogger", "(", "FeedKeys", ".", "class", ")", ";", "public", "void", "handleEvent", "(", "VimEvent", "ve", ")", "throws", "VimException", "{", "String", "argument", "=", "null", ";", "if", "(", "ve", ".", "getEvent", "(", ")", ".", "equals", "(", "\"keyCommand\"", ")", "&&", "(", "argument", "=", "ve", ".", "getArgument", "(", "0", ")", ")", ".", "startsWith", "(", "\"\\\"feedkeys", "\"", ")", ")", "{", "String", "keys", "=", "argument", ".", "substring", "(", "10", ",", "argument", ".", "length", "(", ")", "-", "1", ")", ";", "keys", "=", "keys", ".", "replaceAll", "(", "\"^'(.*)'$\"", ",", "\"$1\"", ")", ";", "keys", "=", "keys", ".", "replaceAll", "(", "\"^\\\"(.*)\\\"$\"", ",", "\"$1\"", ")", ";", "feedKeys", "(", "keys", ")", ";", "}", "}", "private", "void", "feedKeys", "(", "final", "String", "keys", ")", "{", "try", "{", "final", "Workbench", "workbench", "=", "(", "Workbench", ")", "PlatformUI", ".", "getWorkbench", "(", ")", ";", "final", "Display", "display", "=", "workbench", ".", "getDisplay", "(", ")", ";", "final", "int", "[", "]", "bounds", "=", "new", "int", "[", "2", "]", ";", "display", ".", "syncExec", "(", "new", "Runnable", "(", ")", "{", "public", "void", "run", "(", ")", "{", "Shell", "shell", "=", "display", ".", "getActiveShell", "(", ")", ";", "if", "(", "shell", "==", "null", ")", "{", "shell", "=", "display", ".", "getShells", "(", ")", "[", "0", "]", ";", "}", "Point", "point", "=", "shell", ".", "toDisplay", "(", "1", ",", "1", ")", ";", "bounds", "[", "0", "]", "=", "point", ".", "x", ";", "bounds", "[", "1", "]", "=", "point", ".", "y", ";", "}", "}", ")", ";", "DisplayUtils", ".", "doClick", "(", "display", ",", "bounds", "[", "0", "]", "+", "5", ",", "bounds", "[", "1", "]", "+", "5", ",", "false", ")", ";", "final", "String", "[", "]", "sequences", "=", "StringUtils", ".", "split", "(", "keys", ",", "','", ")", ";", "display", ".", "asyncExec", "(", "new", "Runnable", "(", ")", "{", "public", "void", "run", "(", ")", "{", "BindingService", "bindingService", "=", "(", "BindingService", ")", "PlatformUI", ".", "getWorkbench", "(", ")", ".", "getAdapter", "(", "IBindingService", ".", "class", ")", ";", "WorkbenchKeyboard", "keyboard", "=", "bindingService", ".", "getKeyboard", "(", ")", ";", "for", "(", "String", "sequence", ":", "sequences", ")", "{", "try", "{", "if", "(", "sequence", ".", "equals", "(", "\"refocus\"", ")", ")", "{", "logger", ".", "debug", "(", "\"refocus", "gvim\"", ")", ";", "IWorkbenchPage", "page", "=", "PlatformUI", ".", "getWorkbench", "(", ")", ".", "getActiveWorkbenchWindow", "(", ")", ".", "getActivePage", "(", ")", ";", "IEditorPart", "editor", "=", "page", ".", "getActiveEditor", "(", ")", ";", "if", "(", "editor", "!=", "null", ")", "{", "editor", ".", "setFocus", "(", ")", ";", "}", "continue", ";", "}", "KeyStroke", "keyStroke", "=", "KeyStroke", ".", "getInstance", "(", "sequence", ")", ";", "Event", "event", "=", "new", "Event", "(", ")", ";", "event", ".", "widget", "=", "display", ".", "getActiveShell", "(", ")", ";", "ArrayList", "<", "KeyStroke", ">", "keyStrokes", "=", "new", "ArrayList", "<", "KeyStroke", ">", "(", ")", ";", "keyStrokes", ".", "add", "(", "keyStroke", ")", ";", "keyboard", ".", "press", "(", "keyStrokes", ",", "event", ")", ";", "logger", ".", "debug", "(", "\"\"", "+", "sequence", ")", ";", "}", "catch", "(", "Throwable", "t", ")", "{", "logger", ".", "error", "(", "\"\"", ",", "t", ")", ";", "}", "}", "}", "}", ")", ";", "}", "catch", "(", "Throwable", "t", ")", "{", "logger", ".", "error", "(", "\"\"", ",", "t", ")", ";", "}", "}", "}", "</s>" ]
1,404
[ "<s>", "package", "org", ".", "vimplugin", ";", "import", "org", ".", "vimplugin", ".", "editors", ".", "VimEditor", ";", "public", "class", "VimEvent", "{", "private", "static", "final", "org", ".", "eclim", ".", "logging", ".", "Logger", "logger", "=", "org", ".", "eclim", ".", "logging", ".", "Logger", ".", "getLogger", "(", "VimEvent", ".", "class", ")", ";", "private", "final", "String", "line", ";", "private", "final", "VimConnection", "connection", ";", "public", "VimEvent", "(", "String", "_line", ",", "VimConnection", "_connection", ")", "{", "line", "=", "_line", ";", "connection", "=", "_connection", ";", "}", "public", "String", "getLine", "(", ")", "{", "return", "line", ";", "}", "public", "String", "getEvent", "(", ")", "throws", "VimException", "{", "int", "beginIndex", "=", "line", ".", "indexOf", "(", "':'", ")", ";", "int", "endIndex", "=", "line", ".", "indexOf", "(", "'='", ")", ";", "try", "{", "return", "line", ".", "substring", "(", "beginIndex", "+", "1", ",", "endIndex", ")", ";", "}", "catch", "(", "IndexOutOfBoundsException", "iobe", ")", "{", "logger", ".", "debug", "(", "\"\"", "+", "line", ",", "iobe", ")", ";", "}", "return", "\"\"", ";", "}", "public", "String", "getArgument", "(", "int", "index", ")", "throws", "VimException", "{", "int", "i", "=", "0", ";", "int", "beginIndex", "=", "-", "1", ";", "while", "(", "i", "<=", "index", ")", "{", "beginIndex", "=", "line", ".", "indexOf", "(", "\"", "\"", ",", "beginIndex", "+", "1", ")", ";", "i", "++", ";", "}", "int", "endIndex", "=", "beginIndex", ";", "if", "(", "line", ".", "charAt", "(", "beginIndex", "+", "1", ")", "==", "'\"'", ")", "{", "while", "(", "true", ")", "{", "endIndex", "=", "line", ".", "indexOf", "(", "\"", "\"", ",", "endIndex", "+", "1", ")", ";", "if", "(", "endIndex", "==", "-", "1", "||", "(", "line", ".", "charAt", "(", "endIndex", "-", "1", ")", "==", "'\"'", "&&", "beginIndex", "!=", "endIndex", "-", "2", ")", ")", "break", ";", "}", "}", "else", "{", "endIndex", "=", "line", ".", "indexOf", "(", "\"", "\"", ",", "beginIndex", "+", "1", ")", ";", "}", "if", "(", "endIndex", "==", "-", "1", ")", "{", "endIndex", "=", "line", ".", "length", "(", ")", ";", "}", "try", "{", "return", "line", ".", "substring", "(", "beginIndex", "+", "1", ",", "endIndex", ")", ";", "}", "catch", "(", "IndexOutOfBoundsException", "iobe", ")", "{", "logger", ".", "debug", "(", "\"\"", "+", "index", "+", "\"", "from", "line:\"", "+", "line", ",", "iobe", ")", ";", "}", "return", "\"\"", ";", "}", "public", "int", "getBufferID", "(", ")", "throws", "VimException", "{", "int", "beginIndex", "=", "line", ".", "indexOf", "(", "':'", ")", ";", "try", "{", "return", "Integer", ".", "parseInt", "(", "line", ".", "substring", "(", "0", ",", "beginIndex", ")", ")", ";", "}", "catch", "(", "NumberFormatException", "nfe", ")", "{", "throw", "new", "VimException", "(", "\"\"", ",", "nfe", ")", ";", "}", "}", "public", "VimConnection", "getConnection", "(", ")", "{", "return", "connection", ";", "}", "public", "VimEditor", "getEditor", "(", ")", "throws", "VimException", "{", "return", "VimPlugin", ".", "getDefault", "(", ")", ".", "getVimserver", "(", "this", ".", "getConnection", "(", ")", ".", "getVimID", "(", ")", ")", ".", "getEditor", "(", "this", ".", "getBufferID", "(", ")", ")", ";", "}", "}", "</s>" ]
1,405
[ "<s>", "package", "org", ".", "vimplugin", ";", "import", "java", ".", "io", ".", "BufferedReader", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "io", ".", "InputStream", ";", "import", "java", ".", "io", ".", "InputStreamReader", ";", "import", "java", ".", "io", ".", "PrintWriter", ";", "import", "java", ".", "net", ".", "ServerSocket", ";", "import", "java", ".", "net", ".", "Socket", ";", "import", "java", ".", "net", ".", "SocketException", ";", "import", "java", ".", "util", ".", "HashSet", ";", "import", "java", ".", "util", ".", "regex", ".", "Pattern", ";", "import", "org", ".", "vimplugin", ".", "editors", ".", "VimEditor", ";", "import", "org", ".", "vimplugin", ".", "listeners", ".", "BufferEnter", ";", "import", "org", ".", "vimplugin", ".", "listeners", ".", "FeedKeys", ";", "import", "org", ".", "vimplugin", ".", "listeners", ".", "FileClosed", ";", "import", "org", ".", "vimplugin", ".", "listeners", ".", "FileModified", ";", "import", "org", ".", "vimplugin", ".", "listeners", ".", "FileOpened", ";", "import", "org", ".", "vimplugin", ".", "listeners", ".", "FileUnmodified", ";", "import", "org", ".", "vimplugin", ".", "listeners", ".", "IVimListener", ";", "import", "org", ".", "vimplugin", ".", "listeners", ".", "Logger", ";", "import", "org", ".", "vimplugin", ".", "listeners", ".", "ServerDisconnect", ";", "import", "org", ".", "vimplugin", ".", "listeners", ".", "ServerStarted", ";", "import", "org", ".", "vimplugin", ".", "listeners", ".", "TextInsert", ";", "import", "org", ".", "vimplugin", ".", "listeners", ".", "TextRemoved", ";", "import", "org", ".", "vimplugin", ".", "preferences", ".", "PreferenceConstants", ";", "public", "class", "VimConnection", "implements", "Runnable", "{", "private", "static", "final", "org", ".", "eclim", ".", "logging", ".", "Logger", "logger", "=", "org", ".", "eclim", ".", "logging", ".", "Logger", ".", "getLogger", "(", "VimConnection", ".", "class", ")", ";", "private", "static", "final", "Pattern", "EVENT", "=", "Pattern", ".", "compile", "(", "\"\"", ")", ";", "private", "boolean", "serverRunning", "=", "false", ";", "private", "boolean", "startupDone", "=", "false", ";", "final", "HashSet", "<", "IVimListener", ">", "listeners", "=", "new", "HashSet", "<", "IVimListener", ">", "(", ")", ";", "final", "int", "vimID", ";", "private", "BufferedReader", "in", ";", "private", "PrintWriter", "out", ";", "private", "final", "int", "port", ";", "private", "ServerSocket", "socket", ";", "private", "Socket", "vimSocket", ";", "private", "volatile", "boolean", "functionCalled", "=", "false", ";", "private", "Object", "functionMonitor", "=", "new", "Object", "(", ")", ";", "private", "String", "functionResult", ";", "public", "VimConnection", "(", "int", "instanceID", ")", "{", "port", "=", "VimPlugin", ".", "getDefault", "(", ")", ".", "getPreferenceStore", "(", ")", ".", "getInt", "(", "PreferenceConstants", ".", "P_PORT", ")", ";", "vimID", "=", "instanceID", ";", "}", "public", "void", "run", "(", ")", "{", "try", "{", "logger", ".", "debug", "(", "\"\"", "+", "(", "port", "+", "vimID", ")", ")", ";", "socket", "=", "new", "ServerSocket", "(", "port", "+", "vimID", ")", ";", "logger", ".", "debug", "(", "\"\"", ")", ";", "vimSocket", "=", "socket", ".", "accept", "(", ")", ";", "out", "=", "new", "PrintWriter", "(", "vimSocket", ".", "getOutputStream", "(", ")", ",", "true", ")", ";", "in", "=", "new", "BufferedReader", "(", "new", "InputStreamReader", "(", "vimSocket", ".", "getInputStream", "(", ")", ")", ")", ";", "logger", ".", "debug", "(", "\"\"", ")", ";", "listeners", ".", "add", "(", "new", "Logger", "(", ")", ")", ";", "listeners", ".", "add", "(", "new", "ServerStarted", "(", ")", ")", ";", "listeners", ".", "add", "(", "new", "ServerDisconnect", "(", ")", ")", ";", "listeners", ".", "add", "(", "new", "TextInsert", "(", ")", ")", ";", "listeners", ".", "add", "(", "new", "TextRemoved", "(", ")", ")", ";", "listeners", ".", "add", "(", "new", "FileOpened", "(", ")", ")", ";", "listeners", ".", "add", "(", "new", "FileClosed", "(", ")", ")", ";", "listeners", ".", "add", "(", "new", "FileModified", "(", ")", ")", ";", "listeners", ".", "add", "(", "new", "FileUnmodified", "(", ")", ")", ";", "listeners", ".", "add", "(", "new", "BufferEnter", "(", ")", ")", ";", "listeners", ".", "add", "(", "new", "FeedKeys", "(", ")", ")", ";", "String", "line", ";", "try", "{", "while", "(", "!", "startupDone", "&&", "(", "line", "=", "in", ".", "readLine", "(", ")", ")", "!=", "null", ")", "{", "if", "(", "!", "line", ".", "startsWith", "(", "\"AUTH\"", ")", ")", "{", "VimEvent", "ve", "=", "new", "VimEvent", "(", "line", ",", "this", ")", ";", "for", "(", "IVimListener", "listener", ":", "listeners", ")", "{", "listener", ".", "handleEvent", "(", "ve", ")", ";", "}", "}", "}", "}", "catch", "(", "VimException", "ve", ")", "{", "logger", ".", "error", "(", "\"error:\"", ",", "ve", ")", ";", "}", "try", "{", "while", "(", "(", "serverRunning", "&&", "(", "line", "=", "in", ".", "readLine", "(", ")", ")", "!=", "null", ")", ")", "{", "if", "(", "functionCalled", "&&", "!", "EVENT", ".", "matcher", "(", "line", ")", ".", "matches", "(", ")", ")", "{", "synchronized", "(", "functionMonitor", ")", "{", "functionResult", "=", "line", ";", "functionMonitor", ".", "notify", "(", ")", ";", "}", "}", "else", "{", "VimEvent", "ve", "=", "new", "VimEvent", "(", "line", ",", "this", ")", ";", "for", "(", "IVimListener", "listener", ":", "listeners", ")", "{", "listener", ".", "handleEvent", "(", "ve", ")", ";", "}", "}", "}", "}", "catch", "(", "SocketException", "se", ")", "{", "VimPlugin", "plugin", "=", "VimPlugin", ".", "getDefault", "(", ")", ";", "VimServer", "server", "=", "plugin", ".", "getVimserver", "(", "getVimID", "(", ")", ")", ";", "if", "(", "server", "!=", "null", ")", "{", "for", "(", "VimEditor", "editor", ":", "server", ".", "getEditors", "(", ")", ")", "{", "if", "(", "editor", "!=", "null", ")", "{", "editor", ".", "forceDispose", "(", ")", ";", "}", "}", "}", "close", "(", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "logger", ".", "error", "(", "\"error:\"", ",", "e", ")", ";", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "}", "public", "boolean", "close", "(", ")", "throws", "IOException", "{", "if", "(", "vimSocket", "!=", "null", ")", "{", "vimSocket", ".", "close", "(", ")", ";", "}", "if", "(", "socket", "!=", "null", ")", "{", "socket", ".", "close", "(", ")", ";", "}", "serverRunning", "=", "false", ";", "return", "true", ";", "}", "public", "void", "command", "(", "int", "bufID", ",", "String", "name", ",", "String", "param", ")", "{", "int", "seqno", "=", "VimPlugin", ".", "getDefault", "(", ")", ".", "nextSeqNo", "(", ")", ";", "String", "cmd", "=", "bufID", "+", "\":\"", "+", "name", "+", "\"!\"", "+", "seqno", "+", "\"", "\"", "+", "param", ";", "logger", ".", "debug", "(", "\"command:", "\"", "+", "cmd", ")", ";", "out", ".", "println", "(", "cmd", ")", ";", "}", "public", "String", "function", "(", "int", "bufID", ",", "String", "name", ",", "String", "param", ")", "throws", "IOException", "{", "int", "seqno", "=", "VimPlugin", ".", "getDefault", "(", ")", ".", "nextSeqNo", "(", ")", ";", "String", "tmp", "=", "bufID", "+", "\":\"", "+", "name", "+", "\"/\"", "+", "seqno", "+", "\"", "\"", "+", "param", ";", "logger", ".", "debug", "(", "\"function:", "\"", "+", "tmp", ")", ";", "synchronized", "(", "functionMonitor", ")", "{", "functionCalled", "=", "true", ";", "out", ".", "println", "(", "tmp", ")", ";", "if", "(", "\"saveAndExit\"", ".", "equals", "(", "name", ")", ")", "{", "return", "null", ";", "}", "try", "{", "functionMonitor", ".", "wait", "(", "1000", ")", ";", "}", "catch", "(", "InterruptedException", "ie", ")", "{", "logger", ".", "error", "(", "\"\"", ")", ";", "return", "null", ";", "}", "}", "String", "result", "=", "functionResult", ";", "functionResult", "=", "null", ";", "logger", ".", "debug", "(", "\"result:", "\"", "+", "result", ")", ";", "return", "result", ";", "}", "public", "void", "plain", "(", "String", "s", ")", "{", "logger", ".", "debug", "(", "\"plain:", "\"", "+", "s", ")", ";", "out", ".", "println", "(", "s", ")", ";", "}", "public", "void", "remotesend", "(", "String", "s", ")", "{", "String", "[", "]", "args", "=", "{", "\"vim\"", ",", "\"--servername\"", ",", "String", ".", "valueOf", "(", "vimID", ")", ",", "\"\"", ",", "s", "}", ";", "try", "{", "logger", ".", "debug", "(", "\"\"", "+", "s", ")", ";", "Process", "process", "=", "new", "ProcessBuilder", "(", "args", ")", ".", "start", "(", ")", ";", "InputStream", "is", "=", "process", ".", "getInputStream", "(", ")", ";", "InputStreamReader", "isr", "=", "new", "InputStreamReader", "(", "is", ")", ";", "BufferedReader", "br", "=", "new", "BufferedReader", "(", "isr", ")", ";", "String", "line", ";", "while", "(", "(", "line", "=", "br", ".", "readLine", "(", ")", ")", "!=", "null", ")", "{", "logger", ".", "debug", "(", "line", ")", ";", "}", "process", ".", "waitFor", "(", ")", ";", "logger", ".", "debug", "(", "\"result:", "\"", "+", "process", ".", "exitValue", "(", ")", ")", ";", "}", "catch", "(", "IOException", "ioe", ")", "{", "logger", ".", "error", "(", "\"\"", ",", "ioe", ")", ";", "}", "catch", "(", "InterruptedException", "ie", ")", "{", "logger", ".", "error", "(", "\"\"", ",", "ie", ")", ";", "}", "}", "public", "void", "addListener", "(", "IVimListener", "vl", ")", "{", "listeners", ".", "add", "(", "vl", ")", ";", "}", "public", "int", "getVimID", "(", ")", "{", "return", "vimID", ";", "}", "public", "void", "setStartupDone", "(", "boolean", "startupDone", ")", "{", "this", ".", "startupDone", "=", "startupDone", ";", "}", "public", "boolean", "isStartupDone", "(", ")", "{", "return", "startupDone", ";", "}", "public", "void", "setServerRunning", "(", "boolean", "serverRunning", ")", "{", "this", ".", "serverRunning", "=", "serverRunning", ";", "}", "public", "boolean", "isServerRunning", "(", ")", "{", "return", "serverRunning", ";", "}", "}", "</s>" ]
1,406
[ "<s>", "package", "org", ".", "vimplugin", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "io", ".", "PrintWriter", ";", "import", "java", ".", "io", ".", "StringWriter", ";", "public", "class", "VimExceptionHandler", "implements", "Thread", ".", "UncaughtExceptionHandler", "{", "public", "void", "uncaughtException", "(", "Thread", "t", ",", "Throwable", "e", ")", "{", "String", "stacktrace", ";", "StringWriter", "sw", "=", "null", ";", "PrintWriter", "pw", "=", "null", ";", "try", "{", "sw", "=", "new", "StringWriter", "(", ")", ";", "pw", "=", "new", "PrintWriter", "(", "sw", ")", ";", "e", ".", "printStackTrace", "(", "pw", ")", ";", "stacktrace", "=", "sw", ".", "toString", "(", ")", ";", "}", "finally", "{", "try", "{", "if", "(", "pw", "!=", "null", ")", "pw", ".", "close", "(", ")", ";", "if", "(", "sw", "!=", "null", ")", "sw", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "ignore", ")", "{", "}", "}", "System", ".", "err", ".", "println", "(", "\"\"", "+", "stacktrace", ")", ";", "}", "}", "</s>" ]
1,407
[ "<s>", "package", "org", ".", "vimplugin", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Arrays", ";", "import", "java", ".", "util", ".", "HashSet", ";", "import", "org", ".", "eclim", ".", "logging", ".", "Logger", ";", "import", "org", ".", "eclim", ".", "util", ".", "CommandExecutor", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "Platform", ";", "import", "org", ".", "vimplugin", ".", "editors", ".", "VimEditor", ";", "import", "org", ".", "vimplugin", ".", "preferences", ".", "PreferenceConstants", ";", "public", "class", "VimServer", "{", "private", "static", "final", "Logger", "logger", "=", "Logger", ".", "getLogger", "(", "VimServer", ".", "class", ")", ";", "private", "boolean", "embedded", ";", "private", "boolean", "tabbed", ";", "private", "final", "int", "ID", ";", "private", "HashSet", "<", "VimEditor", ">", "editors", "=", "new", "HashSet", "<", "VimEditor", ">", "(", ")", ";", "public", "VimServer", "(", "int", "instanceID", ")", "{", "ID", "=", "instanceID", ";", "}", "protected", "Process", "p", ";", "protected", "Thread", "t", ";", "protected", "VimConnection", "vc", "=", "null", ";", "public", "int", "getID", "(", ")", "{", "return", "ID", ";", "}", "public", "VimConnection", "getVc", "(", ")", "{", "return", "vc", ";", "}", "public", "boolean", "isExternalTabbed", "(", ")", "{", "return", "tabbed", ";", "}", "public", "boolean", "isEmbedded", "(", ")", "{", "return", "embedded", ";", "}", "protected", "String", "getNetbeansString", "(", "int", "portID", ")", "{", "int", "port", "=", "VimPlugin", ".", "getDefault", "(", ")", ".", "getPreferenceStore", "(", ")", ".", "getInt", "(", "PreferenceConstants", ".", "P_PORT", ")", "+", "portID", ";", "return", "\"-nb::\"", "+", "port", ";", "}", "public", "void", "start", "(", "String", "workingDir", ",", "String", "filePath", ",", "boolean", "tabbed", ",", "boolean", "first", ")", "{", "String", "gvim", "=", "VimPlugin", ".", "getDefault", "(", ")", ".", "getPreferenceStore", "(", ")", ".", "getString", "(", "PreferenceConstants", ".", "P_GVIM", ")", ";", "String", "[", "]", "addopts", "=", "getUserArgs", "(", ")", ";", "String", "[", "]", "args", "=", "null", ";", "if", "(", "!", "tabbed", "||", "first", ")", "{", "int", "numArgs", "=", "tabbed", "?", "8", ":", "6", ";", "args", "=", "new", "String", "[", "numArgs", "+", "addopts", ".", "length", "]", ";", "args", "[", "0", "]", "=", "gvim", ";", "args", "[", "1", "]", "=", "\"--cmd\"", ";", "args", "[", "2", "]", "=", "\"\"", ";", "int", "offset", "=", "0", ";", "if", "(", "tabbed", ")", "{", "offset", "=", "2", ";", "args", "[", "3", "]", "=", "\"--cmd\"", ";", "args", "[", "4", "]", "=", "\"\"", ";", "}", "args", "[", "3", "+", "offset", "]", "=", "\"--servername\"", ";", "args", "[", "4", "+", "offset", "]", "=", "String", ".", "valueOf", "(", "ID", ")", ";", "args", "[", "5", "+", "offset", "]", "=", "getNetbeansString", "(", "ID", ")", ";", "System", ".", "arraycopy", "(", "addopts", ",", "0", ",", "args", ",", "numArgs", ",", "addopts", ".", "length", ")", ";", "this", ".", "tabbed", "=", "tabbed", ";", "start", "(", "workingDir", ",", "false", ",", "(", "tabbed", "&&", "!", "first", ")", ",", "args", ")", ";", "}", "else", "{", "args", "=", "new", "String", "[", "5", "+", "addopts", ".", "length", "]", ";", "args", "[", "0", "]", "=", "gvim", ";", "args", "[", "1", "]", "=", "\"--servername\"", ";", "args", "[", "2", "]", "=", "String", ".", "valueOf", "(", "ID", ")", ";", "args", "[", "3", "]", "=", "\"\"", ";", "args", "[", "4", "]", "=", "\"\"", "+", "workingDir", ".", "replace", "(", "\"", "\"", ",", "\"\\\\", "\"", ")", "+", "\"<cr>\"", ";", "System", ".", "arraycopy", "(", "addopts", ",", "0", ",", "args", ",", "5", ",", "addopts", ".", "length", ")", ";", "start", "(", "workingDir", ",", "false", ",", "(", "tabbed", "&&", "!", "first", ")", ",", "args", ")", ";", "String", "vim", "=", "gvim", ";", "if", "(", "Platform", ".", "getOS", "(", ")", ".", "equals", "(", "Platform", ".", "OS_WIN32", ")", ")", "{", "vim", "=", "gvim", ".", "replace", "(", "\"gvim.exe\"", ",", "\"vim.exe\"", ")", ";", "}", "args", "=", "new", "String", "[", "5", "]", ";", "args", "[", "0", "]", "=", "vim", ";", "args", "[", "1", "]", "=", "\"--servername\"", ";", "args", "[", "2", "]", "=", "String", ".", "valueOf", "(", "ID", ")", ";", "args", "[", "3", "]", "=", "\"\"", ";", "args", "[", "4", "]", "=", "\"bufname('%')\"", ";", "int", "tries", "=", "0", ";", "while", "(", "tries", "<", "5", ")", "{", "try", "{", "String", "result", "=", "CommandExecutor", ".", "execute", "(", "args", ",", "1000", ")", ".", "getResult", "(", ")", ".", "trim", "(", ")", ";", "if", "(", "filePath", ".", "equals", "(", "result", ")", ")", "{", "break", ";", "}", "Thread", ".", "sleep", "(", "500", ")", ";", "tries", "++", ";", "}", "catch", "(", "Exception", "e", ")", "{", "logger", ".", "error", "(", "\"\"", ",", "e", ")", ";", "}", "}", "}", "}", "public", "void", "start", "(", "String", "workingDir", ",", "long", "wid", ")", "{", "String", "gvim", "=", "VimPlugin", ".", "getDefault", "(", ")", ".", "getPreferenceStore", "(", ")", ".", "getString", "(", "PreferenceConstants", ".", "P_GVIM", ")", ";", "String", "netbeans", "=", "getNetbeansString", "(", "ID", ")", ";", "String", "dontfork", "=", "\"-f\"", ";", "String", "socketid", "=", "\"--socketid\"", ";", "if", "(", "Platform", ".", "getOS", "(", ")", ".", "equals", "(", "Platform", ".", "OS_WIN32", ")", ")", "{", "socketid", "=", "\"--windowid\"", ";", "}", "String", "stringwid", "=", "String", ".", "valueOf", "(", "wid", ")", ";", "String", "[", "]", "addopts", "=", "getUserArgs", "(", ")", ";", "String", "[", "]", "args", "=", "new", "String", "[", "9", "+", "addopts", ".", "length", "]", ";", "args", "[", "0", "]", "=", "gvim", ";", "args", "[", "1", "]", "=", "\"--servername\"", ";", "args", "[", "2", "]", "=", "String", ".", "valueOf", "(", "ID", ")", ";", "args", "[", "3", "]", "=", "netbeans", ";", "args", "[", "4", "]", "=", "dontfork", ";", "args", "[", "5", "]", "=", "socketid", ";", "args", "[", "6", "]", "=", "stringwid", ";", "args", "[", "7", "]", "=", "\"--cmd\"", ";", "args", "[", "8", "]", "=", "\"\"", ";", "System", ".", "arraycopy", "(", "addopts", ",", "0", ",", "args", ",", "9", ",", "addopts", ".", "length", ")", ";", "start", "(", "workingDir", ",", "true", ",", "false", ",", "args", ")", ";", "}", "private", "void", "start", "(", "String", "workingDir", ",", "boolean", "embedded", ",", "boolean", "tabbed", ",", "String", "...", "args", ")", "{", "if", "(", "!", "tabbed", "&&", "vc", "!=", "null", "&&", "vc", ".", "isServerRunning", "(", ")", ")", "{", "return", ";", "}", "VimPlugin", "plugin", "=", "VimPlugin", ".", "getDefault", "(", ")", ";", "if", "(", "vc", "==", "null", "||", "!", "vc", ".", "isServerRunning", "(", ")", ")", "{", "vc", "=", "new", "VimConnection", "(", "ID", ")", ";", "t", "=", "new", "Thread", "(", "vc", ")", ";", "t", ".", "setUncaughtExceptionHandler", "(", "new", "VimExceptionHandler", "(", ")", ")", ";", "t", ".", "setDaemon", "(", "true", ")", ";", "t", ".", "start", "(", ")", ";", "}", "try", "{", "logger", ".", "debug", "(", "\"\"", ")", ";", "logger", ".", "debug", "(", "Arrays", ".", "toString", "(", "args", ")", ")", ";", "ProcessBuilder", "builder", "=", "new", "ProcessBuilder", "(", "args", ")", ";", "if", "(", "workingDir", "!=", "null", ")", "{", "builder", ".", "directory", "(", "new", "File", "(", "workingDir", ")", ")", ";", "}", "p", "=", "builder", ".", "start", "(", ")", ";", "logger", ".", "debug", "(", "\"Started", "vim\"", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "logger", ".", "error", "(", "\"error:\"", ",", "e", ")", ";", "}", "long", "maxTime", "=", "System", ".", "currentTimeMillis", "(", ")", "+", "10000L", ";", "while", "(", "!", "vc", ".", "isServerRunning", "(", ")", ")", "{", "if", "(", "System", ".", "currentTimeMillis", "(", ")", ">=", "maxTime", ")", "{", "try", "{", "vc", ".", "close", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "logger", ".", "error", "(", "\"error:\"", ",", "e", ")", ";", "}", "String", "message", "=", "plugin", ".", "getMessage", "(", "\"\"", ",", "plugin", ".", "getMessage", "(", "\"\"", ")", ")", ";", "throw", "new", "RuntimeException", "(", "message", ")", ";", "}", "long", "stoptime", "=", "2000L", ";", "logger", ".", "debug", "(", "\"\"", ")", ";", "try", "{", "Thread", ".", "sleep", "(", "stoptime", ")", ";", "}", "catch", "(", "InterruptedException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "}", "this", ".", "embedded", "=", "embedded", ";", "}", "public", "synchronized", "boolean", "stop", "(", ")", "throws", "IOException", "{", "boolean", "result", "=", "false", ";", "if", "(", "p", "!=", "null", ")", "{", "Thread", "waiter", "=", "new", "Thread", "(", ")", "{", "public", "void", "run", "(", ")", "{", "try", "{", "logger", ".", "debug", "(", "\"\"", ")", ";", "p", ".", "waitFor", "(", ")", ";", "}", "catch", "(", "InterruptedException", "ie", ")", "{", "}", "}", "}", ";", "waiter", ".", "start", "(", ")", ";", "try", "{", "waiter", ".", "join", "(", "10000", ")", ";", "}", "catch", "(", "InterruptedException", "ie", ")", "{", "}", "p", ".", "destroy", "(", ")", ";", "p", "=", "null", ";", "logger", ".", "debug", "(", "\"Vim", "closed.\"", ")", ";", "}", "if", "(", "vc", "!=", "null", ")", "{", "result", "=", "vc", ".", "close", "(", ")", ";", "vc", "=", "null", ";", "}", "if", "(", "t", "!=", "null", ")", "{", "t", ".", "interrupt", "(", ")", ";", "}", "return", "result", ";", "}", "public", "void", "setEditors", "(", "HashSet", "<", "VimEditor", ">", "editors", ")", "{", "this", ".", "editors", "=", "editors", ";", "}", "public", "HashSet", "<", "VimEditor", ">", "getEditors", "(", ")", "{", "return", "editors", ";", "}", "public", "VimEditor", "getEditor", "(", "int", "bufid", ")", "{", "for", "(", "VimEditor", "veditor", ":", "getEditors", "(", ")", ")", "{", "if", "(", "veditor", ".", "getBufferID", "(", ")", "==", "bufid", ")", "{", "return", "veditor", ";", "}", "}", "return", "null", ";", "}", "protected", "String", "[", "]", "getUserArgs", "(", ")", "{", "String", "opts", "=", "VimPlugin", ".", "getDefault", "(", ")", ".", "getPreferenceStore", "(", ")", ".", "getString", "(", "PreferenceConstants", ".", "P_OPTS", ")", ";", "char", "[", "]", "chars", "=", "opts", ".", "toCharArray", "(", ")", ";", "char", "quote", "=", "'", "'", ";", "StringBuffer", "arg", "=", "new", "StringBuffer", "(", ")", ";", "ArrayList", "<", "String", ">", "args", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "for", "(", "char", "c", ":", "chars", ")", "{", "if", "(", "c", "==", "'", "'", "&&", "quote", "==", "'", "'", ")", "{", "if", "(", "arg", ".", "length", "(", ")", ">", "0", ")", "{", "args", ".", "add", "(", "arg", ".", "toString", "(", ")", ")", ";", "arg", "=", "new", "StringBuffer", "(", ")", ";", "}", "}", "else", "if", "(", "c", "==", "'\"'", "||", "c", "==", "'\\''", ")", "{", "if", "(", "quote", "!=", "'", "'", "&&", "c", "==", "quote", ")", "{", "quote", "=", "'", "'", ";", "}", "else", "if", "(", "quote", "==", "'", "'", ")", "{", "quote", "=", "c", ";", "}", "else", "{", "arg", ".", "append", "(", "c", ")", ";", "}", "}", "else", "{", "arg", ".", "append", "(", "c", ")", ";", "}", "}", "if", "(", "arg", ".", "length", "(", ")", ">", "0", ")", "{", "args", ".", "add", "(", "arg", ".", "toString", "(", ")", ")", ";", "}", "return", "args", ".", "toArray", "(", "new", "String", "[", "args", ".", "size", "(", ")", "]", ")", ";", "}", "}", "</s>" ]
1,408
[ "<s>", "package", "org", ".", "vimplugin", ".", "editors", ";", "import", "java", ".", "util", ".", "Arrays", ";", "import", "org", ".", "eclim", ".", "logging", ".", "Logger", ";", "import", "org", ".", "eclipse", ".", "core", ".", "commands", ".", "CommandManager", ";", "import", "org", ".", "eclipse", ".", "core", ".", "commands", ".", "common", ".", "NotDefinedException", ";", "import", "org", ".", "eclipse", ".", "core", ".", "commands", ".", "contexts", ".", "ContextManager", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "bindings", ".", "Binding", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "bindings", ".", "BindingManager", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "bindings", ".", "Scheme", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "bindings", ".", "keys", ".", "KeyBinding", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "bindings", ".", "keys", ".", "KeySequence", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "bindings", ".", "keys", ".", "ParseException", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "contexts", ".", "IContextIds", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "IPartListener", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "IWorkbench", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "IWorkbenchPart", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "PlatformUI", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "keys", ".", "IBindingService", ";", "public", "class", "VimEditorPartListener", "implements", "IPartListener", "{", "private", "static", "final", "Logger", "logger", "=", "Logger", ".", "getLogger", "(", "VimEditorPartListener", ".", "class", ")", ";", "private", "static", "final", "String", "[", "]", "CONTEXT_IDS", "=", "new", "String", "[", "]", "{", "IContextIds", ".", "CONTEXT_ID_WINDOW", ",", "IContextIds", ".", "CONTEXT_ID_DIALOG_AND_WINDOW", ",", "}", ";", "private", "boolean", "keysDisabled", "=", "false", ";", "private", "IBindingService", "bindingService", ";", "private", "String", "[", "]", "keys", "=", "{", "\"Ctrl+N\"", ",", "\"Ctrl+U\"", ",", "\"Ctrl+V\"", ",", "\"Ctrl+W\"", "}", ";", "private", "KeySequence", "[", "]", "keySequences", ";", "public", "VimEditorPartListener", "(", ")", "{", "IWorkbench", "workbench", "=", "PlatformUI", ".", "getWorkbench", "(", ")", ";", "bindingService", "=", "(", "IBindingService", ")", "workbench", ".", "getService", "(", "IBindingService", ".", "class", ")", ";", "keySequences", "=", "new", "KeySequence", "[", "keys", ".", "length", "]", ";", "for", "(", "int", "ii", "=", "0", ";", "ii", "<", "keys", ".", "length", ";", "ii", "++", ")", "{", "try", "{", "keySequences", "[", "ii", "]", "=", "KeySequence", ".", "getInstance", "(", "keys", "[", "ii", "]", ")", ";", "}", "catch", "(", "ParseException", "pe", ")", "{", "logger", ".", "error", "(", "\"\"", "+", "keys", "[", "ii", "]", ",", "pe", ")", ";", "}", "}", "}", "public", "void", "partActivated", "(", "IWorkbenchPart", "part", ")", "{", "if", "(", "part", "instanceof", "VimEditor", ")", "{", "VimEditor", "editor", "=", "(", "VimEditor", ")", "part", ";", "if", "(", "editor", ".", "isEmbedded", "(", ")", ")", "{", "disableKeys", "(", ")", ";", "}", "}", "else", "{", "enableKeys", "(", ")", ";", "}", "}", "public", "void", "partBroughtToTop", "(", "IWorkbenchPart", "part", ")", "{", "}", "public", "void", "partClosed", "(", "IWorkbenchPart", "part", ")", "{", "}", "public", "void", "partDeactivated", "(", "IWorkbenchPart", "part", ")", "{", "}", "public", "void", "partOpened", "(", "IWorkbenchPart", "part", ")", "{", "}", "private", "BindingManager", "getLocalChangeManager", "(", ")", "{", "BindingManager", "manager", "=", "new", "BindingManager", "(", "new", "ContextManager", "(", ")", ",", "new", "CommandManager", "(", ")", ")", ";", "Scheme", "scheme", "=", "bindingService", ".", "getActiveScheme", "(", ")", ";", "try", "{", "try", "{", "manager", ".", "setActiveScheme", "(", "scheme", ")", ";", "}", "catch", "(", "NotDefinedException", "nde", ")", "{", "}", "manager", ".", "setLocale", "(", "bindingService", ".", "getLocale", "(", ")", ")", ";", "manager", ".", "setPlatform", "(", "bindingService", ".", "getPlatform", "(", ")", ")", ";", "manager", ".", "setBindings", "(", "bindingService", ".", "getBindings", "(", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "logger", ".", "error", "(", "\"\"", ",", "e", ")", ";", "}", "return", "manager", ";", "}", "private", "void", "disableKeys", "(", ")", "{", "if", "(", "!", "keysDisabled", ")", "{", "logger", ".", "debug", "(", "\"\"", "+", "Arrays", ".", "toString", "(", "keys", ")", ")", ";", "BindingManager", "localChangeManager", "=", "getLocalChangeManager", "(", ")", ";", "String", "schemeId", "=", "localChangeManager", ".", "getActiveScheme", "(", ")", ".", "getId", "(", ")", ";", "for", "(", "KeySequence", "keySequence", ":", "keySequences", ")", "{", "for", "(", "String", "contextId", ":", "CONTEXT_IDS", ")", "{", "localChangeManager", ".", "removeBindings", "(", "keySequence", ",", "schemeId", ",", "contextId", ",", "null", ",", "null", ",", "null", ",", "Binding", ".", "USER", ")", ";", "localChangeManager", ".", "addBinding", "(", "new", "KeyBinding", "(", "keySequence", ",", "null", ",", "schemeId", ",", "contextId", ",", "null", ",", "null", ",", "null", ",", "Binding", ".", "USER", ")", ")", ";", "}", "}", "keysDisabled", "=", "true", ";", "saveKeyChanges", "(", "localChangeManager", ")", ";", "}", "}", "private", "void", "enableKeys", "(", ")", "{", "if", "(", "keysDisabled", ")", "{", "logger", ".", "debug", "(", "\"\"", ")", ";", "BindingManager", "localChangeManager", "=", "getLocalChangeManager", "(", ")", ";", "String", "schemeId", "=", "localChangeManager", ".", "getActiveScheme", "(", ")", ".", "getId", "(", ")", ";", "for", "(", "KeySequence", "keySequence", ":", "keySequences", ")", "{", "for", "(", "String", "contextId", ":", "CONTEXT_IDS", ")", "{", "localChangeManager", ".", "removeBindings", "(", "keySequence", ",", "schemeId", ",", "contextId", ",", "null", ",", "null", ",", "null", ",", "Binding", ".", "USER", ")", ";", "}", "}", "keysDisabled", "=", "false", ";", "saveKeyChanges", "(", "localChangeManager", ")", ";", "}", "}", "private", "void", "saveKeyChanges", "(", "BindingManager", "localChangeManager", ")", "{", "try", "{", "bindingService", ".", "savePreferences", "(", "localChangeManager", ".", "getActiveScheme", "(", ")", ",", "localChangeManager", ".", "getBindings", "(", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "logger", ".", "error", "(", "\"\"", ",", "e", ")", ";", "}", "}", "}", "</s>" ]
1,409
[ "<s>", "package", "org", ".", "vimplugin", ".", "editors", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "custom", ".", "StyledText", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Composite", ";", "public", "class", "VimText", "extends", "StyledText", "{", "public", "VimText", "(", "Composite", "parent", ",", "int", "style", ")", "{", "super", "(", "parent", ",", "style", ")", ";", "}", "}", "</s>" ]
1,410
[ "<s>", "package", "org", ".", "vimplugin", ".", "editors", ";", "import", "java", ".", "io", ".", "ByteArrayInputStream", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "io", ".", "PrintWriter", ";", "import", "java", ".", "io", ".", "StringWriter", ";", "import", "java", ".", "lang", ".", "reflect", ".", "Field", ";", "import", "java", ".", "net", ".", "URI", ";", "import", "org", ".", "eclim", ".", "logging", ".", "Logger", ";", "import", "org", ".", "eclim", ".", "util", ".", "CommandExecutor", ";", "import", "org", ".", "eclim", ".", "util", ".", "file", ".", "FileUtils", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "IFile", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "IProject", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "ResourcesPlugin", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "CoreException", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "IPath", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "IProgressMonitor", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "IStatus", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "Status", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "dialogs", ".", "IDialogConstants", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "dialogs", ".", "MessageDialog", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "preference", ".", "IPreferenceStore", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "preference", ".", "PreferenceDialog", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "text", ".", "IDocument", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "SWT", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Point", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Rectangle", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Button", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Canvas", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Composite", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Control", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Display", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Shell", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "IEditorInput", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "IEditorSite", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "IFileEditorInput", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "IMemento", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "IURIEditorInput", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "IWorkbenchPage", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "PartInitException", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "PlatformUI", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "dialogs", ".", "PreferencesUtil", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "editors", ".", "text", ".", "TextEditor", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "internal", ".", "part", ".", "StatusPart", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "texteditor", ".", "AbstractTextEditor", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "texteditor", ".", "IDocumentProvider", ";", "import", "org", ".", "vimplugin", ".", "DisplayUtils", ";", "import", "org", ".", "vimplugin", ".", "VimConnection", ";", "import", "org", ".", "vimplugin", ".", "VimPlugin", ";", "import", "org", ".", "vimplugin", ".", "VimServer", ";", "import", "org", ".", "vimplugin", ".", "preferences", ".", "PreferenceConstants", ";", "public", "class", "VimEditor", "extends", "TextEditor", "{", "private", "static", "final", "Logger", "logger", "=", "Logger", ".", "getLogger", "(", "VimEditor", ".", "class", ")", ";", "private", "static", "final", "String", "ECLIMD_VIEW_ID", "=", "\"\"", ";", "private", "int", "serverID", ";", "private", "int", "bufferID", ";", "private", "Canvas", "editorGUI", ";", "private", "IFile", "selectedFile", ";", "private", "IDocument", "document", ";", "private", "VimViewer", "viewer", ";", "private", "VimDocumentProvider", "documentProvider", ";", "private", "boolean", "dirty", ";", "private", "boolean", "alreadyClosed", "=", "false", ";", "private", "Composite", "parent", ";", "public", "static", "final", "String", "win32WID", "=", "\"handle\"", ";", "public", "static", "final", "String", "gtkWID", "=", "\"\"", ";", "private", "Shell", "shell", ";", "private", "boolean", "embedded", ";", "private", "boolean", "tabbed", ";", "private", "boolean", "documentListen", ";", "public", "VimEditor", "(", ")", "{", "super", "(", ")", ";", "bufferID", "=", "-", "1", ";", "setDocumentProvider", "(", "documentProvider", "=", "new", "VimDocumentProvider", "(", ")", ")", ";", "}", "@", "Override", "public", "void", "createPartControl", "(", "Composite", "parent", ")", "{", "this", ".", "parent", "=", "parent", ";", "this", ".", "shell", "=", "parent", ".", "getShell", "(", ")", ";", "VimPlugin", "plugin", "=", "VimPlugin", ".", "getDefault", "(", ")", ";", "if", "(", "!", "plugin", ".", "gvimAvailable", "(", ")", ")", "{", "MessageDialog", "dialog", "=", "new", "MessageDialog", "(", "shell", ",", "\"Vimplugin\"", ",", "null", ",", "plugin", ".", "getMessage", "(", "\"\"", ")", ",", "MessageDialog", ".", "ERROR", ",", "new", "String", "[", "]", "{", "IDialogConstants", ".", "OK_LABEL", ",", "IDialogConstants", ".", "CANCEL_LABEL", "}", ",", "0", ")", "{", "protected", "void", "buttonPressed", "(", "int", "buttonId", ")", "{", "super", ".", "buttonPressed", "(", "buttonId", ")", ";", "if", "(", "buttonId", "==", "IDialogConstants", ".", "OK_ID", ")", "{", "PreferenceDialog", "prefs", "=", "PreferencesUtil", ".", "createPreferenceDialogOn", "(", "shell", ",", "\"\"", ",", "null", ",", "null", ")", ";", "if", "(", "prefs", "!=", "null", ")", "{", "prefs", ".", "open", "(", ")", ";", "}", "}", "}", "}", ";", "dialog", ".", "open", "(", ")", ";", "if", "(", "!", "plugin", ".", "gvimAvailable", "(", ")", ")", "{", "throw", "new", "RuntimeException", "(", "plugin", ".", "getMessage", "(", "\"\"", ")", ")", ";", "}", "}", "IPreferenceStore", "prefs", "=", "plugin", ".", "getPreferenceStore", "(", ")", ";", "tabbed", "=", "prefs", ".", "getBoolean", "(", "PreferenceConstants", ".", "P_TABBED", ")", ";", "embedded", "=", "prefs", ".", "getBoolean", "(", "PreferenceConstants", ".", "P_EMBED", ")", ";", "documentListen", "=", "false", ";", "if", "(", "embedded", ")", "{", "if", "(", "!", "plugin", ".", "gvimEmbedSupported", "(", ")", ")", "{", "String", "message", "=", "plugin", ".", "getMessage", "(", "\"\"", ",", "plugin", ".", "getMessage", "(", "\"\"", ")", ")", ";", "throw", "new", "RuntimeException", "(", "message", ")", ";", "}", "}", "if", "(", "!", "plugin", ".", "gvimNbSupported", "(", ")", ")", "{", "String", "message", "=", "plugin", ".", "getMessage", "(", "\"\"", ",", "plugin", ".", "getMessage", "(", "\"\"", ")", ")", ";", "throw", "new", "RuntimeException", "(", "message", ")", ";", "}", "alreadyClosed", "=", "false", ";", "dirty", "=", "false", ";", "String", "projectPath", "=", "null", ";", "String", "filePath", "=", "null", ";", "IEditorInput", "input", "=", "getEditorInput", "(", ")", ";", "if", "(", "input", "instanceof", "IFileEditorInput", ")", "{", "selectedFile", "=", "(", "(", "IFileEditorInput", ")", "input", ")", ".", "getFile", "(", ")", ";", "IProject", "project", "=", "selectedFile", ".", "getProject", "(", ")", ";", "IPath", "path", "=", "project", ".", "getRawLocation", "(", ")", ";", "if", "(", "path", "==", "null", ")", "{", "String", "name", "=", "project", ".", "getName", "(", ")", ";", "path", "=", "ResourcesPlugin", ".", "getWorkspace", "(", ")", ".", "getRoot", "(", ")", ".", "getRawLocation", "(", ")", ";", "path", "=", "path", ".", "append", "(", "name", ")", ";", "}", "projectPath", "=", "path", ".", "toPortableString", "(", ")", ";", "filePath", "=", "selectedFile", ".", "getRawLocation", "(", ")", ".", "toPortableString", "(", ")", ";", "if", "(", "filePath", ".", "toLowerCase", "(", ")", ".", "indexOf", "(", "projectPath", ".", "toLowerCase", "(", ")", ")", "!=", "-", "1", ")", "{", "filePath", "=", "filePath", ".", "substring", "(", "projectPath", ".", "length", "(", ")", "+", "1", ")", ";", "}", "}", "else", "{", "URI", "uri", "=", "(", "(", "IURIEditorInput", ")", "input", ")", ".", "getURI", "(", ")", ";", "filePath", "=", "uri", ".", "toString", "(", ")", ".", "substring", "(", "\"file:\"", ".", "length", "(", ")", ")", ";", "filePath", "=", "filePath", ".", "replaceFirst", "(", "\"\"", ",", "\"$1\"", ")", ";", "}", "if", "(", "filePath", "!=", "null", ")", "{", "editorGUI", "=", "new", "Canvas", "(", "parent", ",", "SWT", ".", "EMBEDDED", ")", ";", "VimConnection", "vc", "=", "createVim", "(", "projectPath", ",", "filePath", ",", "parent", ")", ";", "viewer", "=", "new", "VimViewer", "(", "bufferID", ",", "vc", ",", "editorGUI", "!=", "null", "?", "editorGUI", ":", "parent", ",", "SWT", ".", "EMBEDDED", ")", ";", "viewer", ".", "getTextWidget", "(", ")", ".", "setVisible", "(", "false", ")", ";", "viewer", ".", "setDocument", "(", "document", ")", ";", "viewer", ".", "setEditable", "(", "isEditable", "(", ")", ")", ";", "try", "{", "Field", "fSourceViewer", "=", "AbstractTextEditor", ".", "class", ".", "getDeclaredField", "(", "\"\"", ")", ";", "fSourceViewer", ".", "setAccessible", "(", "true", ")", ";", "fSourceViewer", ".", "set", "(", "this", ",", "viewer", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "logger", ".", "error", "(", "\"\"", ",", "e", ")", ";", "}", "boolean", "startEclimd", "=", "plugin", ".", "getPreferenceStore", "(", ")", ".", "getBoolean", "(", "PreferenceConstants", ".", "P_START_ECLIMD", ")", ";", "if", "(", "startEclimd", ")", "{", "IWorkbenchPage", "page", "=", "PlatformUI", ".", "getWorkbench", "(", ")", ".", "getActiveWorkbenchWindow", "(", ")", ".", "getActivePage", "(", ")", ";", "try", "{", "if", "(", "page", "!=", "null", "&&", "page", ".", "findView", "(", "ECLIMD_VIEW_ID", ")", "==", "null", ")", "{", "page", ".", "showView", "(", "ECLIMD_VIEW_ID", ")", ";", "}", "}", "catch", "(", "PartInitException", "pie", ")", "{", "logger", ".", "error", "(", "\"\"", ",", "pie", ")", ";", "}", "}", "if", "(", "embedded", ")", "{", "plugin", ".", "getPartListener", "(", ")", ".", "partOpened", "(", "this", ")", ";", "plugin", ".", "getPartListener", "(", ")", ".", "partBroughtToTop", "(", "this", ")", ";", "plugin", ".", "getPartListener", "(", ")", ".", "partActivated", "(", "this", ")", ";", "}", "}", "}", "private", "VimConnection", "createVim", "(", "String", "workingDir", ",", "String", "filePath", ",", "Composite", "parent", ")", "{", "VimPlugin", "plugin", "=", "VimPlugin", ".", "getDefault", "(", ")", ";", "bufferID", "=", "plugin", ".", "getNumberOfBuffers", "(", ")", ";", "plugin", ".", "setNumberOfBuffers", "(", "bufferID", "+", "1", ")", ";", "IStatus", "status", "=", "null", ";", "VimConnection", "vc", "=", "null", ";", "if", "(", "embedded", ")", "{", "try", "{", "vc", "=", "createEmbeddedVim", "(", "workingDir", ",", "filePath", ",", "editorGUI", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "embedded", "=", "false", ";", "vc", "=", "createExternalVim", "(", "workingDir", ",", "filePath", ",", "parent", ")", ";", "String", "message", "=", "plugin", ".", "getMessage", "(", "e", "instanceof", "NoSuchFieldException", "?", "\"\"", ":", "\"\"", ")", ";", "status", "=", "new", "Status", "(", "IStatus", ".", "ERROR", ",", "PlatformUI", ".", "PLUGIN_ID", ",", "0", ",", "message", ",", "e", ")", ";", "}", "}", "else", "{", "vc", "=", "createExternalVim", "(", "workingDir", ",", "filePath", ",", "parent", ")", ";", "String", "message", "=", "plugin", ".", "getMessage", "(", "\"\"", ")", ";", "status", "=", "new", "Status", "(", "IStatus", ".", "OK", ",", "PlatformUI", ".", "PLUGIN_ID", ",", "message", ")", ";", "}", "if", "(", "status", "!=", "null", ")", "{", "editorGUI", ".", "dispose", "(", ")", ";", "editorGUI", "=", "null", ";", "new", "StatusPart", "(", "parent", ",", "status", ")", ";", "if", "(", "status", ".", "getSeverity", "(", ")", "==", "IStatus", ".", "OK", ")", "{", "for", "(", "Control", "c", ":", "parent", ".", "getChildren", "(", ")", ")", "{", "if", "(", "c", "instanceof", "Composite", ")", "{", "for", "(", "Control", "ch", ":", "(", "(", "Composite", ")", "c", ")", ".", "getChildren", "(", ")", ")", "{", "if", "(", "ch", "instanceof", "Button", ")", "{", "ch", ".", "setVisible", "(", "false", ")", ";", "}", "}", "}", "}", "}", "}", "plugin", ".", "getVimserver", "(", "serverID", ")", ".", "getEditors", "(", ")", ".", "add", "(", "this", ")", ";", "return", "vc", ";", "}", "private", "VimConnection", "createExternalVim", "(", "String", "workingDir", ",", "String", "filePath", ",", "Composite", "parent", ")", "{", "VimPlugin", "plugin", "=", "VimPlugin", ".", "getDefault", "(", ")", ";", "boolean", "first", "=", "plugin", ".", "getVimserver", "(", "VimPlugin", ".", "DEFAULT_VIMSERVER_ID", ")", "==", "null", ";", "serverID", "=", "tabbed", "?", "plugin", ".", "getDefaultVimServer", "(", ")", ":", "plugin", ".", "createVimServer", "(", ")", ";", "plugin", ".", "getVimserver", "(", "serverID", ")", ".", "start", "(", "workingDir", ",", "filePath", ",", "tabbed", ",", "first", ")", ";", "VimConnection", "vc", "=", "plugin", ".", "getVimserver", "(", "serverID", ")", ".", "getVc", "(", ")", ";", "vc", ".", "command", "(", "bufferID", ",", "\"editFile\"", ",", "\"\\\"\"", "+", "filePath", "+", "\"\\\"\"", ")", ";", "if", "(", "documentListen", ")", "{", "vc", ".", "command", "(", "bufferID", ",", "\"\"", ",", "\"\"", ")", ";", "}", "else", "{", "vc", ".", "command", "(", "bufferID", ",", "\"\"", ",", "\"\"", ")", ";", "}", "return", "vc", ";", "}", "private", "VimConnection", "createEmbeddedVim", "(", "String", "workingDir", ",", "String", "filePath", ",", "Composite", "parent", ")", "throws", "Exception", "{", "long", "wid", "=", "0", ";", "Field", "f", "=", "null", ";", "try", "{", "f", "=", "Composite", ".", "class", ".", "getField", "(", "VimEditor", ".", "gtkWID", ")", ";", "}", "catch", "(", "NoSuchFieldException", "nsfe", ")", "{", "f", "=", "Control", ".", "class", ".", "getField", "(", "VimEditor", ".", "win32WID", ")", ";", "}", "wid", "=", "f", ".", "getLong", "(", "parent", ")", ";", "VimPlugin", "plugin", "=", "VimPlugin", ".", "getDefault", "(", ")", ";", "serverID", "=", "plugin", ".", "createVimServer", "(", ")", ";", "plugin", ".", "getVimserver", "(", "serverID", ")", ".", "start", "(", "workingDir", ",", "wid", ")", ";", "VimConnection", "vc", "=", "plugin", ".", "getVimserver", "(", "serverID", ")", ".", "getVc", "(", ")", ";", "vc", ".", "command", "(", "bufferID", ",", "\"editFile\"", ",", "\"\\\"\"", "+", "filePath", "+", "\"\\\"\"", ")", ";", "if", "(", "documentListen", ")", "{", "vc", ".", "command", "(", "bufferID", ",", "\"\"", ",", "\"\"", ")", ";", "}", "else", "{", "vc", ".", "command", "(", "bufferID", ",", "\"\"", ",", "\"\"", ")", ";", "}", "return", "vc", ";", "}", "public", "void", "forceDispose", "(", ")", "{", "final", "VimEditor", "editor", "=", "this", ";", "Display", "display", "=", "getSite", "(", ")", ".", "getShell", "(", ")", ".", "getDisplay", "(", ")", ";", "display", ".", "asyncExec", "(", "new", "Runnable", "(", ")", "{", "public", "void", "run", "(", ")", "{", "if", "(", "editor", "!=", "null", "&&", "!", "editor", ".", "alreadyClosed", ")", "{", "editor", ".", "setDirty", "(", "false", ")", ";", "editor", ".", "showBusy", "(", "true", ")", ";", "editor", ".", "close", "(", "false", ")", ";", "getSite", "(", ")", ".", "getPage", "(", ")", ".", "closeEditor", "(", "editor", ",", "false", ")", ";", "}", "}", "}", ")", ";", "}", "@", "Override", "public", "void", "dispose", "(", ")", "{", "close", "(", "true", ")", ";", "if", "(", "viewer", "!=", "null", ")", "{", "viewer", ".", "getTextWidget", "(", ")", ".", "dispose", "(", ")", ";", "viewer", "=", "null", ";", "}", "if", "(", "editorGUI", "!=", "null", ")", "{", "editorGUI", ".", "dispose", "(", ")", ";", "editorGUI", "=", "null", ";", "}", "document", "=", "null", ";", "super", ".", "dispose", "(", ")", ";", "}", "@", "Override", "public", "void", "close", "(", "boolean", "save", ")", "{", "if", "(", "this", ".", "alreadyClosed", ")", "{", "super", ".", "close", "(", "false", ")", ";", "return", ";", "}", "VimPlugin", "plugin", "=", "VimPlugin", ".", "getDefault", "(", ")", ";", "alreadyClosed", "=", "true", ";", "VimServer", "server", "=", "plugin", ".", "getVimserver", "(", "serverID", ")", ";", "if", "(", "server", "!=", "null", ")", "{", "server", ".", "getEditors", "(", ")", ".", "remove", "(", "this", ")", ";", "if", "(", "save", "&&", "dirty", ")", "{", "server", ".", "getVc", "(", ")", ".", "command", "(", "bufferID", ",", "\"save\"", ",", "\"\"", ")", ";", "dirty", "=", "false", ";", "firePropertyChange", "(", "PROP_DIRTY", ")", ";", "}", "if", "(", "server", ".", "getEditors", "(", ")", ".", "size", "(", ")", ">", "0", ")", "{", "server", ".", "getVc", "(", ")", ".", "command", "(", "bufferID", ",", "\"close\"", ",", "\"\"", ")", ";", "String", "gvim", "=", "VimPlugin", ".", "getDefault", "(", ")", ".", "getPreferenceStore", "(", ")", ".", "getString", "(", "PreferenceConstants", ".", "P_GVIM", ")", ";", "String", "[", "]", "args", "=", "new", "String", "[", "5", "]", ";", "args", "[", "0", "]", "=", "gvim", ";", "args", "[", "1", "]", "=", "\"--servername\"", ";", "args", "[", "2", "]", "=", "String", ".", "valueOf", "(", "server", ".", "getID", "(", ")", ")", ";", "args", "[", "3", "]", "=", "\"\"", ";", "args", "[", "4", "]", "=", "\"\"", ";", "try", "{", "CommandExecutor", ".", "execute", "(", "args", ",", "1000", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "logger", ".", "error", "(", "\"\"", ",", "e", ")", ";", "}", "}", "else", "{", "try", "{", "VimConnection", "vc", "=", "server", ".", "getVc", "(", ")", ";", "if", "(", "vc", "!=", "null", ")", "{", "server", ".", "getVc", "(", ")", ".", "function", "(", "bufferID", ",", "\"saveAndExit\"", ",", "\"\"", ")", ";", "}", "plugin", ".", "stopVimServer", "(", "serverID", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "message", "(", "plugin", ".", "getMessage", "(", "\"\"", ")", ",", "e", ")", ";", "}", "}", "}", "super", ".", "close", "(", "false", ")", ";", "}", "@", "Override", "public", "boolean", "isEditable", "(", ")", "{", "return", "false", ";", "}", "@", "Override", "public", "void", "doSave", "(", "IProgressMonitor", "monitor", ")", "{", "VimPlugin", ".", "getDefault", "(", ")", ".", "getVimserver", "(", "serverID", ")", ".", "getVc", "(", ")", ".", "command", "(", "bufferID", ",", "\"save\"", ",", "\"\"", ")", ";", "dirty", "=", "false", ";", "firePropertyChange", "(", "PROP_DIRTY", ")", ";", "}", "@", "Override", "public", "void", "doSaveAs", "(", ")", "{", "performSaveAs", "(", "null", ")", ";", "}", "@", "Override", "public", "void", "init", "(", "IEditorSite", "site", ",", "IEditorInput", "input", ")", "throws", "PartInitException", "{", "setSite", "(", "site", ")", ";", "setInput", "(", "input", ")", ";", "try", "{", "document", "=", "documentProvider", ".", "createDocument", "(", "input", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "VimPlugin", "plugin", "=", "VimPlugin", ".", "getDefault", "(", ")", ";", "message", "(", "plugin", ".", "getMessage", "(", "\"\"", ")", ",", "e", ")", ";", "}", "}", "@", "Override", "public", "boolean", "isDirty", "(", ")", "{", "return", "dirty", ";", "}", "@", "Override", "public", "boolean", "isSaveAsAllowed", "(", ")", "{", "return", "true", ";", "}", "private", "String", "getFilePath", "(", "IEditorInput", "input", ")", "{", "String", "filePath", "=", "null", ";", "if", "(", "input", "instanceof", "IFileEditorInput", ")", "{", "selectedFile", "=", "(", "(", "IFileEditorInput", ")", "input", ")", ".", "getFile", "(", ")", ";", "filePath", "=", "selectedFile", ".", "getRawLocation", "(", ")", ".", "toPortableString", "(", ")", ";", "}", "else", "{", "URI", "uri", "=", "(", "(", "IURIEditorInput", ")", "input", ")", ".", "getURI", "(", ")", ";", "filePath", "=", "uri", ".", "toString", "(", ")", ".", "substring", "(", "\"file:\"", ".", "length", "(", ")", ")", ";", "filePath", "=", "filePath", ".", "replaceFirst", "(", "\"\"", ",", "\"$1\"", ")", ";", "}", "return", "filePath", ";", "}", "public", "void", "setDirty", "(", "boolean", "result", ")", "{", "dirty", "=", "result", ";", "final", "VimEditor", "vime", "=", "this", ";", "Display", "display", "=", "getSite", "(", ")", ".", "getShell", "(", ")", ".", "getDisplay", "(", ")", ";", "display", ".", "asyncExec", "(", "new", "Runnable", "(", ")", "{", "public", "void", "run", "(", ")", "{", "vime", ".", "firePropertyChangeAsync", "(", "PROP_DIRTY", ")", ";", "}", "}", ")", ";", "}", "public", "void", "firePropertyChangeAsync", "(", "int", "prop", ")", "{", "super", ".", "firePropertyChange", "(", "prop", ")", ";", "}", "@", "Override", "public", "void", "setFocus", "(", ")", "{", "if", "(", "alreadyClosed", ")", "{", "getSite", "(", ")", ".", "getPage", "(", ")", ".", "closeEditor", "(", "this", ",", "false", ")", ";", "return", ";", "}", "if", "(", "embedded", ")", "{", "parent", ".", "setFocus", "(", ")", ";", "}", "VimPlugin", "plugin", "=", "VimPlugin", ".", "getDefault", "(", ")", ";", "VimConnection", "conn", "=", "plugin", ".", "getVimserver", "(", "serverID", ")", ".", "getVc", "(", ")", ";", "try", "{", "String", "cursor", "=", "conn", ".", "function", "(", "bufferID", ",", "\"getCursor\"", ",", "\"\"", ")", ";", "if", "(", "cursor", "==", "null", ")", "{", "return", ";", "}", "}", "catch", "(", "IOException", "ioe", ")", "{", "logger", ".", "error", "(", "\"\"", ",", "ioe", ")", ";", "}", "conn", ".", "command", "(", "bufferID", ",", "\"raise\"", ",", "\"\"", ")", ";", "if", "(", "embedded", "&&", "parent", ".", "getDisplay", "(", ")", ".", "getActiveShell", "(", ")", "!=", "null", ")", "{", "boolean", "autoClickFocus", "=", "plugin", ".", "getPreferenceStore", "(", ")", ".", "getBoolean", "(", "PreferenceConstants", ".", "P_FOCUS_AUTO_CLICK", ")", ";", "if", "(", "autoClickFocus", ")", "{", "Rectangle", "bounds", "=", "parent", ".", "getBounds", "(", ")", ";", "final", "Point", "point", "=", "parent", ".", "toDisplay", "(", "bounds", ".", "x", "+", "5", ",", "bounds", ".", "y", "+", "bounds", ".", "height", "-", "25", ")", ";", "new", "Thread", "(", ")", "{", "public", "void", "run", "(", ")", "{", "DisplayUtils", ".", "doClick", "(", "parent", ".", "getDisplay", "(", ")", ",", "point", ".", "x", ",", "point", ".", "y", ",", "true", ")", ";", "}", "}", ".", "start", "(", ")", ";", "}", "}", "}", "public", "void", "setTitleTo", "(", "final", "String", "path", ")", "{", "Display", ".", "getDefault", "(", ")", ".", "asyncExec", "(", "new", "Runnable", "(", ")", "{", "public", "void", "run", "(", ")", "{", "String", "filename", "=", "path", ".", "substring", "(", "path", ".", "lastIndexOf", "(", "File", ".", "separator", ")", "+", "1", ")", ";", "setPartName", "(", "filename", ")", ";", "}", "}", ")", ";", "}", "@", "Override", "public", "IDocumentProvider", "getDocumentProvider", "(", ")", "{", "return", "documentProvider", ";", "}", "public", "void", "setDocumentText", "(", "String", "text", ")", "{", "document", ".", "set", "(", "text", ")", ";", "setDirty", "(", "true", ")", ";", "}", "private", "String", "removeBackSlashes", "(", "String", "text", ")", "{", "if", "(", "text", ".", "length", "(", ")", "<=", "2", ")", "return", "text", ";", "int", "offset", "=", "0", ",", "length", "=", "text", ".", "length", "(", ")", ",", "offset1", "=", "0", ";", "String", "newText", "=", "\"\"", ";", "while", "(", "offset", "<", "length", ")", "{", "offset1", "=", "text", ".", "indexOf", "(", "'\\\\'", ",", "offset", ")", ";", "if", "(", "offset1", "<", "0", ")", "{", "newText", "=", "newText", "+", "text", ".", "substring", "(", "offset", ")", ";", "break", ";", "}", "newText", "=", "newText", "+", "text", ".", "substring", "(", "offset", ",", "offset1", ")", "+", "(", "text", ".", "length", "(", ")", ">", "offset1", "+", "1", "?", "text", ".", "substring", "(", "offset1", "+", "1", ",", "offset1", "+", "2", ")", ":", "\"\"", ")", ";", "offset", "=", "offset1", "+", "2", ";", "}", "return", "newText", ";", "}", "public", "void", "insertDocumentText", "(", "String", "text", ",", "int", "offset", ")", "{", "text", "=", "removeBackSlashes", "(", "text", ")", ";", "try", "{", "String", "contents", "=", "document", ".", "get", "(", ")", ";", "offset", "=", "FileUtils", ".", "byteOffsetToCharOffset", "(", "new", "ByteArrayInputStream", "(", "contents", ".", "getBytes", "(", ")", ")", ",", "offset", ",", "null", ")", ";", "String", "first", "=", "contents", ".", "substring", "(", "0", ",", "offset", ")", ";", "String", "last", "=", "contents", ".", "substring", "(", "offset", ")", ";", "if", "(", "text", ".", "equals", "(", "new", "String", "(", "\"\\\\n\"", ")", ")", ")", "{", "first", "=", "first", "+", "System", ".", "getProperty", "(", "\"\"", ")", "+", "last", ";", "}", "else", "{", "first", "=", "first", "+", "text", "+", "last", ";", "}", "document", ".", "set", "(", "first", ")", ";", "setDirty", "(", "true", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "VimPlugin", "plugin", "=", "VimPlugin", ".", "getDefault", "(", ")", ";", "logger", ".", "error", "(", "plugin", ".", "getMessage", "(", "\"\"", ")", ",", "e", ")", ";", "}", "}", "public", "void", "removeDocumentText", "(", "int", "offset", ",", "int", "length", ")", "{", "try", "{", "String", "contents", "=", "document", ".", "get", "(", ")", ";", "int", "loffset", "=", "FileUtils", ".", "byteOffsetToCharOffset", "(", "new", "ByteArrayInputStream", "(", "contents", ".", "getBytes", "(", ")", ")", ",", "offset", "+", "length", ",", "null", ")", ";", "offset", "=", "FileUtils", ".", "byteOffsetToCharOffset", "(", "new", "ByteArrayInputStream", "(", "contents", ".", "getBytes", "(", ")", ")", ",", "offset", ",", "null", ")", ";", "length", "=", "loffset", "-", "offset", ";", "String", "first", "=", "contents", ".", "substring", "(", "0", ",", "offset", ")", ";", "String", "last", "=", "contents", ".", "substring", "(", "offset", "+", "length", ")", ";", "first", "=", "first", "+", "last", ";", "document", ".", "set", "(", "first", ")", ";", "setDirty", "(", "true", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "VimPlugin", "plugin", "=", "VimPlugin", ".", "getDefault", "(", ")", ";", "logger", ".", "error", "(", "plugin", ".", "getMessage", "(", "\"\"", ")", ",", "e", ")", ";", "}", "}", "@", "Override", "protected", "void", "createActions", "(", ")", "{", "super", ".", "createActions", "(", ")", ";", "}", "@", "Override", "protected", "void", "doSetInput", "(", "IEditorInput", "input", ")", "throws", "CoreException", "{", "if", "(", "getEditorInput", "(", ")", "!=", "null", ")", "{", "String", "oldFilePath", "=", "getFilePath", "(", "getEditorInput", "(", ")", ")", ";", "String", "newFilePath", "=", "getFilePath", "(", "input", ")", ";", "if", "(", "!", "oldFilePath", ".", "equals", "(", "newFilePath", ")", ")", "{", "VimConnection", "vc", "=", "VimPlugin", ".", "getDefault", "(", ")", ".", "getVimserver", "(", "serverID", ")", ".", "getVc", "(", ")", ";", "if", "(", "input", "instanceof", "IFileEditorInput", ")", "{", "IProject", "project", "=", "selectedFile", ".", "getProject", "(", ")", ";", "IPath", "path", "=", "project", ".", "getRawLocation", "(", ")", ";", "if", "(", "path", "==", "null", ")", "{", "String", "name", "=", "project", ".", "getName", "(", ")", ";", "path", "=", "ResourcesPlugin", ".", "getWorkspace", "(", ")", ".", "getRoot", "(", ")", ".", "getRawLocation", "(", ")", ";", "path", "=", "path", ".", "append", "(", "name", ")", ";", "}", "String", "projectPath", "=", "path", ".", "toPortableString", "(", ")", ";", "if", "(", "newFilePath", ".", "toLowerCase", "(", ")", ".", "indexOf", "(", "projectPath", ".", "toLowerCase", "(", ")", ")", "!=", "-", "1", ")", "{", "newFilePath", "=", "newFilePath", ".", "substring", "(", "projectPath", ".", "length", "(", ")", "+", "1", ")", ";", "}", "}", "if", "(", "isDirty", "(", ")", ")", "{", "vc", ".", "remotesend", "(", "\"\"", "+", "newFilePath", ".", "replace", "(", "\"", "\"", ",", "\"\\\\", "\"", ")", "+", "\"<cr>\"", ")", ";", "}", "else", "{", "vc", ".", "command", "(", "bufferID", ",", "\"editFile\"", ",", "\"\\\"\"", "+", "newFilePath", "+", "\"\\\"\"", ")", ";", "}", "}", "}", "super", ".", "doSetInput", "(", "input", ")", ";", "}", "@", "Override", "public", "void", "saveState", "(", "IMemento", "arg0", ")", "{", "}", "public", "IFile", "getSelectedFile", "(", ")", "{", "return", "selectedFile", ";", "}", "public", "int", "getServerID", "(", ")", "{", "return", "serverID", ";", "}", "public", "int", "getBufferID", "(", ")", "{", "return", "bufferID", ";", "}", "public", "boolean", "isEmbedded", "(", ")", "{", "return", "embedded", ";", "}", "private", "void", "message", "(", "String", "message", ",", "Throwable", "e", ")", "{", "String", "stacktrace", ";", "StringWriter", "sw", "=", "null", ";", "PrintWriter", "pw", "=", "null", ";", "try", "{", "sw", "=", "new", "StringWriter", "(", ")", ";", "pw", "=", "new", "PrintWriter", "(", "sw", ")", ";", "e", ".", "printStackTrace", "(", "pw", ")", ";", "stacktrace", "=", "sw", ".", "toString", "(", ")", ";", "}", "finally", "{", "try", "{", "if", "(", "pw", "!=", "null", ")", "pw", ".", "close", "(", ")", ";", "if", "(", "sw", "!=", "null", ")", "sw", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "ignore", ")", "{", "}", "}", "MessageDialog", ".", "openError", "(", "shell", ",", "\"Vimplugin\"", ",", "message", "+", "stacktrace", ")", ";", "}", "}", "</s>" ]
1,411
[ "<s>", "package", "org", ".", "vimplugin", ".", "editors", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "CoreException", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "text", ".", "IDocument", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "editors", ".", "text", ".", "FileDocumentProvider", ";", "public", "class", "VimDocumentProvider", "extends", "FileDocumentProvider", "{", "private", "IDocument", "document", ";", "protected", "IDocument", "createDocument", "(", "Object", "element", ")", "throws", "CoreException", "{", "document", "=", "super", ".", "createDocument", "(", "element", ")", ";", "return", "document", ";", "}", "}", "</s>" ]
1,412
[ "<s>", "package", "org", ".", "vimplugin", ".", "editors", ";", "import", "java", ".", "io", ".", "ByteArrayInputStream", ";", "import", "org", ".", "eclim", ".", "logging", ".", "Logger", ";", "import", "org", ".", "eclim", ".", "util", ".", "file", ".", "FileUtils", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "text", ".", "IDocument", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "text", ".", "IEventConsumer", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "text", ".", "IFindReplaceTarget", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "text", ".", "IRegion", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "text", ".", "IRewriteTarget", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "text", ".", "ITextDoubleClickStrategy", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "text", ".", "ITextHover", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "text", ".", "ITextInputListener", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "text", ".", "ITextListener", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "text", ".", "ITextOperationTarget", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "text", ".", "ITextViewerExtension", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "text", ".", "IUndoManager", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "text", ".", "IViewportListener", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "text", ".", "TextPresentation", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "text", ".", "source", ".", "Annotation", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "text", ".", "source", ".", "IAnnotationHover", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "text", ".", "source", ".", "IAnnotationModel", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "text", ".", "source", ".", "ISourceViewer", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "text", ".", "source", ".", "SourceViewerConfiguration", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "ISelectionProvider", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "custom", ".", "StyledText", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "custom", ".", "VerifyKeyListener", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Color", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Point", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Composite", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Control", ";", "import", "org", ".", "vimplugin", ".", "VimConnection", ";", "public", "class", "VimViewer", "implements", "ISourceViewer", ",", "ITextViewerExtension", "{", "private", "static", "final", "Logger", "logger", "=", "Logger", ".", "getLogger", "(", "VimViewer", ".", "class", ")", ";", "private", "int", "bufferID", ";", "private", "IDocument", "document", ";", "private", "VimText", "textWidget", ";", "private", "VimConnection", "vimConnection", ";", "public", "VimViewer", "(", "int", "bufferID", ",", "VimConnection", "vimConnection", ",", "Composite", "parent", ",", "int", "styles", ")", "{", "this", ".", "textWidget", "=", "new", "VimText", "(", "parent", ",", "styles", ")", ";", "this", ".", "bufferID", "=", "bufferID", ";", "this", ".", "vimConnection", "=", "vimConnection", ";", "}", "public", "void", "configure", "(", "SourceViewerConfiguration", "configuration", ")", "{", "}", "public", "void", "setAnnotationHover", "(", "IAnnotationHover", "annotationHover", ")", "{", "}", "public", "void", "setDocument", "(", "IDocument", "document", ",", "IAnnotationModel", "annotationModel", ")", "{", "setDocument", "(", "document", ")", ";", "}", "public", "void", "setDocument", "(", "IDocument", "document", ",", "IAnnotationModel", "annotationModel", ",", "int", "modelRangeOffset", ",", "int", "modelRangeLength", ")", "{", "setDocument", "(", "document", ",", "modelRangeOffset", ",", "modelRangeLength", ")", ";", "}", "public", "IAnnotationModel", "getAnnotationModel", "(", ")", "{", "return", "null", ";", "}", "public", "void", "setRangeIndicator", "(", "Annotation", "rangeIndicator", ")", "{", "}", "public", "void", "setRangeIndication", "(", "int", "offset", ",", "int", "length", ",", "boolean", "moveCursor", ")", "{", "}", "public", "IRegion", "getRangeIndication", "(", ")", "{", "return", "null", ";", "}", "public", "void", "removeRangeIndication", "(", ")", "{", "}", "public", "void", "showAnnotations", "(", "boolean", "show", ")", "{", "}", "public", "StyledText", "getTextWidget", "(", ")", "{", "return", "textWidget", ";", "}", "public", "void", "setUndoManager", "(", "IUndoManager", "manager", ")", "{", "}", "public", "void", "setTextDoubleClickStrategy", "(", "ITextDoubleClickStrategy", "strategy", ",", "String", "contentType", ")", "{", "}", "@", "SuppressWarnings", "(", "\"deprecation\"", ")", "public", "void", "setAutoIndentStrategy", "(", "org", ".", "eclipse", ".", "jface", ".", "text", ".", "IAutoIndentStrategy", "strategy", ",", "String", "contentType", ")", "{", "}", "public", "void", "setTextHover", "(", "ITextHover", "textViewerHover", ",", "String", "contentType", ")", "{", "}", "public", "void", "activatePlugins", "(", ")", "{", "}", "public", "void", "resetPlugins", "(", ")", "{", "}", "public", "void", "addViewportListener", "(", "IViewportListener", "listener", ")", "{", "}", "public", "void", "removeViewportListener", "(", "IViewportListener", "listener", ")", "{", "}", "public", "void", "addTextListener", "(", "ITextListener", "listener", ")", "{", "}", "public", "void", "removeTextListener", "(", "ITextListener", "listener", ")", "{", "}", "public", "void", "addTextInputListener", "(", "ITextInputListener", "listener", ")", "{", "}", "public", "void", "removeTextInputListener", "(", "ITextInputListener", "listener", ")", "{", "}", "public", "void", "setDocument", "(", "IDocument", "document", ")", "{", "this", ".", "document", "=", "document", ";", "}", "public", "IDocument", "getDocument", "(", ")", "{", "return", "document", ";", "}", "public", "void", "setEventConsumer", "(", "IEventConsumer", "consumer", ")", "{", "}", "public", "void", "setEditable", "(", "boolean", "editable", ")", "{", "}", "public", "boolean", "isEditable", "(", ")", "{", "return", "true", ";", "}", "public", "void", "setDocument", "(", "IDocument", "document", ",", "int", "modelRangeOffset", ",", "int", "modelRangeLength", ")", "{", "setDocument", "(", "document", ")", ";", "}", "public", "void", "setVisibleRegion", "(", "int", "offset", ",", "int", "length", ")", "{", "}", "public", "void", "resetVisibleRegion", "(", ")", "{", "}", "public", "IRegion", "getVisibleRegion", "(", ")", "{", "return", "null", ";", "}", "public", "boolean", "overlapsWithVisibleRegion", "(", "int", "offset", ",", "int", "length", ")", "{", "return", "false", ";", "}", "public", "void", "changeTextPresentation", "(", "TextPresentation", "presentation", ",", "boolean", "controlRedraw", ")", "{", "}", "public", "void", "invalidateTextPresentation", "(", ")", "{", "}", "public", "void", "setTextColor", "(", "Color", "color", ")", "{", "}", "public", "void", "setTextColor", "(", "Color", "color", ",", "int", "offset", ",", "int", "length", ",", "boolean", "controlRedraw", ")", "{", "}", "public", "ITextOperationTarget", "getTextOperationTarget", "(", ")", "{", "return", "null", ";", "}", "public", "IFindReplaceTarget", "getFindReplaceTarget", "(", ")", "{", "return", "null", ";", "}", "public", "void", "setDefaultPrefixes", "(", "String", "[", "]", "defaultPrefixes", ",", "String", "contentType", ")", "{", "}", "public", "void", "setIndentPrefixes", "(", "String", "[", "]", "indentPrefixes", ",", "String", "contentType", ")", "{", "}", "public", "void", "setSelectedRange", "(", "int", "offset", ",", "int", "length", ")", "{", "try", "{", "int", "[", "]", "pos", "=", "FileUtils", ".", "offsetToLineColumn", "(", "new", "ByteArrayInputStream", "(", "document", ".", "get", "(", ")", ".", "getBytes", "(", ")", ")", ",", "offset", ")", ";", "vimConnection", ".", "command", "(", "bufferID", ",", "\"setDot\"", ",", "\"\"", "+", "pos", "[", "0", "]", "+", "'/'", "+", "pos", "[", "1", "]", ")", ";", "vimConnection", ".", "remotesend", "(", "\"\"", ")", ";", "vimConnection", ".", "remotesend", "(", "\"\"", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "logger", ".", "error", "(", "\"\"", ",", "e", ")", ";", "}", "}", "public", "Point", "getSelectedRange", "(", ")", "{", "return", "null", ";", "}", "public", "ISelectionProvider", "getSelectionProvider", "(", ")", "{", "return", "null", ";", "}", "public", "void", "revealRange", "(", "int", "offset", ",", "int", "length", ")", "{", "}", "public", "void", "setTopIndex", "(", "int", "index", ")", "{", "}", "public", "int", "getTopIndex", "(", ")", "{", "return", "0", ";", "}", "public", "int", "getTopIndexStartOffset", "(", ")", "{", "return", "0", ";", "}", "public", "int", "getBottomIndex", "(", ")", "{", "return", "0", ";", "}", "public", "int", "getBottomIndexEndOffset", "(", ")", "{", "return", "0", ";", "}", "public", "int", "getTopInset", "(", ")", "{", "return", "0", ";", "}", "public", "void", "prependVerifyKeyListener", "(", "VerifyKeyListener", "listener", ")", "{", "}", "public", "void", "appendVerifyKeyListener", "(", "VerifyKeyListener", "listener", ")", "{", "}", "public", "void", "removeVerifyKeyListener", "(", "VerifyKeyListener", "listener", ")", "{", "}", "public", "Control", "getControl", "(", ")", "{", "return", "getTextWidget", "(", ")", ";", "}", "public", "void", "setMark", "(", "int", "arg0", ")", "{", "}", "public", "int", "getMark", "(", ")", "{", "return", "-", "1", ";", "}", "public", "void", "setRedraw", "(", "boolean", "redraw", ")", "{", "}", "public", "IRewriteTarget", "getRewriteTarget", "(", ")", "{", "return", "null", ";", "}", "}", "</s>" ]
1,413
[ "<s>", "package", "org", ".", "vimplugin", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "io", ".", "FileInputStream", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "text", ".", "MessageFormat", ";", "import", "java", ".", "util", ".", "Arrays", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "Locale", ";", "import", "java", ".", "util", ".", "Properties", ";", "import", "java", ".", "util", ".", "ResourceBundle", ";", "import", "org", ".", "apache", ".", "tools", ".", "ant", ".", "taskdefs", ".", "condition", ".", "Os", ";", "import", "org", ".", "eclim", ".", "logging", ".", "Logger", ";", "import", "org", ".", "eclim", ".", "util", ".", "CommandExecutor", ";", "import", "org", ".", "eclim", ".", "util", ".", "IOUtils", ";", "import", "org", ".", "eclim", ".", "util", ".", "StringUtils", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "Platform", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "dialogs", ".", "MessageDialog", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "resource", ".", "ImageDescriptor", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Display", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "IWorkbench", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "PlatformUI", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "plugin", ".", "AbstractUIPlugin", ";", "import", "org", ".", "osgi", ".", "framework", ".", "BundleContext", ";", "import", "org", ".", "vimplugin", ".", "editors", ".", "VimEditorPartListener", ";", "import", "org", ".", "vimplugin", ".", "preferences", ".", "PreferenceConstants", ";", "public", "class", "VimPlugin", "extends", "AbstractUIPlugin", "{", "private", "static", "final", "Logger", "logger", "=", "Logger", ".", "getLogger", "(", "VimPlugin", ".", "class", ")", ";", "private", "static", "final", "String", "GVIM_FEATURE_TEST", "=", "\"\"", ";", "private", "static", "final", "String", "FEATURES_COMMAND_UNIX", "=", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", ";", "private", "static", "final", "String", "FEATURES_COMMAND_WINDOWS", "=", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", ";", "private", "static", "VimPlugin", "plugin", ";", "public", "static", "final", "int", "DEFAULT_VIMSERVER_ID", "=", "0", ";", "private", "HashMap", "<", "String", ",", "Boolean", ">", "features", ";", "private", "VimEditorPartListener", "partListener", ";", "public", "static", "VimPlugin", "getDefault", "(", ")", "{", "return", "plugin", ";", "}", "public", "static", "ImageDescriptor", "getImageDescriptor", "(", "String", "path", ")", "{", "return", "AbstractUIPlugin", ".", "imageDescriptorFromPlugin", "(", "\"VimNB\"", ",", "path", ")", ";", "}", "private", "int", "nextServerID", ";", "private", "int", "numberOfBuffers", ";", "private", "int", "seqNo", ";", "private", "final", "HashMap", "<", "Integer", ",", "VimServer", ">", "vimServers", "=", "new", "HashMap", "<", "Integer", ",", "VimServer", ">", "(", ")", ";", "private", "Properties", "properties", ";", "private", "ResourceBundle", "messages", ";", "public", "VimPlugin", "(", ")", "{", "plugin", "=", "this", ";", "properties", "=", "new", "Properties", "(", ")", ";", "try", "{", "properties", ".", "load", "(", "getClass", "(", ")", ".", "getResourceAsStream", "(", "\"\"", ")", ")", ";", "}", "catch", "(", "IOException", "ioe", ")", "{", "MessageDialog", ".", "openError", "(", "getWorkbench", "(", ")", ".", "getActiveWorkbenchWindow", "(", ")", ".", "getShell", "(", ")", ",", "\"Vimplugin\"", ",", "\"\"", ")", ";", "ioe", ".", "printStackTrace", "(", ")", ";", "}", "messages", "=", "ResourceBundle", ".", "getBundle", "(", "\"\"", ",", "Locale", ".", "getDefault", "(", ")", ",", "getClass", "(", ")", ".", "getClassLoader", "(", ")", ")", ";", "}", "public", "int", "getDefaultVimServer", "(", ")", "{", "return", "createVimServer", "(", "DEFAULT_VIMSERVER_ID", ")", ";", "}", "public", "int", "createVimServer", "(", ")", "{", "return", "createVimServer", "(", "nextServerID", "++", ")", ";", "}", "private", "int", "createVimServer", "(", "int", "id", ")", "{", "if", "(", "!", "vimServers", ".", "containsKey", "(", "id", ")", ")", "{", "VimServer", "vimserver", "=", "new", "VimServer", "(", "id", ")", ";", "vimServers", ".", "put", "(", "id", ",", "vimserver", ")", ";", "}", "return", "id", ";", "}", "public", "boolean", "stopVimServer", "(", "int", "id", ")", "{", "boolean", "b", "=", "false", ";", "try", "{", "b", "=", "getVimserver", "(", "id", ")", ".", "stop", "(", ")", ";", "vimServers", ".", "remove", "(", "id", ")", ";", "}", "catch", "(", "IOException", "ioe", ")", "{", "MessageDialog", ".", "openError", "(", "getWorkbench", "(", ")", ".", "getActiveWorkbenchWindow", "(", ")", ".", "getShell", "(", ")", ",", "\"Vimplugin\"", ",", "\"\"", ")", ";", "ioe", ".", "printStackTrace", "(", ")", ";", "}", "return", "b", ";", "}", "public", "VimServer", "getVimserver", "(", "int", "id", ")", "{", "return", "vimServers", ".", "get", "(", "id", ")", ";", "}", "@", "Override", "public", "void", "start", "(", "BundleContext", "context", ")", "throws", "Exception", "{", "super", ".", "start", "(", "context", ")", ";", "nextServerID", "=", "1", ";", "numberOfBuffers", "=", "1", ";", "seqNo", "=", "0", ";", "partListener", "=", "new", "VimEditorPartListener", "(", ")", ";", "Display", ".", "getDefault", "(", ")", ".", "asyncExec", "(", "new", "Runnable", "(", ")", "{", "public", "void", "run", "(", ")", "{", "IWorkbench", "workbench", "=", "PlatformUI", ".", "getWorkbench", "(", ")", ";", "workbench", ".", "getActiveWorkbenchWindow", "(", ")", ".", "getActivePage", "(", ")", ".", "addPartListener", "(", "partListener", ")", ";", "}", "}", ")", ";", "}", "@", "Override", "public", "void", "stop", "(", "BundleContext", "context", ")", "throws", "Exception", "{", "super", ".", "stop", "(", "context", ")", ";", "plugin", "=", "null", ";", "if", "(", "PlatformUI", ".", "isWorkbenchRunning", "(", ")", ")", "{", "IWorkbench", "workbench", "=", "PlatformUI", ".", "getWorkbench", "(", ")", ";", "if", "(", "workbench", "!=", "null", ")", "{", "workbench", ".", "getActiveWorkbenchWindow", "(", ")", ".", "getActivePage", "(", ")", ".", "removePartListener", "(", "partListener", ")", ";", "}", "}", "}", "public", "int", "nextSeqNo", "(", ")", "{", "return", "seqNo", "++", ";", "}", "public", "void", "setNumberOfBuffers", "(", "int", "numberOfBuffers", ")", "{", "this", ".", "numberOfBuffers", "=", "numberOfBuffers", ";", "}", "public", "int", "getNumberOfBuffers", "(", ")", "{", "return", "numberOfBuffers", ";", "}", "public", "boolean", "gvimAvailable", "(", ")", "{", "String", "gvim", "=", "VimPlugin", ".", "getDefault", "(", ")", ".", "getPreferenceStore", "(", ")", ".", "getString", "(", "PreferenceConstants", ".", "P_GVIM", ")", ";", "File", "file", "=", "new", "File", "(", "gvim", ")", ";", "if", "(", "file", ".", "exists", "(", ")", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}", "public", "boolean", "gvimEmbedSupported", "(", ")", "{", "return", "hasFeature", "(", "\"embed\"", ")", ";", "}", "public", "boolean", "gvimNbSupported", "(", ")", "{", "return", "hasFeature", "(", "\"netbeans\"", ")", ";", "}", "public", "boolean", "gvimNbDocumentListenSupported", "(", ")", "{", "return", "hasFeature", "(", "\"\"", ")", ";", "}", "public", "void", "resetGvimState", "(", ")", "{", "features", "=", "null", ";", "}", "public", "VimEditorPartListener", "getPartListener", "(", ")", "{", "return", "this", ".", "partListener", ";", "}", "private", "boolean", "hasFeature", "(", "String", "name", ")", "{", "if", "(", "features", "==", "null", ")", "{", "String", "gvim", "=", "VimPlugin", ".", "getDefault", "(", ")", ".", "getPreferenceStore", "(", ")", ".", "getString", "(", "PreferenceConstants", ".", "P_GVIM", ")", ";", "try", "{", "File", "tempFile", "=", "File", ".", "createTempFile", "(", "\"eclim_gvim\"", ",", "null", ")", ";", "tempFile", ".", "deleteOnExit", "(", ")", ";", "String", "command", "=", "FEATURES_COMMAND_UNIX", ";", "if", "(", "Platform", ".", "getOS", "(", ")", ".", "equals", "(", "Platform", ".", "OS_WIN32", ")", ")", "{", "command", "=", "FEATURES_COMMAND_WINDOWS", ";", "}", "command", "=", "GVIM_FEATURE_TEST", ".", "replaceFirst", "(", "\"<command>\"", ",", "command", ")", ";", "command", "=", "command", ".", "replaceFirst", "(", "\"<file>\"", ",", "tempFile", ".", "getAbsolutePath", "(", ")", ".", "replace", "(", "'\\\\'", ",", "'/'", ")", ".", "replaceAll", "(", "\"", "\"", ",", "\"\\\\", "\"", ")", ")", ";", "String", "[", "]", "cmd", "=", "{", "gvim", ",", "\"-f\"", ",", "\"-X\"", ",", "\"-u\"", ",", "\"NONE\"", ",", "\"-U\"", ",", "\"NONE\"", ",", "\"--cmd\"", ",", "command", "}", ";", "logger", ".", "debug", "(", "Arrays", ".", "toString", "(", "cmd", ")", ")", ";", "CommandExecutor", "process", "=", "CommandExecutor", ".", "execute", "(", "cmd", ",", "5000", ")", ";", "if", "(", "process", ".", "getReturnCode", "(", ")", "!=", "0", ")", "{", "logger", ".", "error", "(", "\"\"", "+", "process", ".", "getErrorMessage", "(", ")", ")", ";", "return", "false", ";", "}", "FileInputStream", "in", "=", "null", ";", "try", "{", "String", "result", "=", "IOUtils", ".", "toString", "(", "in", "=", "new", "FileInputStream", "(", "tempFile", ")", ")", ";", "result", "=", "result", ".", "trim", "(", ")", ";", "logger", ".", "debug", "(", "\"\"", "+", "result", ")", ";", "features", "=", "new", "HashMap", "<", "String", ",", "Boolean", ">", "(", ")", ";", "for", "(", "String", "f", ":", "StringUtils", ".", "split", "(", "result", ")", ")", "{", "String", "[", "]", "keyVal", "=", "StringUtils", ".", "split", "(", "f", ",", "\":\"", ")", ";", "if", "(", "keyVal", ".", "length", "!=", "2", ")", "{", "logger", ".", "error", "(", "\"\"", "+", "result", ")", ";", "return", "false", ";", "}", "features", ".", "put", "(", "keyVal", "[", "0", "]", ",", "Boolean", ".", "valueOf", "(", "keyVal", "[", "1", "]", ".", "equals", "(", "\"1\"", ")", ")", ")", ";", "}", "}", "catch", "(", "IOException", "ioe", ")", "{", "logger", ".", "error", "(", "\"\"", ",", "ioe", ")", ";", "IOUtils", ".", "closeQuietly", "(", "in", ")", ";", "return", "false", ";", "}", "finally", "{", "IOUtils", ".", "closeQuietly", "(", "in", ")", ";", "try", "{", "tempFile", ".", "delete", "(", ")", ";", "}", "catch", "(", "Exception", "ignore", ")", "{", "}", "}", "}", "catch", "(", "Exception", "e", ")", "{", "logger", ".", "error", "(", "\"\"", ",", "e", ")", ";", "return", "false", ";", "}", "}", "return", "features", ".", "containsKey", "(", "name", ")", "&&", "features", ".", "get", "(", "name", ")", ".", "booleanValue", "(", ")", ";", "}", "public", "String", "getProperty", "(", "String", "name", ")", "{", "return", "properties", ".", "getProperty", "(", "name", ")", ";", "}", "public", "String", "getProperty", "(", "String", "name", ",", "String", "def", ")", "{", "return", "properties", ".", "getProperty", "(", "name", ",", "def", ")", ";", "}", "public", "String", "getMessage", "(", "String", "key", ",", "Object", "...", "args", ")", "{", "String", "message", "=", "messages", ".", "getString", "(", "key", ")", ";", "if", "(", "Os", ".", "isFamily", "(", "Os", ".", "FAMILY_MAC", ")", ")", "{", "message", "=", "message", ".", "replaceAll", "(", "\"\\\\bgvim\\\\b\"", ",", "\"mvim/gvim\"", ")", ";", "}", "if", "(", "args", "!=", "null", "&&", "args", ".", "length", ">", "0", ")", "{", "return", "MessageFormat", ".", "format", "(", "message", ",", "args", ")", ";", "}", "return", "message", ";", "}", "}", "</s>" ]
1,414
[ "<s>", "package", "org", ".", "vimplugin", ";", "public", "class", "VimException", "extends", "Exception", "{", "private", "static", "final", "long", "serialVersionUID", "=", "1L", ";", "public", "VimException", "(", "String", "message", ")", "{", "super", "(", "message", ")", ";", "}", "public", "VimException", "(", "String", "message", ",", "Exception", "cause", ")", "{", "super", "(", "message", ",", "cause", ")", ";", "}", "}", "</s>" ]
1,415
[ "<s>", "package", "org", ".", "vimplugin", ".", "preferences", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "preferences", ".", "AbstractPreferenceInitializer", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "preference", ".", "IPreferenceStore", ";", "import", "org", ".", "vimplugin", ".", "VimPlugin", ";", "public", "class", "PreferenceInitializer", "extends", "AbstractPreferenceInitializer", "{", "@", "Override", "public", "void", "initializeDefaultPreferences", "(", ")", "{", "VimPlugin", "plugin", "=", "VimPlugin", ".", "getDefault", "(", ")", ";", "IPreferenceStore", "store", "=", "plugin", ".", "getPreferenceStore", "(", ")", ";", "store", ".", "setDefault", "(", "PreferenceConstants", ".", "P_PORT", ",", "3219", ")", ";", "store", ".", "setDefault", "(", "PreferenceConstants", ".", "P_EMBED", ",", "\"true\"", ".", "equals", "(", "plugin", ".", "getProperty", "(", "\"\"", ")", ")", ")", ";", "store", ".", "setDefault", "(", "PreferenceConstants", ".", "P_TABBED", ",", "true", ")", ";", "store", ".", "setDefault", "(", "PreferenceConstants", ".", "P_FOCUS_AUTO_CLICK", ",", "true", ")", ";", "store", ".", "setDefault", "(", "PreferenceConstants", ".", "P_START_ECLIMD", ",", "true", ")", ";", "store", ".", "setDefault", "(", "PreferenceConstants", ".", "P_GVIM", ",", "plugin", ".", "getProperty", "(", "\"gvim.default\"", ")", ")", ";", "}", "}", "</s>" ]
1,416
[ "<s>", "package", "org", ".", "vimplugin", ".", "preferences", ";", "public", "class", "PreferenceConstants", "{", "public", "static", "final", "String", "P_PORT", "=", "\"port\"", ";", "public", "static", "final", "String", "P_GVIM", "=", "\"gvim\"", ";", "public", "static", "final", "String", "P_OPTS", "=", "\"opts\"", ";", "public", "static", "final", "String", "P_EMBED", "=", "\"embedded\"", ";", "public", "static", "final", "String", "P_TABBED", "=", "\"tabbed\"", ";", "public", "static", "final", "String", "P_FOCUS_AUTO_CLICK", "=", "\"focus.click\"", ";", "public", "static", "final", "String", "P_START_ECLIMD", "=", "\"eclimd.start\"", ";", "}", "</s>" ]
1,417
[ "<s>", "package", "org", ".", "vimplugin", ".", "preferences", ";", "import", "org", ".", "apache", ".", "tools", ".", "ant", ".", "taskdefs", ".", "condition", ".", "Os", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "preference", ".", "BooleanFieldEditor", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "preference", ".", "FieldEditorPreferencePage", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "preference", ".", "FileFieldEditor", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "preference", ".", "StringFieldEditor", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "IWorkbench", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "IWorkbenchPreferencePage", ";", "import", "org", ".", "vimplugin", ".", "VimPlugin", ";", "public", "class", "VimPreferences", "extends", "FieldEditorPreferencePage", "implements", "IWorkbenchPreferencePage", "{", "public", "VimPreferences", "(", ")", "{", "super", "(", "FieldEditorPreferencePage", ".", "GRID", ")", ";", "VimPlugin", "plugin", "=", "VimPlugin", ".", "getDefault", "(", ")", ";", "setPreferenceStore", "(", "plugin", ".", "getPreferenceStore", "(", ")", ")", ";", "setDescription", "(", "plugin", ".", "getMessage", "(", "\"\"", ")", ")", ";", "}", "@", "Override", "public", "void", "createFieldEditors", "(", ")", "{", "VimPlugin", "plugin", "=", "VimPlugin", ".", "getDefault", "(", ")", ";", "if", "(", "!", "Os", ".", "isFamily", "(", "Os", ".", "FAMILY_MAC", ")", ")", "{", "addField", "(", "new", "BooleanFieldEditor", "(", "PreferenceConstants", ".", "P_EMBED", ",", "plugin", ".", "getMessage", "(", "\"\"", ")", ",", "getFieldEditorParent", "(", ")", ")", ")", ";", "}", "addField", "(", "new", "BooleanFieldEditor", "(", "PreferenceConstants", ".", "P_TABBED", ",", "plugin", ".", "getMessage", "(", "\"\"", ")", ",", "getFieldEditorParent", "(", ")", ")", ")", ";", "addField", "(", "new", "BooleanFieldEditor", "(", "PreferenceConstants", ".", "P_START_ECLIMD", ",", "plugin", ".", "getMessage", "(", "\"\"", ")", ",", "getFieldEditorParent", "(", ")", ")", ")", ";", "addField", "(", "new", "BooleanFieldEditor", "(", "PreferenceConstants", ".", "P_FOCUS_AUTO_CLICK", ",", "plugin", ".", "getMessage", "(", "\"\"", ")", ",", "getFieldEditorParent", "(", ")", ")", ")", ";", "addField", "(", "new", "StringFieldEditor", "(", "PreferenceConstants", ".", "P_PORT", ",", "plugin", ".", "getMessage", "(", "\"\"", ")", ",", "getFieldEditorParent", "(", ")", ")", ")", ";", "addField", "(", "new", "FileFieldEditor", "(", "PreferenceConstants", ".", "P_GVIM", ",", "plugin", ".", "getMessage", "(", "\"\"", ")", ",", "true", ",", "getFieldEditorParent", "(", ")", ")", ")", ";", "addField", "(", "new", "StringFieldEditor", "(", "PreferenceConstants", ".", "P_OPTS", ",", "plugin", ".", "getMessage", "(", "\"\"", ")", ",", "getFieldEditorParent", "(", ")", ")", ")", ";", "}", "public", "void", "init", "(", "IWorkbench", "workbench", ")", "{", "}", "public", "boolean", "performOk", "(", ")", "{", "boolean", "result", "=", "super", ".", "performOk", "(", ")", ";", "VimPlugin", ".", "getDefault", "(", ")", ".", "resetGvimState", "(", ")", ";", "return", "result", ";", "}", "}", "</s>" ]
1,418
[ "<s>", "package", "org", ".", "vimplugin", ".", "views", ";", "import", "java", ".", "io", ".", "BufferedReader", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "io", ".", "InputStream", ";", "import", "java", ".", "io", ".", "InputStreamReader", ";", "import", "java", ".", "util", ".", "Arrays", ";", "import", "org", ".", "eclim", ".", "logging", ".", "Logger", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "SWT", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Composite", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Event", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Listener", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Text", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "part", ".", "ViewPart", ";", "import", "org", ".", "vimplugin", ".", "VimPlugin", ";", "public", "class", "CommandView", "extends", "ViewPart", "{", "private", "static", "final", "Logger", "logger", "=", "Logger", ".", "getLogger", "(", "CommandView", ".", "class", ")", ";", "private", "Text", "input", ";", "@", "Override", "public", "void", "createPartControl", "(", "Composite", "parent", ")", "{", "input", "=", "new", "Text", "(", "parent", ",", "SWT", ".", "MULTI", ")", ";", "input", ".", "addListener", "(", "SWT", ".", "KeyDown", ",", "new", "Listener", "(", ")", "{", "public", "void", "handleEvent", "(", "Event", "e", ")", "{", "if", "(", "e", ".", "character", "==", "0x0D", ")", "{", "String", "line1", "=", "input", ".", "getText", "(", ")", ".", "substring", "(", "3", ")", ";", "if", "(", "input", ".", "getText", "(", ")", ".", "startsWith", "(", "\"vr:\"", ")", ")", "{", "String", "[", "]", "args", "=", "{", "\"vim\"", ",", "\"--servername\"", ",", "\"GVIM\"", ",", "\"\"", ",", "line1", "}", ";", "try", "{", "logger", ".", "debug", "(", "\"running:", "\"", "+", "Arrays", ".", "toString", "(", "args", ")", ")", ";", "Process", "process", "=", "new", "ProcessBuilder", "(", "args", ")", ".", "start", "(", ")", ";", "InputStream", "is", "=", "process", ".", "getInputStream", "(", ")", ";", "InputStreamReader", "isr", "=", "new", "InputStreamReader", "(", "is", ")", ";", "BufferedReader", "br", "=", "new", "BufferedReader", "(", "isr", ")", ";", "String", "line", ";", "while", "(", "(", "line", "=", "br", ".", "readLine", "(", ")", ")", "!=", "null", ")", "{", "logger", ".", "debug", "(", "line", ")", ";", "}", "process", ".", "waitFor", "(", ")", ";", "logger", ".", "debug", "(", "\"result:", "\"", "+", "process", ".", "exitValue", "(", ")", ")", ";", "}", "catch", "(", "IOException", "ioe", ")", "{", "logger", ".", "error", "(", "\"\"", ",", "ioe", ")", ";", "}", "catch", "(", "InterruptedException", "ie", ")", "{", "logger", ".", "error", "(", "\"\"", ",", "ie", ")", ";", "}", "}", "else", "if", "(", "input", ".", "getText", "(", ")", ".", "startsWith", "(", "\"nb:\"", ")", ")", "{", "VimPlugin", ".", "getDefault", "(", ")", ".", "getVimserver", "(", "0", ")", ".", "getVc", "(", ")", ".", "plain", "(", "line1", ")", ";", "}", "input", ".", "setText", "(", "\"\"", ")", ";", "}", "}", "}", ")", ";", "}", "@", "Override", "public", "void", "setFocus", "(", ")", "{", "input", ".", "setFocus", "(", ")", ";", "}", "}", "</s>" ]
1,419
[ "<s>", "package", "org", ".", "vimplugin", ";", "import", "org", ".", "eclim", ".", "logging", ".", "Logger", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "SWT", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Point", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Display", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Event", ";", "public", "class", "DisplayUtils", "{", "private", "static", "final", "Logger", "logger", "=", "Logger", ".", "getLogger", "(", "DisplayUtils", ".", "class", ")", ";", "public", "static", "void", "doClick", "(", "final", "Display", "display", ",", "final", "int", "x", ",", "final", "int", "y", ",", "boolean", "restore", ")", "{", "final", "int", "[", "]", "orig", "=", "{", "0", ",", "0", "}", ";", "if", "(", "restore", ")", "{", "display", ".", "syncExec", "(", "new", "Runnable", "(", ")", "{", "public", "void", "run", "(", ")", "{", "Point", "point", "=", "display", ".", "getCursorLocation", "(", ")", ";", "orig", "[", "0", "]", "=", "point", ".", "x", ";", "orig", "[", "1", "]", "=", "point", ".", "y", ";", "}", "}", ")", ";", "}", "Event", "event", "=", "new", "Event", "(", ")", ";", "event", ".", "x", "=", "x", ";", "event", ".", "y", "=", "y", ";", "event", ".", "type", "=", "SWT", ".", "MouseMove", ";", "post", "(", "display", ",", "event", ")", ";", "final", "boolean", "[", "]", "moved", "=", "{", "false", "}", ";", "Thread", "check", "=", "new", "Thread", "(", ")", "{", "public", "void", "run", "(", ")", "{", "final", "int", "[", "]", "cursor", "=", "{", "0", ",", "0", "}", ";", "while", "(", "!", "isInterrupted", "(", ")", "&&", "cursor", "[", "0", "]", "!=", "x", "||", "cursor", "[", "1", "]", "!=", "y", ")", "{", "display", ".", "syncExec", "(", "new", "Runnable", "(", ")", "{", "public", "void", "run", "(", ")", "{", "Point", "point", "=", "display", ".", "getCursorLocation", "(", ")", ";", "cursor", "[", "0", "]", "=", "point", ".", "x", ";", "cursor", "[", "1", "]", "=", "point", ".", "y", ";", "if", "(", "point", ".", "x", "==", "x", "&&", "point", ".", "y", "==", "y", ")", "{", "moved", "[", "0", "]", "=", "true", ";", "}", "}", "}", ")", ";", "try", "{", "Thread", ".", "sleep", "(", "25", ")", ";", "}", "catch", "(", "InterruptedException", "ie", ")", "{", "break", ";", "}", "}", "}", "}", ";", "check", ".", "start", "(", ")", ";", "try", "{", "check", ".", "join", "(", "2000", ")", ";", "check", ".", "interrupt", "(", ")", ";", "}", "catch", "(", "InterruptedException", "ie", ")", "{", "logger", ".", "debug", "(", "\"\"", ",", "ie", ")", ";", "}", "if", "(", "moved", "[", "0", "]", ")", "{", "event", "=", "new", "Event", "(", ")", ";", "event", ".", "button", "=", "1", ";", "event", ".", "type", "=", "SWT", ".", "MouseDown", ";", "post", "(", "display", ",", "event", ")", ";", "event", ".", "type", "=", "SWT", ".", "MouseUp", ";", "post", "(", "display", ",", "event", ")", ";", "}", "if", "(", "restore", ")", "{", "event", "=", "new", "Event", "(", ")", ";", "event", ".", "x", "=", "orig", "[", "0", "]", ";", "event", ".", "y", "=", "orig", "[", "1", "]", ";", "event", ".", "type", "=", "SWT", ".", "MouseMove", ";", "post", "(", "display", ",", "event", ")", ";", "}", "}", "public", "static", "void", "doKeypress", "(", "Display", "display", ",", "int", "key", ",", "int", "...", "modifiers", ")", "{", "for", "(", "int", "modifier", ":", "modifiers", ")", "{", "Event", "event", "=", "new", "Event", "(", ")", ";", "event", ".", "type", "=", "SWT", ".", "KeyDown", ";", "event", ".", "keyCode", "=", "modifier", ";", "post", "(", "display", ",", "event", ")", ";", "}", "Event", "event", "=", "new", "Event", "(", ")", ";", "event", ".", "keyCode", "=", "key", ";", "event", ".", "type", "=", "SWT", ".", "KeyDown", ";", "post", "(", "display", ",", "event", ")", ";", "event", ".", "type", "=", "SWT", ".", "KeyUp", ";", "post", "(", "display", ",", "event", ")", ";", "for", "(", "int", "modifier", ":", "modifiers", ")", "{", "event", "=", "new", "Event", "(", ")", ";", "event", ".", "type", "=", "SWT", ".", "KeyUp", ";", "event", ".", "keyCode", "=", "modifier", ";", "post", "(", "display", ",", "event", ")", ";", "}", "}", "public", "static", "void", "doKeypress", "(", "Display", "display", ",", "char", "key", ",", "int", "...", "modifiers", ")", "{", "for", "(", "int", "modifier", ":", "modifiers", ")", "{", "Event", "event", "=", "new", "Event", "(", ")", ";", "event", ".", "type", "=", "SWT", ".", "KeyDown", ";", "event", ".", "keyCode", "=", "modifier", ";", "post", "(", "display", ",", "event", ")", ";", "}", "Event", "event", "=", "new", "Event", "(", ")", ";", "event", ".", "character", "=", "key", ";", "event", ".", "type", "=", "SWT", ".", "KeyDown", ";", "post", "(", "display", ",", "event", ")", ";", "event", ".", "type", "=", "SWT", ".", "KeyUp", ";", "post", "(", "display", ",", "event", ")", ";", "for", "(", "int", "modifier", ":", "modifiers", ")", "{", "event", "=", "new", "Event", "(", ")", ";", "event", ".", "type", "=", "SWT", ".", "KeyUp", ";", "event", ".", "keyCode", "=", "modifier", ";", "post", "(", "display", ",", "event", ")", ";", "}", "}", "private", "static", "void", "post", "(", "Display", "display", ",", "Event", "event", ")", "{", "if", "(", "!", "display", ".", "post", "(", "event", ")", ")", "{", "throw", "new", "RuntimeException", "(", "\"\"", ")", ";", "}", "}", "}", "</s>" ]
1,420
[ "<s>", "package", "org", ".", "vimplugin", ".", "actions", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "action", ".", "Action", ";", "public", "class", "UndoAction", "extends", "Action", "{", "public", "UndoAction", "(", ")", "{", "super", "(", ")", ";", "update", "(", ")", ";", "}", "public", "void", "run", "(", ")", "{", "}", "public", "void", "update", "(", ")", "{", "setEnabled", "(", "true", ")", ";", "}", "}", "</s>" ]
1,421
[ "<s>", "package", "org", ".", "vimplugin", ".", "actions", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "action", ".", "Action", ";", "public", "class", "PasteAction", "extends", "Action", "{", "public", "PasteAction", "(", ")", "{", "super", "(", ")", ";", "update", "(", ")", ";", "}", "public", "void", "run", "(", ")", "{", "}", "public", "void", "update", "(", ")", "{", "setEnabled", "(", "true", ")", ";", "}", "}", "</s>" ]
1,422
[ "<s>", "package", "org", ".", "vimplugin", ".", "actions", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "action", ".", "Action", ";", "public", "class", "CopyAction", "extends", "Action", "{", "public", "CopyAction", "(", ")", "{", "super", "(", ")", ";", "update", "(", ")", ";", "}", "public", "void", "run", "(", ")", "{", "}", "public", "void", "update", "(", ")", "{", "setEnabled", "(", "true", ")", ";", "}", "}", "</s>" ]
1,423
[ "<s>", "package", "org", ".", "vimplugin", ".", "actions", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "action", ".", "Action", ";", "public", "class", "RedoAction", "extends", "Action", "{", "public", "RedoAction", "(", ")", "{", "super", "(", ")", ";", "update", "(", ")", ";", "}", "public", "void", "run", "(", ")", "{", "}", "public", "void", "update", "(", ")", "{", "setEnabled", "(", "true", ")", ";", "}", "}", "</s>" ]
1,424
[ "<s>", "package", "org", ".", "vimplugin", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "action", ".", "*", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "*", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "part", ".", "EditorActionBarContributor", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "actions", ".", "ActionFactory", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "texteditor", ".", "*", ";", "import", "org", ".", "vimplugin", ".", "actions", ".", "*", ";", "public", "class", "VimActionContributor", "extends", "EditorActionBarContributor", "{", "protected", "RetargetTextEditorAction", "fContentAssistProposal", ";", "protected", "RetargetTextEditorAction", "fContentAssistTip", ";", "public", "VimActionContributor", "(", ")", "{", "super", "(", ")", ";", "}", "public", "void", "init", "(", "IActionBars", "bars", ")", "{", "super", ".", "init", "(", "bars", ")", ";", "IMenuManager", "menuManager", "=", "bars", ".", "getMenuManager", "(", ")", ";", "IMenuManager", "editMenu", "=", "menuManager", ".", "findMenuUsingPath", "(", "IWorkbenchActionConstants", ".", "M_EDIT", ")", ";", "if", "(", "editMenu", "!=", "null", ")", "{", "editMenu", ".", "add", "(", "new", "Separator", "(", ")", ")", ";", "}", "IActionBars", "actionBars", "=", "getActionBars", "(", ")", ";", "actionBars", ".", "setGlobalActionHandler", "(", "ActionFactory", ".", "DELETE", ".", "getId", "(", ")", ",", "new", "UndoAction", "(", ")", ")", ";", "actionBars", ".", "setGlobalActionHandler", "(", "ActionFactory", ".", "UNDO", ".", "getId", "(", ")", ",", "new", "UndoAction", "(", ")", ")", ";", "actionBars", ".", "setGlobalActionHandler", "(", "ActionFactory", ".", "REDO", ".", "getId", "(", ")", ",", "new", "RedoAction", "(", ")", ")", ";", "actionBars", ".", "setGlobalActionHandler", "(", "ActionFactory", ".", "COPY", ".", "getId", "(", ")", ",", "new", "CopyAction", "(", ")", ")", ";", "actionBars", ".", "setGlobalActionHandler", "(", "ActionFactory", ".", "PASTE", ".", "getId", "(", ")", ",", "new", "PasteAction", "(", ")", ")", ";", "actionBars", ".", "setGlobalActionHandler", "(", "ActionFactory", ".", "SELECT_ALL", ".", "getId", "(", ")", ",", "new", "UndoAction", "(", ")", ")", ";", "}", "private", "void", "doSetActiveEditor", "(", "IEditorPart", "part", ")", "{", "super", ".", "setActiveEditor", "(", "part", ")", ";", "}", "public", "void", "setActiveEditor", "(", "IEditorPart", "part", ")", "{", "doSetActiveEditor", "(", "part", ")", ";", "}", "public", "void", "dispose", "(", ")", "{", "doSetActiveEditor", "(", "null", ")", ";", "super", ".", "dispose", "(", ")", ";", "}", "}", "</s>" ]
1,425
[ "<s>", "package", "com", ".", "martiansoftware", ".", "nailgun", ";", "import", "java", ".", "util", ".", "Properties", ";", "public", "class", "NGConstants", "{", "public", "static", "final", "int", "DEFAULT_PORT", "=", "2113", ";", "public", "static", "final", "int", "EXIT_EXCEPTION", "=", "899", ";", "public", "static", "final", "int", "EXIT_NOSUCHCOMMAND", "=", "898", ";", "public", "static", "final", "char", "CHUNKTYPE_ARGUMENT", "=", "'A'", ";", "public", "static", "final", "char", "CHUNKTYPE_ENVIRONMENT", "=", "'E'", ";", "public", "static", "final", "char", "CHUNKTYPE_COMMAND", "=", "'C'", ";", "public", "static", "final", "char", "CHUNKTYPE_WORKINGDIRECTORY", "=", "'D'", ";", "public", "static", "final", "char", "CHUNKTYPE_KEEP_ALIVE", "=", "'K'", ";", "public", "static", "final", "char", "CHUNKTYPE_BYE", "=", "'B'", ";", "public", "static", "final", "char", "CHUNKTYPE_STDIN", "=", "'0'", ";", "public", "static", "final", "char", "CHUNKTYPE_STDIN_EOF", "=", "'.'", ";", "public", "static", "final", "char", "CHUNKTYPE_STDOUT", "=", "'1'", ";", "public", "static", "final", "char", "CHUNKTYPE_STDERR", "=", "'2'", ";", "public", "static", "final", "char", "CHUNKTYPE_EXIT", "=", "'X'", ";", "public", "static", "final", "String", "VERSION", ";", "static", "{", "Properties", "props", "=", "new", "Properties", "(", ")", ";", "try", "{", "props", ".", "load", "(", "NGConstants", ".", "class", ".", "getClassLoader", "(", ")", ".", "getResourceAsStream", "(", "\"\"", ")", ")", ";", "}", "catch", "(", "java", ".", "io", ".", "IOException", "e", ")", "{", "System", ".", "err", ".", "println", "(", "\"\"", ")", ";", "}", "VERSION", "=", "props", ".", "getProperty", "(", "\"version\"", ",", "\"UNKNOWN\"", ")", ";", "}", "}", "</s>" ]
1,426
[ "<s>", "package", "com", ".", "martiansoftware", ".", "nailgun", ";", "import", "java", ".", "io", ".", "InputStream", ";", "import", "java", ".", "io", ".", "PrintStream", ";", "import", "java", ".", "lang", ".", "reflect", ".", "Method", ";", "import", "java", ".", "net", ".", "InetAddress", ";", "import", "java", ".", "net", ".", "ServerSocket", ";", "import", "java", ".", "net", ".", "Socket", ";", "import", "java", ".", "net", ".", "UnknownHostException", ";", "import", "java", ".", "util", ".", "Iterator", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "com", ".", "martiansoftware", ".", "nailgun", ".", "builtins", ".", "DefaultNail", ";", "@", "SuppressWarnings", "(", "{", "\"rawtypes\"", ",", "\"unchecked\"", "}", ")", "public", "class", "NGServer", "implements", "Runnable", "{", "private", "InetAddress", "addr", "=", "null", ";", "private", "int", "port", "=", "0", ";", "private", "ClassLoader", "classLoader", ";", "private", "boolean", "captureSystemStreams", "=", "true", ";", "private", "boolean", "capturedSystemStreams", "=", "false", ";", "private", "ServerSocket", "serversocket", ";", "private", "boolean", "shutdown", "=", "false", ";", "private", "boolean", "running", "=", "false", ";", "private", "AliasManager", "aliasManager", ";", "private", "boolean", "allowNailsByClassName", "=", "true", ";", "private", "Class", "defaultNailClass", "=", "null", ";", "private", "NGSessionPool", "sessionPool", "=", "null", ";", "public", "final", "PrintStream", "out", "=", "System", ".", "out", ";", "public", "final", "PrintStream", "err", "=", "System", ".", "err", ";", "public", "final", "InputStream", "in", "=", "System", ".", "in", ";", "private", "Map", "allNailStats", "=", "null", ";", "private", "SecurityManager", "originalSecurityManager", "=", "null", ";", "public", "NGServer", "(", "InetAddress", "addr", ",", "int", "port", ",", "ClassLoader", "classloader", ")", "{", "init", "(", "addr", ",", "port", ",", "classloader", ")", ";", "}", "public", "NGServer", "(", ")", "{", "init", "(", "null", ",", "NGConstants", ".", "DEFAULT_PORT", ",", "null", ")", ";", "}", "private", "void", "init", "(", "InetAddress", "addr", ",", "int", "port", ",", "ClassLoader", "classLoader", ")", "{", "this", ".", "addr", "=", "addr", ";", "this", ".", "port", "=", "port", ";", "this", ".", "classLoader", "=", "classLoader", ";", "this", ".", "aliasManager", "=", "new", "AliasManager", "(", ")", ";", "allNailStats", "=", "new", "java", ".", "util", ".", "HashMap", "(", ")", ";", "sessionPool", "=", "new", "NGSessionPool", "(", "this", ",", "10", ")", ";", "}", "public", "ClassLoader", "getClassLoader", "(", ")", "{", "return", "this", ".", "classLoader", "!=", "null", "?", "this", ".", "classLoader", ":", "this", ".", "getClass", "(", ")", ".", "getClassLoader", "(", ")", ";", "}", "public", "void", "setAllowNailsByClassName", "(", "boolean", "allowNailsByClassName", ")", "{", "this", ".", "allowNailsByClassName", "=", "allowNailsByClassName", ";", "}", "public", "boolean", "allowsNailsByClassName", "(", ")", "{", "return", "(", "allowNailsByClassName", ")", ";", "}", "public", "void", "setDefaultNailClass", "(", "Class", "defaultNailClass", ")", "{", "this", ".", "defaultNailClass", "=", "defaultNailClass", ";", "}", "public", "Class", "getDefaultNailClass", "(", ")", "{", "return", "(", "(", "defaultNailClass", "==", "null", ")", "?", "DefaultNail", ".", "class", ":", "defaultNailClass", ")", ";", "}", "public", "void", "setCaptureSystemStreams", "(", "boolean", "captureSystemStreams", ")", "{", "this", ".", "captureSystemStreams", "=", "captureSystemStreams", ";", "}", "public", "boolean", "hasCapturedSystemStreams", "(", ")", "{", "return", "capturedSystemStreams", ";", "}", "private", "NailStats", "getOrCreateStatsFor", "(", "Class", "nailClass", ")", "{", "NailStats", "result", "=", "null", ";", "synchronized", "(", "allNailStats", ")", "{", "result", "=", "(", "NailStats", ")", "allNailStats", ".", "get", "(", "nailClass", ")", ";", "if", "(", "result", "==", "null", ")", "{", "result", "=", "new", "NailStats", "(", "nailClass", ")", ";", "allNailStats", ".", "put", "(", "nailClass", ",", "result", ")", ";", "}", "}", "return", "(", "result", ")", ";", "}", "void", "nailStarted", "(", "Class", "nailClass", ")", "{", "NailStats", "stats", "=", "getOrCreateStatsFor", "(", "nailClass", ")", ";", "stats", ".", "nailStarted", "(", ")", ";", "}", "void", "nailFinished", "(", "Class", "nailClass", ")", "{", "NailStats", "stats", "=", "(", "NailStats", ")", "allNailStats", ".", "get", "(", "nailClass", ")", ";", "stats", ".", "nailFinished", "(", ")", ";", "}", "public", "Map", "getNailStats", "(", ")", "{", "Map", "result", "=", "new", "java", ".", "util", ".", "TreeMap", "(", ")", ";", "synchronized", "(", "allNailStats", ")", "{", "for", "(", "Iterator", "i", "=", "allNailStats", ".", "keySet", "(", ")", ".", "iterator", "(", ")", ";", "i", ".", "hasNext", "(", ")", ";", ")", "{", "Class", "nailclass", "=", "(", "Class", ")", "i", ".", "next", "(", ")", ";", "result", ".", "put", "(", "nailclass", ".", "getName", "(", ")", ",", "(", "(", "NailStats", ")", "allNailStats", ".", "get", "(", "nailclass", ")", ")", ".", "clone", "(", ")", ")", ";", "}", "}", "return", "(", "result", ")", ";", "}", "public", "AliasManager", "getAliasManager", "(", ")", "{", "return", "(", "aliasManager", ")", ";", "}", "public", "void", "shutdown", "(", "boolean", "exitVM", ")", "{", "synchronized", "(", "this", ")", "{", "if", "(", "shutdown", ")", "return", ";", "shutdown", "=", "true", ";", "}", "try", "{", "serversocket", ".", "close", "(", ")", ";", "}", "catch", "(", "Throwable", "toDiscard", ")", "{", "}", "sessionPool", ".", "shutdown", "(", ")", ";", "Class", "[", "]", "argTypes", "=", "new", "Class", "[", "1", "]", ";", "argTypes", "[", "0", "]", "=", "NGServer", ".", "class", ";", "Object", "[", "]", "argValues", "=", "new", "Object", "[", "1", "]", ";", "argValues", "[", "0", "]", "=", "this", ";", "for", "(", "Iterator", "i", "=", "getAliasManager", "(", ")", ".", "getAliases", "(", ")", ".", "iterator", "(", ")", ";", "i", ".", "hasNext", "(", ")", ";", ")", "{", "Alias", "alias", "=", "(", "Alias", ")", "i", ".", "next", "(", ")", ";", "getOrCreateStatsFor", "(", "alias", ".", "getAliasedClass", "(", ")", ")", ";", "}", "synchronized", "(", "allNailStats", ")", "{", "for", "(", "Iterator", "i", "=", "allNailStats", ".", "values", "(", ")", ".", "iterator", "(", ")", ";", "i", ".", "hasNext", "(", ")", ";", ")", "{", "NailStats", "ns", "=", "(", "NailStats", ")", "i", ".", "next", "(", ")", ";", "Class", "nailClass", "=", "ns", ".", "getNailClass", "(", ")", ";", "try", "{", "Method", "nailShutdown", "=", "nailClass", ".", "getMethod", "(", "\"nailShutdown\"", ",", "argTypes", ")", ";", "nailShutdown", ".", "invoke", "(", "null", ",", "argValues", ")", ";", "}", "catch", "(", "Throwable", "toDiscard", ")", "{", "}", "}", "}", "if", "(", "hasCapturedSystemStreams", "(", ")", ")", "{", "System", ".", "setIn", "(", "in", ")", ";", "System", ".", "setOut", "(", "out", ")", ";", "System", ".", "setErr", "(", "err", ")", ";", "}", "System", ".", "setSecurityManager", "(", "originalSecurityManager", ")", ";", "if", "(", "exitVM", ")", "{", "System", ".", "exit", "(", "0", ")", ";", "}", "}", "public", "boolean", "isRunning", "(", ")", "{", "return", "(", "running", ")", ";", "}", "public", "int", "getPort", "(", ")", "{", "return", "(", "(", "serversocket", "==", "null", ")", "?", "port", ":", "serversocket", ".", "getLocalPort", "(", ")", ")", ";", "}", "public", "void", "run", "(", ")", "{", "running", "=", "true", ";", "NGSession", "sessionOnDeck", "=", "null", ";", "originalSecurityManager", "=", "System", ".", "getSecurityManager", "(", ")", ";", "System", ".", "setSecurityManager", "(", "new", "NGSecurityManager", "(", "originalSecurityManager", ")", ")", ";", "if", "(", "captureSystemStreams", ")", "{", "synchronized", "(", "System", ".", "in", ")", "{", "if", "(", "!", "(", "System", ".", "in", "instanceof", "ThreadLocalInputStream", ")", ")", "{", "System", ".", "setIn", "(", "new", "ThreadLocalInputStream", "(", "in", ")", ")", ";", "System", ".", "setOut", "(", "new", "ThreadLocalPrintStream", "(", "out", ")", ")", ";", "System", ".", "setErr", "(", "new", "ThreadLocalPrintStream", "(", "err", ")", ")", ";", "capturedSystemStreams", "=", "true", ";", "}", "}", "}", "try", "{", "if", "(", "addr", "==", "null", ")", "{", "serversocket", "=", "new", "ServerSocket", "(", "port", ")", ";", "}", "else", "{", "serversocket", "=", "new", "ServerSocket", "(", "port", ",", "0", ",", "addr", ")", ";", "}", "while", "(", "!", "shutdown", ")", "{", "sessionOnDeck", "=", "sessionPool", ".", "take", "(", ")", ";", "Socket", "socket", "=", "serversocket", ".", "accept", "(", ")", ";", "sessionOnDeck", ".", "run", "(", "socket", ")", ";", "}", "}", "catch", "(", "Throwable", "t", ")", "{", "if", "(", "!", "shutdown", ")", "{", "throw", "new", "RuntimeException", "(", "t", ")", ";", "}", "}", "if", "(", "sessionOnDeck", "!=", "null", ")", "{", "sessionOnDeck", ".", "shutdown", "(", ")", ";", "}", "running", "=", "false", ";", "}", "private", "static", "void", "usage", "(", ")", "{", "System", ".", "err", ".", "println", "(", "\"\"", ")", ";", "System", ".", "err", ".", "println", "(", "\"\"", ")", ";", "System", ".", "err", ".", "println", "(", "\"\"", ")", ";", "System", ".", "err", ".", "println", "(", "\"\"", ")", ";", "}", "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "throws", "NumberFormatException", ",", "UnknownHostException", "{", "if", "(", "args", ".", "length", ">", "1", ")", "{", "usage", "(", ")", ";", "return", ";", "}", "InetAddress", "serverAddress", "=", "null", ";", "int", "port", "=", "NGConstants", ".", "DEFAULT_PORT", ";", "if", "(", "args", ".", "length", "!=", "0", ")", "{", "String", "[", "]", "argParts", "=", "args", "[", "0", "]", ".", "split", "(", "\":\"", ")", ";", "String", "addrPart", "=", "null", ";", "String", "portPart", "=", "null", ";", "if", "(", "argParts", ".", "length", "==", "2", ")", "{", "addrPart", "=", "argParts", "[", "0", "]", ";", "portPart", "=", "argParts", "[", "1", "]", ";", "}", "else", "if", "(", "argParts", "[", "0", "]", ".", "indexOf", "(", "'.'", ")", ">=", "0", ")", "{", "addrPart", "=", "argParts", "[", "0", "]", ";", "}", "else", "{", "portPart", "=", "argParts", "[", "0", "]", ";", "}", "if", "(", "addrPart", "!=", "null", ")", "{", "serverAddress", "=", "InetAddress", ".", "getByName", "(", "addrPart", ")", ";", "}", "if", "(", "portPart", "!=", "null", ")", "{", "port", "=", "Integer", ".", "parseInt", "(", "portPart", ")", ";", "}", "}", "NGServer", "server", "=", "new", "NGServer", "(", "serverAddress", ",", "port", ",", "null", ")", ";", "Thread", "t", "=", "new", "Thread", "(", "server", ")", ";", "t", ".", "setName", "(", "\"NGServer(\"", "+", "serverAddress", "+", "\",", "\"", "+", "port", "+", "\")\"", ")", ";", "t", ".", "start", "(", ")", ";", "Runtime", ".", "getRuntime", "(", ")", ".", "addShutdownHook", "(", "new", "NGServerShutdowner", "(", "server", ")", ")", ";", "int", "runningPort", "=", "server", ".", "getPort", "(", ")", ";", "while", "(", "runningPort", "==", "0", ")", "{", "try", "{", "Thread", ".", "sleep", "(", "50", ")", ";", "}", "catch", "(", "Throwable", "toIgnore", ")", "{", "}", "runningPort", "=", "server", ".", "getPort", "(", ")", ";", "}", "System", ".", "out", ".", "println", "(", "\"\"", "+", "(", "(", "serverAddress", "==", "null", ")", "?", "\"\"", ":", "serverAddress", ".", "getHostAddress", "(", ")", ")", "+", "\",", "port", "\"", "+", "runningPort", "+", "\".\"", ")", ";", "}", "private", "static", "class", "NGServerShutdowner", "extends", "Thread", "{", "private", "NGServer", "server", "=", "null", ";", "NGServerShutdowner", "(", "NGServer", "server", ")", "{", "this", ".", "server", "=", "server", ";", "}", "public", "void", "run", "(", ")", "{", "int", "count", "=", "0", ";", "server", ".", "shutdown", "(", "false", ")", ";", "while", "(", "server", ".", "isRunning", "(", ")", "&&", "(", "count", "<", "50", ")", ")", "{", "try", "{", "Thread", ".", "sleep", "(", "100", ")", ";", "}", "catch", "(", "InterruptedException", "e", ")", "{", "}", "++", "count", ";", "}", "if", "(", "server", ".", "isRunning", "(", ")", ")", "{", "System", ".", "err", ".", "println", "(", "\"\"", ")", ";", "}", "else", "{", "System", ".", "out", ".", "println", "(", "\"\"", ")", ";", "}", "}", "}", "}", "</s>" ]
1,427
[ "<s>", "package", "com", ".", "martiansoftware", ".", "nailgun", ";", "import", "java", ".", "io", ".", "InputStream", ";", "import", "java", ".", "io", ".", "PrintStream", ";", "import", "java", ".", "lang", ".", "reflect", ".", "InvocationTargetException", ";", "import", "java", ".", "lang", ".", "reflect", ".", "Method", ";", "import", "java", ".", "net", ".", "Socket", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Properties", ";", "import", "org", ".", "apache", ".", "tools", ".", "ant", ".", "ExitException", ";", "@", "SuppressWarnings", "(", "{", "\"rawtypes\"", ",", "\"unchecked\"", "}", ")", "class", "NGSession", "extends", "Thread", "{", "private", "NGServer", "server", "=", "null", ";", "private", "NGSessionPool", "sessionPool", "=", "null", ";", "private", "Object", "lock", "=", "new", "Object", "(", ")", ";", "private", "Socket", "nextSocket", "=", "null", ";", "private", "boolean", "done", "=", "false", ";", "private", "long", "instanceNumber", "=", "0", ";", "private", "static", "Object", "sharedLock", "=", "new", "Object", "(", ")", ";", "private", "static", "long", "instanceCounter", "=", "0", ";", "private", "static", "Class", "[", "]", "mainSignature", ";", "private", "static", "Class", "[", "]", "nailMainSignature", ";", "static", "{", "mainSignature", "=", "new", "Class", "[", "1", "]", ";", "mainSignature", "[", "0", "]", "=", "String", "[", "]", ".", "class", ";", "nailMainSignature", "=", "new", "Class", "[", "1", "]", ";", "nailMainSignature", "[", "0", "]", "=", "NGContext", ".", "class", ";", "}", "NGSession", "(", "NGSessionPool", "sessionPool", ",", "NGServer", "server", ")", "{", "super", "(", ")", ";", "this", ".", "sessionPool", "=", "sessionPool", ";", "this", ".", "server", "=", "server", ";", "synchronized", "(", "sharedLock", ")", "{", "this", ".", "instanceNumber", "=", "++", "instanceCounter", ";", "}", "}", "void", "shutdown", "(", ")", "{", "done", "=", "true", ";", "synchronized", "(", "lock", ")", "{", "nextSocket", "=", "null", ";", "lock", ".", "notifyAll", "(", ")", ";", "}", "}", "public", "void", "run", "(", "Socket", "socket", ")", "{", "synchronized", "(", "lock", ")", "{", "nextSocket", "=", "socket", ";", "lock", ".", "notify", "(", ")", ";", "}", "Thread", ".", "yield", "(", ")", ";", "}", "private", "Socket", "nextSocket", "(", ")", "{", "Socket", "result", "=", "null", ";", "synchronized", "(", "lock", ")", "{", "result", "=", "nextSocket", ";", "while", "(", "!", "done", "&&", "result", "==", "null", ")", "{", "try", "{", "lock", ".", "wait", "(", ")", ";", "}", "catch", "(", "InterruptedException", "e", ")", "{", "done", "=", "true", ";", "}", "result", "=", "nextSocket", ";", "}", "nextSocket", "=", "null", ";", "}", "return", "(", "result", ")", ";", "}", "public", "void", "run", "(", ")", "{", "updateThreadName", "(", "null", ")", ";", "Socket", "socket", "=", "nextSocket", "(", ")", ";", "while", "(", "socket", "!=", "null", ")", "{", "boolean", "keepAlive", "=", "false", ";", "boolean", "byeChunk", "=", "false", ";", "java", ".", "io", ".", "DataInputStream", "sockin", "=", "null", ";", "java", ".", "io", ".", "OutputStream", "sockout", "=", "null", ";", "try", "{", "byte", "[", "]", "lbuf", "=", "new", "byte", "[", "5", "]", ";", "sockin", "=", "new", "java", ".", "io", ".", "DataInputStream", "(", "socket", ".", "getInputStream", "(", ")", ")", ";", "sockout", "=", "socket", ".", "getOutputStream", "(", ")", ";", "List", "remoteArgs", "=", "new", "java", ".", "util", ".", "ArrayList", "(", ")", ";", "Properties", "remoteEnv", "=", "new", "Properties", "(", ")", ";", "String", "cwd", "=", "null", ";", "String", "command", "=", "null", ";", "while", "(", "command", "==", "null", "&&", "!", "byeChunk", ")", "{", "sockin", ".", "readFully", "(", "lbuf", ")", ";", "long", "bytesToRead", "=", "LongUtils", ".", "fromArray", "(", "lbuf", ",", "0", ")", ";", "char", "chunkType", "=", "(", "char", ")", "lbuf", "[", "4", "]", ";", "byte", "[", "]", "b", "=", "new", "byte", "[", "(", "int", ")", "bytesToRead", "]", ";", "sockin", ".", "readFully", "(", "b", ")", ";", "String", "line", "=", "new", "String", "(", "b", ",", "\"UTF-8\"", ")", ";", "switch", "(", "chunkType", ")", "{", "case", "NGConstants", ".", "CHUNKTYPE_ARGUMENT", ":", "remoteArgs", ".", "add", "(", "line", ")", ";", "break", ";", "case", "NGConstants", ".", "CHUNKTYPE_ENVIRONMENT", ":", "int", "equalsIndex", "=", "line", ".", "indexOf", "(", "'='", ")", ";", "if", "(", "equalsIndex", ">", "0", ")", "{", "remoteEnv", ".", "setProperty", "(", "line", ".", "substring", "(", "0", ",", "equalsIndex", ")", ",", "line", ".", "substring", "(", "equalsIndex", "+", "1", ")", ")", ";", "}", "break", ";", "case", "NGConstants", ".", "CHUNKTYPE_COMMAND", ":", "command", "=", "line", ";", "break", ";", "case", "NGConstants", ".", "CHUNKTYPE_WORKINGDIRECTORY", ":", "cwd", "=", "line", ";", "break", ";", "case", "NGConstants", ".", "CHUNKTYPE_KEEP_ALIVE", ":", "keepAlive", "=", "true", ";", "break", ";", "case", "NGConstants", ".", "CHUNKTYPE_BYE", ":", "byeChunk", "=", "true", ";", "keepAlive", "=", "false", ";", "break", ";", "default", ":", "}", "}", "updateThreadName", "(", "socket", ".", "getInetAddress", "(", ")", ".", "getHostAddress", "(", ")", "+", "\":", "\"", "+", "command", ")", ";", "InputStream", "in", "=", "new", "NGInputStream", "(", "sockin", ")", ";", "PrintStream", "out", "=", "new", "PrintStream", "(", "new", "NGOutputStream", "(", "sockout", ",", "NGConstants", ".", "CHUNKTYPE_STDOUT", ")", ")", ";", "PrintStream", "err", "=", "new", "PrintStream", "(", "new", "NGOutputStream", "(", "sockout", ",", "NGConstants", ".", "CHUNKTYPE_STDERR", ")", ")", ";", "PrintStream", "exit", "=", "new", "PrintStream", "(", "new", "NGOutputStream", "(", "sockout", ",", "NGConstants", ".", "CHUNKTYPE_EXIT", ")", ")", ";", "if", "(", "server", ".", "hasCapturedSystemStreams", "(", ")", ")", "{", "(", "(", "ThreadLocalInputStream", ")", "System", ".", "in", ")", ".", "init", "(", "in", ")", ";", "(", "(", "ThreadLocalPrintStream", ")", "System", ".", "out", ")", ".", "init", "(", "out", ")", ";", "(", "(", "ThreadLocalPrintStream", ")", "System", ".", "err", ")", ".", "init", "(", "err", ")", ";", "}", "if", "(", "!", "byeChunk", ")", "{", "try", "{", "Alias", "alias", "=", "server", ".", "getAliasManager", "(", ")", ".", "getAlias", "(", "command", ")", ";", "Class", "cmdclass", "=", "null", ";", "if", "(", "alias", "!=", "null", ")", "{", "cmdclass", "=", "alias", ".", "getAliasedClass", "(", ")", ";", "}", "else", "if", "(", "server", ".", "allowsNailsByClassName", "(", ")", ")", "{", "cmdclass", "=", "Class", ".", "forName", "(", "command", ",", "true", ",", "server", ".", "getClassLoader", "(", ")", ")", ";", "}", "else", "{", "cmdclass", "=", "server", ".", "getDefaultNailClass", "(", ")", ";", "}", "Object", "[", "]", "methodArgs", "=", "new", "Object", "[", "1", "]", ";", "Method", "mainMethod", "=", "null", ";", "String", "[", "]", "cmdlineArgs", "=", "(", "String", "[", "]", ")", "remoteArgs", ".", "toArray", "(", "new", "String", "[", "remoteArgs", ".", "size", "(", ")", "]", ")", ";", "try", "{", "mainMethod", "=", "cmdclass", ".", "getMethod", "(", "\"nailMain\"", ",", "nailMainSignature", ")", ";", "NGContext", "context", "=", "new", "NGContext", "(", ")", ";", "context", ".", "setArgs", "(", "cmdlineArgs", ")", ";", "context", ".", "in", "=", "in", ";", "context", ".", "out", "=", "out", ";", "context", ".", "err", "=", "err", ";", "context", ".", "setCommand", "(", "command", ")", ";", "context", ".", "setExitStream", "(", "exit", ")", ";", "context", ".", "setNGServer", "(", "server", ")", ";", "context", ".", "setEnv", "(", "remoteEnv", ")", ";", "context", ".", "setInetAddress", "(", "socket", ".", "getInetAddress", "(", ")", ")", ";", "context", ".", "setPort", "(", "socket", ".", "getPort", "(", ")", ")", ";", "context", ".", "setWorkingDirectory", "(", "cwd", ")", ";", "methodArgs", "[", "0", "]", "=", "context", ";", "}", "catch", "(", "NoSuchMethodException", "toDiscard", ")", "{", "}", "if", "(", "mainMethod", "==", "null", ")", "{", "mainMethod", "=", "cmdclass", ".", "getMethod", "(", "\"main\"", ",", "mainSignature", ")", ";", "methodArgs", "[", "0", "]", "=", "cmdlineArgs", ";", "}", "if", "(", "mainMethod", "!=", "null", ")", "{", "server", ".", "nailStarted", "(", "cmdclass", ")", ";", "NGSecurityManager", ".", "setExit", "(", "exit", ")", ";", "try", "{", "mainMethod", ".", "invoke", "(", "null", ",", "methodArgs", ")", ";", "}", "catch", "(", "InvocationTargetException", "ite", ")", "{", "throw", "(", "ite", ".", "getCause", "(", ")", ")", ";", "}", "catch", "(", "Throwable", "t", ")", "{", "throw", "(", "t", ")", ";", "}", "finally", "{", "server", ".", "nailFinished", "(", "cmdclass", ")", ";", "}", "exit", ".", "print", "(", "0", ")", ";", "}", "}", "catch", "(", "ExitException", "exitEx", ")", "{", "exit", ".", "print", "(", "exitEx", ".", "getStatus", "(", ")", ")", ";", "server", ".", "out", ".", "println", "(", "Thread", ".", "currentThread", "(", ")", ".", "getName", "(", ")", "+", "\"\"", "+", "exitEx", ".", "getStatus", "(", ")", ")", ";", "}", "catch", "(", "Throwable", "t", ")", "{", "t", ".", "printStackTrace", "(", ")", ";", "exit", ".", "print", "(", "NGConstants", ".", "EXIT_EXCEPTION", ")", ";", "}", "}", "}", "catch", "(", "Throwable", "t", ")", "{", "t", ".", "printStackTrace", "(", ")", ";", "break", ";", "}", "finally", "{", "if", "(", "!", "keepAlive", ")", "{", "try", "{", "byte", "[", "]", "leftovers", "=", "new", "byte", "[", "8", "]", ";", "while", "(", "sockin", ".", "read", "(", "leftovers", ")", ">", "0", ")", "{", "}", "}", "catch", "(", "Exception", "ignore", ")", "{", "}", "try", "{", "sockout", ".", "close", "(", ")", ";", "}", "catch", "(", "Exception", "ignore", ")", "{", "}", "try", "{", "sockin", ".", "close", "(", ")", ";", "}", "catch", "(", "Exception", "ignore", ")", "{", "}", "try", "{", "socket", ".", "close", "(", ")", ";", "}", "catch", "(", "Exception", "ex", ")", "{", "ex", ".", "printStackTrace", "(", ")", ";", "}", "}", "}", "if", "(", "!", "keepAlive", ")", "{", "if", "(", "server", ".", "hasCapturedSystemStreams", "(", ")", ")", "{", "if", "(", "System", ".", "in", "instanceof", "ThreadLocalInputStream", ")", "{", "(", "(", "ThreadLocalInputStream", ")", "System", ".", "in", ")", ".", "init", "(", "null", ")", ";", "}", "if", "(", "System", ".", "out", "instanceof", "ThreadLocalPrintStream", ")", "{", "(", "(", "ThreadLocalPrintStream", ")", "System", ".", "out", ")", ".", "init", "(", "null", ")", ";", "}", "if", "(", "System", ".", "out", "instanceof", "ThreadLocalPrintStream", ")", "{", "(", "(", "ThreadLocalPrintStream", ")", "System", ".", "err", ")", ".", "init", "(", "null", ")", ";", "}", "}", "updateThreadName", "(", "null", ")", ";", "sessionPool", ".", "give", "(", "this", ")", ";", "socket", "=", "nextSocket", "(", ")", ";", "}", "}", "}", "private", "void", "updateThreadName", "(", "String", "detail", ")", "{", "setName", "(", "\"NGSession", "\"", "+", "instanceNumber", "+", "\":", "\"", "+", "(", "(", "detail", "==", "null", ")", "?", "\"(idle)\"", ":", "detail", ")", ")", ";", "}", "}", "</s>" ]
1,428
[ "<s>", "package", "org", ".", "eclim", ".", "logging", ".", "log4j", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "io", ".", "OutputStream", ";", "import", "java", ".", "io", ".", "Writer", ";", "public", "class", "ConsoleAppender", "extends", "org", ".", "apache", ".", "log4j", ".", "ConsoleAppender", "{", "private", "boolean", "writerSet", ";", "public", "void", "activateOptions", "(", ")", "{", "if", "(", "getTarget", "(", ")", ".", "equals", "(", "SYSTEM_ERR", ")", ")", "{", "setWriter", "(", "createWriter", "(", "new", "SystemStream", "(", "System", ".", "err", ")", ")", ")", ";", "}", "else", "{", "setWriter", "(", "createWriter", "(", "new", "SystemStream", "(", "System", ".", "out", ")", ")", ")", ";", "}", "super", ".", "activateOptions", "(", ")", ";", "}", "public", "synchronized", "void", "setWriter", "(", "Writer", "writer", ")", "{", "if", "(", "!", "writerSet", ")", "{", "super", ".", "setWriter", "(", "writer", ")", ";", "writerSet", "=", "true", ";", "}", "}", "private", "static", "class", "SystemStream", "extends", "OutputStream", "{", "private", "OutputStream", "out", ";", "public", "SystemStream", "(", "OutputStream", "out", ")", "{", "this", ".", "out", "=", "out", ";", "}", "public", "void", "close", "(", ")", "{", "}", "public", "void", "flush", "(", ")", "throws", "IOException", "{", "out", ".", "flush", "(", ")", ";", "}", "public", "void", "write", "(", "final", "byte", "[", "]", "bytes", ")", "throws", "IOException", "{", "out", ".", "write", "(", "bytes", ")", ";", "}", "public", "void", "write", "(", "final", "byte", "[", "]", "bytes", ",", "final", "int", "offset", ",", "final", "int", "length", ")", "throws", "IOException", "{", "out", ".", "write", "(", "bytes", ",", "offset", ",", "length", ")", ";", "}", "public", "void", "write", "(", "final", "int", "bytes", ")", "throws", "IOException", "{", "out", ".", "write", "(", "bytes", ")", ";", "}", "}", "}", "</s>" ]
1,429
[ "<s>", "package", "org", ".", "eclim", ".", "logging", ".", "log4j", ";", "import", "java", ".", "lang", ".", "reflect", ".", "InvocationTargetException", ";", "import", "java", ".", "lang", ".", "reflect", ".", "Method", ";", "import", "org", ".", "apache", ".", "log4j", ".", "AppenderSkeleton", ";", "import", "org", ".", "apache", ".", "log4j", ".", "Layout", ";", "import", "org", ".", "apache", ".", "log4j", ".", "spi", ".", "LoggingEvent", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Display", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Text", ";", "public", "class", "ViewAppender", "extends", "AppenderSkeleton", "{", "private", "Method", "logAccessor", ";", "@", "SuppressWarnings", "(", "{", "\"rawtypes\"", ",", "\"unchecked\"", "}", ")", "public", "void", "setView", "(", "String", "view", ")", "throws", "ClassNotFoundException", ",", "NoSuchMethodException", "{", "Class", "viewClass", "=", "Class", ".", "forName", "(", "view", ")", ";", "logAccessor", "=", "viewClass", ".", "getMethod", "(", "\"getLog\"", ")", ";", "}", "@", "Override", "protected", "void", "append", "(", "final", "LoggingEvent", "event", ")", "{", "try", "{", "final", "Text", "log", "=", "(", "Text", ")", "logAccessor", ".", "invoke", "(", "null", ")", ";", "if", "(", "log", "!=", "null", "&&", "!", "log", ".", "isDisposed", "(", ")", ")", "{", "Display", ".", "getDefault", "(", ")", ".", "asyncExec", "(", "new", "Runnable", "(", ")", "{", "public", "void", "run", "(", ")", "{", "write", "(", "log", ",", "event", ")", ";", "}", "}", ")", ";", "}", "}", "catch", "(", "IllegalAccessException", "iae", ")", "{", "throw", "new", "RuntimeException", "(", "iae", ")", ";", "}", "catch", "(", "InvocationTargetException", "ite", ")", "{", "throw", "new", "RuntimeException", "(", "ite", ")", ";", "}", "}", "private", "void", "write", "(", "Text", "log", ",", "LoggingEvent", "event", ")", "{", "if", "(", "!", "log", ".", "isDisposed", "(", ")", ")", "{", "log", ".", "append", "(", "layout", ".", "format", "(", "event", ")", ")", ";", "if", "(", "layout", ".", "ignoresThrowable", "(", ")", ")", "{", "String", "[", "]", "s", "=", "event", ".", "getThrowableStrRep", "(", ")", ";", "if", "(", "s", "!=", "null", ")", "{", "int", "len", "=", "s", ".", "length", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "len", ";", "i", "++", ")", "{", "log", ".", "append", "(", "s", "[", "i", "]", ")", ";", "log", ".", "append", "(", "Layout", ".", "LINE_SEP", ")", ";", "}", "}", "}", "}", "}", "public", "boolean", "requiresLayout", "(", ")", "{", "return", "true", ";", "}", "public", "void", "close", "(", ")", "{", "}", "}", "</s>" ]
1,430
[ "<s>", "package", "org", ".", "eclim", ".", "logging", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "ResourcesPlugin", ";", "public", "class", "Logger", "{", "private", "static", "String", "workspace", "=", "ResourcesPlugin", ".", "getWorkspace", "(", ")", ".", "getRoot", "(", ")", ".", "getRawLocation", "(", ")", ".", "toOSString", "(", ")", ".", "replace", "(", "'\\\\'", ",", "'/'", ")", ";", "static", "{", "System", ".", "setProperty", "(", "\"\"", ",", "workspace", ")", ";", "}", "private", "org", ".", "slf4j", ".", "Logger", "logger", ";", "private", "Logger", "(", "org", ".", "slf4j", ".", "Logger", "logger", ")", "{", "this", ".", "logger", "=", "logger", ";", "}", "public", "static", "Logger", "getLogger", "(", "Class", "<", "?", ">", "theClass", ")", "{", "return", "getLogger", "(", "theClass", ".", "getName", "(", ")", ")", ";", "}", "public", "static", "Logger", "getLogger", "(", "String", "name", ")", "{", "return", "new", "Logger", "(", "org", ".", "slf4j", ".", "LoggerFactory", ".", "getLogger", "(", "name", ")", ")", ";", "}", "public", "void", "debug", "(", "String", "message", ",", "Throwable", "t", ")", "{", "logger", ".", "debug", "(", "message", ",", "t", ")", ";", "}", "public", "void", "debug", "(", "String", "message", ",", "Object", "...", "args", ")", "{", "logger", ".", "debug", "(", "message", ",", "args", ")", ";", "}", "public", "void", "info", "(", "String", "message", ",", "Throwable", "t", ")", "{", "logger", ".", "info", "(", "message", ",", "t", ")", ";", "}", "public", "void", "info", "(", "String", "message", ",", "Object", "...", "args", ")", "{", "logger", ".", "info", "(", "message", ",", "args", ")", ";", "}", "public", "void", "warn", "(", "String", "message", ",", "Throwable", "t", ")", "{", "logger", ".", "warn", "(", "message", ",", "t", ")", ";", "}", "public", "void", "warn", "(", "String", "message", ",", "Object", "...", "args", ")", "{", "logger", ".", "warn", "(", "message", ",", "args", ")", ";", "}", "public", "void", "error", "(", "String", "message", ",", "Throwable", "t", ")", "{", "logger", ".", "error", "(", "message", ",", "t", ")", ";", "}", "public", "void", "error", "(", "String", "message", ",", "Object", "...", "args", ")", "{", "logger", ".", "error", "(", "message", ",", "args", ")", ";", "}", "public", "boolean", "isDebugEnabled", "(", ")", "{", "return", "logger", ".", "isDebugEnabled", "(", ")", ";", "}", "public", "boolean", "isInfoEnabled", "(", ")", "{", "return", "logger", ".", "isInfoEnabled", "(", ")", ";", "}", "public", "boolean", "isWarnEnabled", "(", ")", "{", "return", "logger", ".", "isWarnEnabled", "(", ")", ";", "}", "public", "boolean", "isErrorEnabled", "(", ")", "{", "return", "logger", ".", "isErrorEnabled", "(", ")", ";", "}", "}", "</s>" ]
1,431
[ "<s>", "package", "org", ".", "eclim", ".", "annotation", ";", "import", "java", ".", "lang", ".", "annotation", ".", "ElementType", ";", "import", "java", ".", "lang", ".", "annotation", ".", "Retention", ";", "import", "java", ".", "lang", ".", "annotation", ".", "RetentionPolicy", ";", "import", "java", ".", "lang", ".", "annotation", ".", "Target", ";", "@", "Target", "(", "ElementType", ".", "TYPE", ")", "@", "Retention", "(", "RetentionPolicy", ".", "RUNTIME", ")", "public", "@", "interface", "Command", "{", "String", "name", "(", ")", ";", "String", "options", "(", ")", "default", "\"\"", ";", "String", "description", "(", ")", "default", "\"\"", ";", "}", "</s>" ]
1,432
[ "<s>", "package", "org", ".", "eclim", ".", "util", ";", "import", "java", ".", "io", ".", "ByteArrayOutputStream", ";", "import", "java", ".", "io", ".", "IOException", ";", "public", "class", "CommandExecutor", "implements", "Runnable", "{", "private", "int", "returnCode", "=", "-", "1", ";", "private", "String", "[", "]", "cmd", ";", "private", "String", "result", ";", "private", "String", "error", ";", "private", "Process", "process", ";", "private", "CommandExecutor", "(", "String", "[", "]", "cmd", ")", "{", "this", ".", "cmd", "=", "cmd", ";", "}", "public", "static", "CommandExecutor", "execute", "(", "String", "[", "]", "cmd", ")", "throws", "Exception", "{", "return", "execute", "(", "cmd", ",", "-", "1", ")", ";", "}", "public", "static", "CommandExecutor", "execute", "(", "String", "[", "]", "cmd", ",", "long", "timeout", ")", "throws", "Exception", "{", "CommandExecutor", "executor", "=", "new", "CommandExecutor", "(", "cmd", ")", ";", "Thread", "thread", "=", "new", "Thread", "(", "executor", ")", ";", "thread", ".", "start", "(", ")", ";", "if", "(", "timeout", ">", "0", ")", "{", "thread", ".", "join", "(", "timeout", ")", ";", "}", "else", "{", "thread", ".", "join", "(", ")", ";", "}", "return", "executor", ";", "}", "public", "void", "run", "(", ")", "{", "try", "{", "Runtime", "runtime", "=", "Runtime", ".", "getRuntime", "(", ")", ";", "process", "=", "runtime", ".", "exec", "(", "cmd", ")", ";", "final", "ByteArrayOutputStream", "out", "=", "new", "ByteArrayOutputStream", "(", ")", ";", "final", "ByteArrayOutputStream", "err", "=", "new", "ByteArrayOutputStream", "(", ")", ";", "Thread", "outThread", "=", "new", "Thread", "(", ")", "{", "public", "void", "run", "(", ")", "{", "try", "{", "IOUtils", ".", "copy", "(", "process", ".", "getInputStream", "(", ")", ",", "out", ")", ";", "}", "catch", "(", "IOException", "ioe", ")", "{", "ioe", ".", "printStackTrace", "(", ")", ";", "}", "}", "}", ";", "outThread", ".", "start", "(", ")", ";", "Thread", "errThread", "=", "new", "Thread", "(", ")", "{", "public", "void", "run", "(", ")", "{", "try", "{", "IOUtils", ".", "copy", "(", "process", ".", "getErrorStream", "(", ")", ",", "err", ")", ";", "}", "catch", "(", "IOException", "ioe", ")", "{", "ioe", ".", "printStackTrace", "(", ")", ";", "}", "}", "}", ";", "errThread", ".", "start", "(", ")", ";", "returnCode", "=", "process", ".", "waitFor", "(", ")", ";", "outThread", ".", "join", "(", "1000", ")", ";", "errThread", ".", "join", "(", "1000", ")", ";", "result", "=", "out", ".", "toString", "(", ")", ";", "error", "=", "err", ".", "toString", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "returnCode", "=", "12", ";", "error", "=", "e", ".", "getMessage", "(", ")", ";", "e", ".", "printStackTrace", "(", ")", ";", "}", "}", "public", "void", "destroy", "(", ")", "{", "if", "(", "process", "!=", "null", ")", "{", "process", ".", "destroy", "(", ")", ";", "}", "}", "public", "String", "getResult", "(", ")", "{", "return", "result", ";", "}", "public", "int", "getReturnCode", "(", ")", "{", "return", "returnCode", ";", "}", "public", "String", "getErrorMessage", "(", ")", "{", "return", "error", ";", "}", "}", "</s>" ]
1,433
[ "<s>", "package", "org", ".", "eclim", ".", "util", ".", "file", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang", ".", "StringUtils", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang", ".", "builder", ".", "EqualsBuilder", ";", "public", "class", "Position", "{", "private", "String", "filename", ";", "private", "int", "offset", "=", "0", ";", "private", "int", "length", "=", "0", ";", "private", "int", "line", "=", "1", ";", "private", "int", "column", "=", "1", ";", "private", "String", "message", ";", "public", "static", "Position", "fromOffset", "(", "String", "filename", ",", "String", "message", ",", "int", "offset", ",", "int", "length", ")", "{", "int", "line", "=", "1", ";", "int", "column", "=", "1", ";", "try", "{", "int", "[", "]", "pos", "=", "FileUtils", ".", "offsetToLineColumn", "(", "filename", ",", "offset", ")", ";", "if", "(", "pos", "!=", "null", ")", "{", "line", "=", "pos", "[", "0", "]", ";", "column", "=", "pos", "[", "1", "]", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "return", "new", "Position", "(", "filename", ",", "message", ",", "offset", ",", "length", ",", "line", ",", "column", ")", ";", "}", "public", "static", "Position", "fromLineColumn", "(", "String", "filename", ",", "String", "message", ",", "int", "line", ",", "int", "column", ")", "{", "return", "new", "Position", "(", "filename", ",", "message", ",", "0", ",", "0", ",", "line", ",", "column", ")", ";", "}", "private", "Position", "(", "String", "filename", ",", "String", "message", ",", "int", "offset", ",", "int", "length", ",", "int", "line", ",", "int", "column", ")", "{", "this", ".", "filename", "=", "filename", ";", "this", ".", "message", "=", "message", "!=", "null", "?", "message", ":", "StringUtils", ".", "EMPTY", ";", "this", ".", "offset", "=", "offset", ";", "this", ".", "length", "=", "length", ";", "this", ".", "line", "=", "line", ";", "this", ".", "column", "=", "column", ";", "}", "public", "String", "getFilename", "(", ")", "{", "return", "this", ".", "filename", ";", "}", "public", "int", "getOffset", "(", ")", "{", "return", "this", ".", "offset", ";", "}", "public", "int", "getLength", "(", ")", "{", "return", "this", ".", "length", ";", "}", "public", "int", "getLine", "(", ")", "{", "return", "this", ".", "line", ";", "}", "public", "int", "getColumn", "(", ")", "{", "return", "this", ".", "column", ";", "}", "public", "void", "setMessage", "(", "String", "message", ")", "{", "this", ".", "message", "=", "message", ";", "}", "public", "String", "getMessage", "(", ")", "{", "return", "this", ".", "message", ";", "}", "@", "Override", "public", "boolean", "equals", "(", "Object", "obj", ")", "{", "if", "(", "!", "(", "obj", "instanceof", "Position", ")", ")", "{", "return", "false", ";", "}", "if", "(", "this", "==", "obj", ")", "{", "return", "true", ";", "}", "Position", "rhs", "=", "(", "Position", ")", "obj", ";", "return", "new", "EqualsBuilder", "(", ")", ".", "append", "(", "filename", ",", "rhs", ".", "getFilename", "(", ")", ")", ".", "append", "(", "offset", ",", "rhs", ".", "getOffset", "(", ")", ")", ".", "append", "(", "length", ",", "rhs", ".", "getLength", "(", ")", ")", ".", "append", "(", "line", ",", "rhs", ".", "getLine", "(", ")", ")", ".", "append", "(", "column", ",", "rhs", ".", "getColumn", "(", ")", ")", ".", "isEquals", "(", ")", ";", "}", "}", "</s>" ]
1,434
[ "<s>", "package", "org", ".", "eclim", ".", "util", ".", "file", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "io", ".", "Reader", ";", "import", "java", ".", "lang", ".", "reflect", ".", "Field", ";", "import", "org", ".", "eclim", ".", "logging", ".", "Logger", ";", "public", "class", "BufferedReader", "extends", "Reader", "{", "private", "static", "final", "Logger", "logger", "=", "Logger", ".", "getLogger", "(", "BufferedReader", ".", "class", ")", ";", "Reader", "in", ";", "char", "[", "]", "buffer", ";", "int", "pos", ";", "int", "limit", ";", "int", "markPos", "=", "-", "1", ";", "static", "final", "int", "DEFAULT_BUFFER_SIZE", "=", "8192", ";", "private", "StringBuffer", "sbuf", "=", "null", ";", "public", "BufferedReader", "(", "Reader", "in", ")", "{", "this", "(", "in", ",", "DEFAULT_BUFFER_SIZE", ")", ";", "}", "public", "BufferedReader", "(", "Reader", "in", ",", "int", "size", ")", "{", "super", "(", "getDeclaredField", "(", "Reader", ".", "class", ",", "in", ",", "\"lock\"", ")", ")", ";", "if", "(", "size", "<=", "0", ")", "throw", "new", "IllegalArgumentException", "(", "\"\"", "+", "size", ")", ";", "this", ".", "in", "=", "in", ";", "buffer", "=", "new", "char", "[", "size", "]", ";", "}", "private", "static", "Object", "getDeclaredField", "(", "Class", "<", "?", ">", "clazz", ",", "Object", "instance", ",", "String", "fieldName", ")", "{", "try", "{", "Field", "field", "=", "clazz", ".", "getDeclaredField", "(", "fieldName", ")", ";", "field", ".", "setAccessible", "(", "true", ")", ";", "return", "field", ".", "get", "(", "instance", ")", ";", "}", "catch", "(", "IllegalAccessException", "iae", ")", "{", "logger", ".", "error", "(", "\"\"", ",", "iae", ")", ";", "}", "catch", "(", "NoSuchFieldException", "nsfe", ")", "{", "logger", ".", "error", "(", "\"\"", ",", "nsfe", ")", ";", "}", "throw", "new", "RuntimeException", "(", "\"\"", ")", ";", "}", "public", "void", "close", "(", ")", "throws", "IOException", "{", "synchronized", "(", "lock", ")", "{", "if", "(", "in", "!=", "null", ")", "in", ".", "close", "(", ")", ";", "in", "=", "null", ";", "buffer", "=", "null", ";", "}", "}", "public", "boolean", "markSupported", "(", ")", "{", "return", "true", ";", "}", "public", "void", "mark", "(", "int", "readLimit", ")", "throws", "IOException", "{", "if", "(", "readLimit", "<", "0", ")", "throw", "new", "IllegalArgumentException", "(", "\"\"", ")", ";", "synchronized", "(", "lock", ")", "{", "checkStatus", "(", ")", ";", "if", "(", "pos", "+", "readLimit", ">", "limit", ")", "{", "char", "[", "]", "old_buffer", "=", "buffer", ";", "int", "extraBuffSpace", "=", "0", ";", "if", "(", "pos", ">", "limit", ")", "extraBuffSpace", "=", "1", ";", "if", "(", "readLimit", "+", "extraBuffSpace", ">", "limit", ")", "buffer", "=", "new", "char", "[", "readLimit", "+", "extraBuffSpace", "]", ";", "limit", "-=", "pos", ";", "if", "(", "limit", ">=", "0", ")", "{", "System", ".", "arraycopy", "(", "old_buffer", ",", "pos", ",", "buffer", ",", "0", ",", "limit", ")", ";", "pos", "=", "0", ";", "}", "}", "if", "(", "limit", "<", "0", ")", "{", "pos", "=", "1", ";", "limit", "=", "markPos", "=", "0", ";", "}", "else", "markPos", "=", "pos", ";", "}", "}", "public", "void", "reset", "(", ")", "throws", "IOException", "{", "synchronized", "(", "lock", ")", "{", "checkStatus", "(", ")", ";", "if", "(", "markPos", "<", "0", ")", "throw", "new", "IOException", "(", "\"\"", ")", ";", "if", "(", "limit", ">", "0", ")", "pos", "=", "markPos", ";", "}", "}", "public", "boolean", "ready", "(", ")", "throws", "IOException", "{", "synchronized", "(", "lock", ")", "{", "checkStatus", "(", ")", ";", "return", "pos", "<", "limit", "||", "in", ".", "ready", "(", ")", ";", "}", "}", "public", "int", "read", "(", "char", "[", "]", "buf", ",", "int", "offset", ",", "int", "count", ")", "throws", "IOException", "{", "if", "(", "offset", "<", "0", "||", "offset", "+", "count", ">", "buf", ".", "length", "||", "count", "<", "0", ")", "throw", "new", "IndexOutOfBoundsException", "(", ")", ";", "synchronized", "(", "lock", ")", "{", "checkStatus", "(", ")", ";", "boolean", "retAtEndOfBuffer", "=", "false", ";", "int", "avail", "=", "limit", "-", "pos", ";", "if", "(", "count", ">", "avail", ")", "{", "if", "(", "avail", ">", "0", ")", "count", "=", "avail", ";", "else", "{", "if", "(", "limit", "==", "buffer", ".", "length", ")", "markPos", "=", "-", "1", ";", "if", "(", "pos", ">", "limit", ")", "{", "retAtEndOfBuffer", "=", "true", ";", "--", "pos", ";", "}", "if", "(", "markPos", "<", "0", ")", "{", "if", "(", "count", ">=", "buffer", ".", "length", "&&", "!", "retAtEndOfBuffer", ")", "return", "in", ".", "read", "(", "buf", ",", "offset", ",", "count", ")", ";", "pos", "=", "limit", "=", "0", ";", "}", "avail", "=", "in", ".", "read", "(", "buffer", ",", "limit", ",", "buffer", ".", "length", "-", "limit", ")", ";", "if", "(", "retAtEndOfBuffer", "&&", "avail", ">", "0", "&&", "buffer", "[", "limit", "]", "==", "'\\n'", ")", "{", "--", "avail", ";", "limit", "++", ";", "}", "if", "(", "avail", "<", "count", ")", "{", "if", "(", "avail", "<=", "0", ")", "return", "avail", ";", "count", "=", "avail", ";", "}", "limit", "+=", "avail", ";", "}", "}", "System", ".", "arraycopy", "(", "buffer", ",", "pos", ",", "buf", ",", "offset", ",", "count", ")", ";", "pos", "+=", "count", ";", "return", "count", ";", "}", "}", "private", "int", "fill", "(", ")", "throws", "IOException", "{", "checkStatus", "(", ")", ";", "boolean", "retAtEndOfBuffer", "=", "false", ";", "if", "(", "pos", ">", "limit", ")", "{", "retAtEndOfBuffer", "=", "true", ";", "--", "pos", ";", "}", "if", "(", "markPos", ">=", "0", "&&", "limit", "==", "buffer", ".", "length", ")", "markPos", "=", "-", "1", ";", "if", "(", "markPos", "<", "0", ")", "pos", "=", "limit", "=", "0", ";", "int", "count", "=", "in", ".", "read", "(", "buffer", ",", "limit", ",", "buffer", ".", "length", "-", "limit", ")", ";", "if", "(", "count", ">", "0", ")", "limit", "+=", "count", ";", "if", "(", "retAtEndOfBuffer", "&&", "buffer", "[", "pos", "]", "==", "'\\n'", ")", "{", "--", "count", ";", "if", "(", "markPos", "==", "pos", ")", "++", "markPos", ";", "++", "pos", ";", "}", "return", "count", ";", "}", "public", "int", "read", "(", ")", "throws", "IOException", "{", "synchronized", "(", "lock", ")", "{", "checkStatus", "(", ")", ";", "if", "(", "pos", ">=", "limit", "&&", "fill", "(", ")", "<=", "0", ")", "return", "-", "1", ";", "return", "buffer", "[", "pos", "++", "]", ";", "}", "}", "private", "int", "lineEnd", "(", "int", "limit", ")", "{", "int", "i", "=", "pos", ";", "for", "(", ";", "i", "<", "limit", ";", "i", "++", ")", "{", "char", "ch", "=", "buffer", "[", "i", "]", ";", "if", "(", "ch", "==", "'\\n'", ")", "break", ";", "}", "return", "i", ";", "}", "public", "String", "readLine", "(", ")", "throws", "IOException", "{", "checkStatus", "(", ")", ";", "if", "(", "pos", ">", "limit", ")", "{", "int", "ch", "=", "read", "(", ")", ";", "if", "(", "ch", "<", "0", ")", "return", "null", ";", "if", "(", "ch", "!=", "'\\n'", ")", "--", "pos", ";", "}", "int", "i", "=", "lineEnd", "(", "limit", ")", ";", "if", "(", "i", "<", "limit", ")", "{", "String", "str", "=", "String", ".", "valueOf", "(", "buffer", ",", "pos", ",", "i", "-", "(", "pos", "-", "1", ")", ")", ";", "pos", "=", "i", "+", "1", ";", "return", "str", ";", "}", "if", "(", "sbuf", "==", "null", ")", "sbuf", "=", "new", "StringBuffer", "(", "200", ")", ";", "else", "sbuf", ".", "setLength", "(", "0", ")", ";", "sbuf", ".", "append", "(", "buffer", ",", "pos", ",", "i", "-", "pos", ")", ";", "pos", "=", "i", ";", "boolean", "eof", "=", "false", ";", "for", "(", ";", ";", ")", "{", "if", "(", "pos", ">=", "limit", ")", "{", "int", "count", "=", "fill", "(", ")", ";", "if", "(", "count", "<", "0", ")", "{", "eof", "=", "true", ";", "break", ";", "}", "continue", ";", "}", "int", "ch", "=", "buffer", "[", "pos", "++", "]", ";", "if", "(", "ch", "==", "'\\n'", ")", "{", "break", ";", "}", "i", "=", "lineEnd", "(", "limit", ")", ";", "int", "end", "=", "i", "-", "(", "pos", "-", "2", ")", ";", "if", "(", "end", ">", "buffer", ".", "length", ")", "end", "=", "i", "-", "(", "pos", "-", "1", ")", ";", "sbuf", ".", "append", "(", "buffer", ",", "pos", "-", "1", ",", "end", ")", ";", "pos", "=", "i", ";", "}", "return", "(", "sbuf", ".", "length", "(", ")", "==", "0", "&&", "eof", ")", "?", "null", ":", "sbuf", ".", "toString", "(", ")", ";", "}", "public", "long", "skip", "(", "long", "count", ")", "throws", "IOException", "{", "synchronized", "(", "lock", ")", "{", "checkStatus", "(", ")", ";", "if", "(", "count", "<", "0", ")", "throw", "new", "IllegalArgumentException", "(", "\"\"", ")", ";", "if", "(", "count", "==", "0", ")", "return", "0", ";", "if", "(", "pos", ">", "limit", ")", "{", "if", "(", "read", "(", ")", "<", "0", ")", "return", "0", ";", "else", "--", "pos", ";", "}", "int", "avail", "=", "limit", "-", "pos", ";", "if", "(", "count", "<", "avail", ")", "{", "pos", "+=", "count", ";", "return", "count", ";", "}", "pos", "=", "limit", ";", "long", "todo", "=", "count", "-", "avail", ";", "if", "(", "todo", ">", "buffer", ".", "length", ")", "{", "markPos", "=", "-", "1", ";", "todo", "-=", "in", ".", "skip", "(", "todo", ")", ";", "}", "else", "{", "while", "(", "todo", ">", "0", ")", "{", "avail", "=", "fill", "(", ")", ";", "if", "(", "avail", "<=", "0", ")", "break", ";", "if", "(", "avail", ">", "todo", ")", "avail", "=", "(", "int", ")", "todo", ";", "pos", "+=", "avail", ";", "todo", "-=", "avail", ";", "}", "}", "return", "count", "-", "todo", ";", "}", "}", "private", "void", "checkStatus", "(", ")", "throws", "IOException", "{", "if", "(", "in", "==", "null", ")", "throw", "new", "IOException", "(", "\"\"", ")", ";", "}", "}", "</s>" ]
1,435
[ "<s>", "package", "org", ".", "eclim", ".", "util", ".", "file", ";", "import", "java", ".", "io", ".", "BufferedInputStream", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "io", ".", "FileInputStream", ";", "import", "java", ".", "io", ".", "InputStream", ";", "import", "java", ".", "util", ".", "Enumeration", ";", "import", "java", ".", "util", ".", "regex", ".", "Matcher", ";", "import", "java", ".", "util", ".", "regex", ".", "Pattern", ";", "import", "javax", ".", "naming", ".", "CompositeName", ";", "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", ".", "util", ".", "IOUtils", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "IPath", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "Path", ";", "public", "class", "FileUtils", "{", "public", "static", "final", "String", "JAR_PREFIX", "=", "\"jar://\"", ";", "public", "static", "final", "String", "ZIP_PREFIX", "=", "\"zip://\"", ";", "public", "static", "final", "String", "JAR_EXT", "=", "\".jar\"", ";", "public", "static", "final", "String", "ZIP_EXT", "=", "\".zip\"", ";", "public", "static", "final", "char", "UNIX_SEPARATOR", "=", "'/'", ";", "public", "static", "final", "char", "WINDOWS_SEPARATOR", "=", "'\\\\'", ";", "public", "static", "final", "String", "UTF8", "=", "\"utf-8\"", ";", "public", "static", "int", "byteOffsetToCharOffset", "(", "String", "filename", ",", "int", "byteOffset", ",", "String", "encoding", ")", "throws", "Exception", "{", "FileSystemManager", "fsManager", "=", "VFS", ".", "getManager", "(", ")", ";", "FileObject", "file", "=", "fsManager", ".", "resolveFile", "(", "filename", ")", ";", "return", "byteOffsetToCharOffset", "(", "file", ".", "getContent", "(", ")", ".", "getInputStream", "(", ")", ",", "byteOffset", ",", "encoding", ")", ";", "}", "public", "static", "int", "byteOffsetToCharOffset", "(", "InputStream", "in", ",", "int", "byteOffset", ",", "String", "encoding", ")", "throws", "Exception", "{", "if", "(", "encoding", "==", "null", ")", "{", "encoding", "=", "UTF8", ";", "}", "BufferedInputStream", "bin", "=", "null", ";", "try", "{", "byte", "[", "]", "bytes", "=", "new", "byte", "[", "byteOffset", "]", ";", "bin", "=", "new", "BufferedInputStream", "(", "in", ")", ";", "bin", ".", "read", "(", "bytes", ",", "0", ",", "bytes", ".", "length", ")", ";", "String", "value", "=", "new", "String", "(", "bytes", ",", "encoding", ")", ";", "return", "value", ".", "length", "(", ")", ";", "}", "finally", "{", "IOUtils", ".", "closeQuietly", "(", "bin", ")", ";", "}", "}", "public", "static", "int", "[", "]", "offsetToLineColumn", "(", "String", "filename", ",", "int", "offset", ")", "throws", "Exception", "{", "FileOffsets", "offsets", "=", "FileOffsets", ".", "compile", "(", "filename", ")", ";", "return", "offsets", ".", "offsetToLineColumn", "(", "offset", ")", ";", "}", "public", "static", "int", "[", "]", "offsetToLineColumn", "(", "InputStream", "in", ",", "int", "offset", ")", "throws", "Exception", "{", "FileOffsets", "offsets", "=", "FileOffsets", ".", "compile", "(", "in", ")", ";", "return", "offsets", ".", "offsetToLineColumn", "(", "offset", ")", ";", "}", "public", "static", "Matcher", "matcher", "(", "Pattern", "pattern", ",", "String", "file", ")", "throws", "Exception", "{", "FileInputStream", "is", "=", "null", ";", "try", "{", "is", "=", "new", "FileInputStream", "(", "file", ")", ";", "String", "contents", "=", "IOUtils", ".", "toString", "(", "is", ")", ";", "return", "pattern", ".", "matcher", "(", "contents", ")", ";", "}", "finally", "{", "IOUtils", ".", "closeQuietly", "(", "is", ")", ";", "}", "}", "public", "static", "String", "toUrl", "(", "String", "file", ")", "{", "file", "=", "file", ".", "replace", "(", "'\\\\'", ",", "'/'", ")", ";", "if", "(", "new", "File", "(", "file", ")", ".", "exists", "(", ")", ")", "{", "return", "file", ";", "}", "if", "(", "file", ".", "startsWith", "(", "JAR_PREFIX", ")", "||", "file", ".", "startsWith", "(", "ZIP_PREFIX", ")", ")", "{", "return", "file", ";", "}", "StringBuffer", "buffer", "=", "new", "StringBuffer", "(", ")", ";", "try", "{", "CompositeName", "fileName", "=", "new", "CompositeName", "(", "file", ")", ";", "Enumeration", "<", "String", ">", "names", "=", "fileName", ".", "getAll", "(", ")", ";", "while", "(", "names", ".", "hasMoreElements", "(", ")", ")", "{", "String", "name", "=", "names", ".", "nextElement", "(", ")", ";", "if", "(", "name", ".", "indexOf", "(", "\"$\"", ")", "!=", "-", "1", ")", "{", "name", "=", "name", ".", "substring", "(", "0", ",", "name", ".", "indexOf", "(", "\"$\"", ")", ")", "+", "'.'", "+", "getExtension", "(", "name", ")", ";", "}", "if", "(", "name", ".", "length", "(", ")", "!=", "0", ")", "{", "buffer", ".", "append", "(", "'/'", ")", ".", "append", "(", "name", ")", ";", "if", "(", "!", "new", "File", "(", "buffer", ".", "toString", "(", ")", ")", ".", "exists", "(", ")", ")", "{", "String", "path", "=", "getFullPath", "(", "buffer", ".", "toString", "(", ")", ")", ";", "if", "(", "path", ".", "endsWith", "(", "\"/\"", ")", "||", "path", ".", "endsWith", "(", "\"\\\\\"", ")", ")", "{", "path", "=", "path", ".", "substring", "(", "0", ",", "path", ".", "length", "(", ")", "-", "1", ")", ";", "}", "if", "(", "path", ".", "endsWith", "(", "JAR_EXT", ")", ")", "{", "buffer", "=", "new", "StringBuffer", "(", "JAR_PREFIX", ")", ".", "append", "(", "path", ")", ".", "append", "(", "'!'", ")", ".", "append", "(", "'/'", ")", ".", "append", "(", "name", ")", ";", "}", "else", "if", "(", "path", ".", "endsWith", "(", "ZIP_EXT", ")", ")", "{", "buffer", "=", "new", "StringBuffer", "(", "ZIP_PREFIX", ")", ".", "append", "(", "path", ")", ".", "append", "(", "'!'", ")", ".", "append", "(", "'/'", ")", ".", "append", "(", "name", ")", ";", "}", "}", "}", "}", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "return", "buffer", ".", "toString", "(", ")", ";", "}", "public", "static", "String", "concat", "(", "String", "head", ",", "String", "...", "parts", ")", "{", "IPath", "path", "=", "Path", ".", "fromOSString", "(", "head", ")", ";", "for", "(", "String", "part", ":", "parts", ")", "{", "path", "=", "path", ".", "append", "(", "part", ")", ";", "}", "return", "path", ".", "toOSString", "(", ")", ".", "replace", "(", "'\\\\'", ",", "'/'", ")", ";", "}", "public", "static", "String", "getBaseName", "(", "String", "path", ")", "{", "IPath", "p", "=", "Path", ".", "fromOSString", "(", "path", ")", ";", "return", "p", ".", "segment", "(", "p", ".", "segmentCount", "(", ")", "-", "1", ")", ";", "}", "public", "static", "String", "getExtension", "(", "String", "path", ")", "{", "String", "ext", "=", "Path", ".", "fromOSString", "(", "path", ")", ".", "getFileExtension", "(", ")", ";", "if", "(", "ext", "==", "null", ")", "{", "return", "StringUtils", ".", "EMPTY", ";", "}", "return", "ext", ";", "}", "public", "static", "String", "getPath", "(", "String", "path", ")", "{", "IPath", "p", "=", "null", ";", "int", "index", "=", "path", ".", "indexOf", "(", "':'", ")", ";", "if", "(", "index", "!=", "-", "1", ")", "{", "p", "=", "new", "Path", "(", "path", ".", "substring", "(", "index", "+", "1", ")", ")", ";", "}", "else", "{", "p", "=", "new", "Path", "(", "path", ")", ";", "}", "if", "(", "!", "p", ".", "hasTrailingSeparator", "(", ")", ")", "{", "p", "=", "p", ".", "uptoSegment", "(", "p", ".", "segmentCount", "(", ")", "-", "1", ")", ";", "}", "return", "p", ".", "makeRelative", "(", ")", ".", "addTrailingSeparator", "(", ")", ".", "toOSString", "(", ")", ";", "}", "public", "static", "String", "getFullPath", "(", "String", "path", ")", "{", "IPath", "p", "=", "Path", ".", "fromOSString", "(", "path", ")", ";", "if", "(", "!", "p", ".", "hasTrailingSeparator", "(", ")", ")", "{", "p", "=", "p", ".", "uptoSegment", "(", "p", ".", "segmentCount", "(", ")", "-", "1", ")", ";", "}", "return", "p", ".", "addTrailingSeparator", "(", ")", ".", "toOSString", "(", ")", ";", "}", "public", "static", "String", "getFileName", "(", "String", "path", ")", "{", "IPath", "p", "=", "Path", ".", "fromOSString", "(", "path", ")", ";", "if", "(", "p", ".", "hasTrailingSeparator", "(", ")", ")", "{", "return", "StringUtils", ".", "EMPTY", ";", "}", "return", "p", ".", "removeFileExtension", "(", ")", ".", "segment", "(", "p", ".", "segmentCount", "(", ")", "-", "1", ")", ";", "}", "public", "static", "String", "removeExtension", "(", "String", "path", ")", "{", "return", "Path", ".", "fromOSString", "(", "path", ")", ".", "removeFileExtension", "(", ")", ".", "toOSString", "(", ")", ";", "}", "public", "static", "String", "addTrailingSlash", "(", "String", "path", ")", "{", "if", "(", "!", "path", ".", "endsWith", "(", "\"/\"", ")", ")", "{", "return", "path", "+=", "'/'", ";", "}", "return", "path", ";", "}", "public", "static", "String", "removeTrailingSlash", "(", "String", "path", ")", "{", "if", "(", "path", ".", "endsWith", "(", "\"/\"", ")", ")", "{", "return", "path", ".", "substring", "(", "0", ",", "path", ".", "length", "(", ")", "-", "1", ")", ";", "}", "return", "path", ";", "}", "public", "static", "String", "separatorsToUnix", "(", "String", "path", ")", "{", "if", "(", "path", "==", "null", "||", "path", ".", "indexOf", "(", "WINDOWS_SEPARATOR", ")", "==", "-", "1", ")", "{", "return", "path", ";", "}", "return", "path", ".", "replace", "(", "WINDOWS_SEPARATOR", ",", "UNIX_SEPARATOR", ")", ";", "}", "public", "static", "void", "deleteDirectory", "(", "File", "dir", ")", "{", "if", "(", "!", "dir", ".", "exists", "(", ")", ")", "{", "return", ";", "}", "for", "(", "File", "f", ":", "dir", ".", "listFiles", "(", ")", ")", "{", "if", "(", "f", ".", "isDirectory", "(", ")", ")", "{", "deleteDirectory", "(", "f", ")", ";", "}", "else", "{", "f", ".", "delete", "(", ")", ";", "}", "}", "dir", ".", "delete", "(", ")", ";", "}", "}", "</s>" ]
1,436
[ "<s>", "package", "org", ".", "eclim", ".", "util", ".", "file", ";", "import", "java", ".", "io", ".", "InputStream", ";", "import", "java", ".", "io", ".", "InputStreamReader", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "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", ".", "util", ".", "IOUtils", ";", "public", "class", "FileOffsets", "{", "private", "Integer", "[", "]", "offsets", ";", "private", "String", "[", "]", "multiByteLines", ";", "private", "FileOffsets", "(", ")", "{", "}", "public", "static", "FileOffsets", "compile", "(", "String", "filename", ")", "{", "try", "{", "FileSystemManager", "fsManager", "=", "VFS", ".", "getManager", "(", ")", ";", "FileObject", "file", "=", "fsManager", ".", "resolveFile", "(", "filename", ")", ";", "if", "(", "!", "file", ".", "exists", "(", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "Services", ".", "getMessage", "(", "\"\"", ",", "filename", ")", ")", ";", "}", "return", "compile", "(", "file", ".", "getContent", "(", ")", ".", "getInputStream", "(", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "}", "public", "static", "FileOffsets", "compile", "(", "InputStream", "in", ")", "{", "FileOffsets", "offsets", "=", "new", "FileOffsets", "(", ")", ";", "offsets", ".", "compileOffsets", "(", "in", ")", ";", "return", "offsets", ";", "}", "private", "void", "compileOffsets", "(", "InputStream", "in", ")", "{", "BufferedReader", "reader", "=", "null", ";", "try", "{", "reader", "=", "new", "BufferedReader", "(", "new", "InputStreamReader", "(", "in", ")", ")", ";", "ArrayList", "<", "Integer", ">", "lines", "=", "new", "ArrayList", "<", "Integer", ">", "(", ")", ";", "lines", ".", "add", "(", "new", "Integer", "(", "0", ")", ")", ";", "ArrayList", "<", "String", ">", "byteLines", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "byteLines", ".", "add", "(", "null", ")", ";", "int", "offset", "=", "0", ";", "String", "line", "=", "null", ";", "while", "(", "(", "line", "=", "reader", ".", "readLine", "(", ")", ")", "!=", "null", ")", "{", "offset", "+=", "line", ".", "length", "(", ")", ";", "lines", ".", "add", "(", "new", "Integer", "(", "offset", ")", ")", ";", "if", "(", "line", ".", "length", "(", ")", "!=", "line", ".", "getBytes", "(", ")", ".", "length", ")", "{", "byteLines", ".", "add", "(", "line", ")", ";", "}", "else", "{", "byteLines", ".", "add", "(", "null", ")", ";", "}", "}", "offsets", "=", "(", "Integer", "[", "]", ")", "lines", ".", "toArray", "(", "new", "Integer", "[", "lines", ".", "size", "(", ")", "]", ")", ";", "multiByteLines", "=", "(", "String", "[", "]", ")", "byteLines", ".", "toArray", "(", "new", "String", "[", "byteLines", ".", "size", "(", ")", "]", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "finally", "{", "IOUtils", ".", "closeQuietly", "(", "reader", ")", ";", "}", "}", "public", "int", "[", "]", "offsetToLineColumn", "(", "int", "offset", ")", "{", "if", "(", "offset", "<=", "0", ")", "{", "return", "new", "int", "[", "]", "{", "1", ",", "1", "}", ";", "}", "int", "bot", "=", "-", "1", ";", "int", "top", "=", "offsets", ".", "length", "-", "1", ";", "while", "(", "top", "-", "bot", ">", "1", ")", "{", "int", "mid", "=", "(", "top", "+", "bot", ")", "/", "2", ";", "if", "(", "offsets", "[", "mid", "]", ".", "intValue", "(", ")", "<", "offset", ")", "{", "bot", "=", "mid", ";", "}", "else", "{", "top", "=", "mid", ";", "}", "}", "if", "(", "offsets", "[", "top", "]", ".", "intValue", "(", ")", ">", "offset", ")", "{", "top", "--", ";", "}", "int", "line", "=", "top", "+", "1", ";", "int", "column", "=", "1", "+", "offset", "-", "offsets", "[", "top", "]", ".", "intValue", "(", ")", ";", "String", "value", "=", "multiByteLines", ".", "length", ">", "line", "?", "multiByteLines", "[", "line", "]", ":", "null", ";", "if", "(", "value", "!=", "null", ")", "{", "column", "=", "value", ".", "substring", "(", "0", ",", "column", ")", ".", "getBytes", "(", ")", ".", "length", ";", "}", "return", "new", "int", "[", "]", "{", "line", ",", "column", "}", ";", "}", "public", "int", "getLineStart", "(", "int", "line", ")", "{", "return", "offsets", "[", "line", "-", "1", "]", ".", "intValue", "(", ")", ";", "}", "public", "int", "getLineEnd", "(", "int", "line", ")", "{", "if", "(", "offsets", ".", "length", "==", "line", ")", "{", "return", "offsets", "[", "offsets", ".", "length", "-", "1", "]", ".", "intValue", "(", ")", ";", "}", "return", "offsets", "[", "line", "]", ".", "intValue", "(", ")", "-", "1", ";", "}", "}", "</s>" ]
1,437
[ "<s>", "package", "org", ".", "eclim", ".", "util", ";", "import", "java", ".", "util", ".", "Collection", ";", "public", "class", "CollectionUtils", "{", "private", "CollectionUtils", "(", ")", "{", "}", "@", "SuppressWarnings", "(", "{", "\"rawtypes\"", ",", "\"unchecked\"", "}", ")", "public", "static", "void", "addAll", "(", "Collection", "collection", ",", "Object", "[", "]", "array", ")", "{", "for", "(", "Object", "obj", ":", "array", ")", "{", "collection", ".", "add", "(", "obj", ")", ";", "}", "}", "}", "</s>" ]
1,438
[ "<s>", "package", "org", ".", "eclim", ".", "util", ";", "import", "java", ".", "util", ".", "Map", ";", "public", "class", "StringUtils", "extends", "org", ".", "apache", ".", "commons", ".", "lang", ".", "StringUtils", "{", "private", "static", "final", "String", "PLACEHOLDER_PREFIX", "=", "\"${\"", ";", "private", "static", "final", "String", "PLACEHOLDER_SUFFIX", "=", "\"}\"", ";", "@", "SuppressWarnings", "(", "\"rawtypes\"", ")", "public", "static", "String", "replacePlaceholders", "(", "String", "string", ",", "Map", "values", ")", "{", "if", "(", "string", "==", "null", "||", "values", "==", "null", ")", "{", "return", "string", ";", "}", "StringBuffer", "buffer", "=", "new", "StringBuffer", "(", "string", ")", ";", "int", "start", "=", "buffer", ".", "indexOf", "(", "PLACEHOLDER_PREFIX", ")", ";", "int", "end", "=", "buffer", ".", "indexOf", "(", "PLACEHOLDER_SUFFIX", ")", ";", "while", "(", "start", "!=", "-", "1", "&&", "end", "!=", "-", "1", ")", "{", "String", "placeholder", "=", "buffer", ".", "substring", "(", "start", "+", "PLACEHOLDER_PREFIX", ".", "length", "(", ")", ",", "end", ")", ";", "Object", "value", "=", "values", ".", "get", "(", "placeholder", ")", ";", "if", "(", "value", "!=", "null", ")", "{", "buffer", ".", "replace", "(", "start", ",", "end", "+", "1", ",", "value", ".", "toString", "(", ")", ")", ";", "}", "start", "=", "buffer", ".", "indexOf", "(", "PLACEHOLDER_PREFIX", ",", "start", "+", "1", ")", ";", "end", "=", "buffer", ".", "indexOf", "(", "PLACEHOLDER_SUFFIX", ",", "start", "+", "1", ")", ";", "}", "return", "buffer", ".", "toString", "(", ")", ";", "}", "}", "</s>" ]
1,439
[ "<s>", "package", "org", ".", "eclim", ".", "util", ";", "import", "java", ".", "io", ".", "BufferedReader", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "io", ".", "InputStream", ";", "import", "java", ".", "io", ".", "InputStreamReader", ";", "import", "java", ".", "io", ".", "OutputStream", ";", "import", "java", ".", "io", ".", "OutputStreamWriter", ";", "import", "java", ".", "io", ".", "PrintWriter", ";", "import", "java", ".", "io", ".", "Reader", ";", "import", "java", ".", "io", ".", "StringWriter", ";", "import", "java", ".", "io", ".", "Writer", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "List", ";", "public", "class", "IOUtils", "{", "private", "static", "final", "int", "DEFAULT_BUFFER_SIZE", "=", "1024", "*", "4", ";", "private", "IOUtils", "(", ")", "{", "}", "public", "static", "void", "closeQuietly", "(", "InputStream", "stream", ")", "{", "try", "{", "if", "(", "stream", "!=", "null", ")", "{", "stream", ".", "close", "(", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "}", "}", "public", "static", "void", "closeQuietly", "(", "OutputStream", "stream", ")", "{", "try", "{", "if", "(", "stream", "!=", "null", ")", "{", "stream", ".", "close", "(", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "}", "}", "public", "static", "void", "closeQuietly", "(", "Reader", "stream", ")", "{", "try", "{", "if", "(", "stream", "!=", "null", ")", "{", "stream", ".", "close", "(", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "}", "}", "public", "static", "void", "closeQuietly", "(", "Writer", "stream", ")", "{", "try", "{", "if", "(", "stream", "!=", "null", ")", "{", "stream", ".", "close", "(", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "}", "}", "public", "static", "void", "copy", "(", "InputStream", "in", ",", "OutputStream", "out", ")", "throws", "IOException", "{", "byte", "[", "]", "buffer", "=", "new", "byte", "[", "DEFAULT_BUFFER_SIZE", "]", ";", "int", "n", "=", "0", ";", "while", "(", "-", "1", "!=", "(", "n", "=", "in", ".", "read", "(", "buffer", ")", ")", ")", "{", "out", ".", "write", "(", "buffer", ",", "0", ",", "n", ")", ";", "}", "}", "public", "static", "void", "copy", "(", "Reader", "in", ",", "Writer", "out", ")", "throws", "IOException", "{", "char", "[", "]", "buffer", "=", "new", "char", "[", "DEFAULT_BUFFER_SIZE", "]", ";", "int", "n", "=", "0", ";", "while", "(", "-", "1", "!=", "(", "n", "=", "in", ".", "read", "(", "buffer", ")", ")", ")", "{", "out", ".", "write", "(", "buffer", ",", "0", ",", "n", ")", ";", "}", "}", "public", "static", "List", "<", "String", ">", "readLines", "(", "InputStream", "in", ")", "throws", "IOException", "{", "BufferedReader", "reader", "=", "new", "BufferedReader", "(", "new", "InputStreamReader", "(", "in", ")", ")", ";", "ArrayList", "<", "String", ">", "lines", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "String", "line", "=", "null", ";", "while", "(", "(", "line", "=", "reader", ".", "readLine", "(", ")", ")", "!=", "null", ")", "{", "lines", ".", "add", "(", "line", ")", ";", "}", "return", "lines", ";", "}", "public", "static", "void", "writeLines", "(", "List", "<", "String", ">", "lines", ",", "OutputStream", "out", ")", "throws", "IOException", "{", "PrintWriter", "writer", "=", "new", "PrintWriter", "(", "new", "OutputStreamWriter", "(", "out", ")", ")", ";", "for", "(", "String", "line", ":", "lines", ")", "{", "writer", ".", "println", "(", "line", ")", ";", "}", "writer", ".", "flush", "(", ")", ";", "}", "public", "static", "String", "toString", "(", "InputStream", "in", ")", "throws", "IOException", "{", "return", "toString", "(", "new", "InputStreamReader", "(", "in", ")", ")", ";", "}", "public", "static", "String", "toString", "(", "Reader", "in", ")", "throws", "IOException", "{", "StringWriter", "out", "=", "new", "StringWriter", "(", ")", ";", "copy", "(", "in", ",", "out", ")", ";", "return", "out", ".", "toString", "(", ")", ";", "}", "}", "</s>" ]
1,440
[ "<s>", "package", "org", ".", "eclim", ".", "command", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang", ".", "builder", ".", "EqualsBuilder", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang", ".", "builder", ".", "HashCodeBuilder", ";", "import", "org", ".", "eclim", ".", "util", ".", "StringUtils", ";", "public", "class", "Error", "{", "private", "String", "message", ";", "private", "String", "filename", ";", "private", "int", "line", ";", "private", "int", "column", ";", "private", "int", "endLine", ";", "private", "int", "endColumn", ";", "private", "boolean", "warning", ";", "public", "Error", "(", "String", "message", ",", "String", "filename", ",", "int", "line", ",", "int", "column", ",", "boolean", "warning", ")", "{", "this", "(", "message", ",", "filename", ",", "line", ",", "column", ",", "-", "1", ",", "-", "1", ",", "warning", ")", ";", "}", "public", "Error", "(", "String", "message", ",", "String", "filename", ",", "int", "line", ",", "int", "column", ",", "int", "endLine", ",", "int", "endColumn", ",", "boolean", "warning", ")", "{", "this", ".", "message", "=", "message", "!=", "null", "?", "message", ":", "StringUtils", ".", "EMPTY", ";", "this", ".", "filename", "=", "filename", ";", "this", ".", "line", "=", "line", ">", "0", "?", "line", ":", "1", ";", "this", ".", "column", "=", "column", ">", "0", "?", "column", ":", "1", ";", "this", ".", "endLine", "=", "endLine", ";", "this", ".", "endColumn", "=", "endColumn", ";", "this", ".", "warning", "=", "warning", ";", "}", "public", "String", "getMessage", "(", ")", "{", "return", "message", "!=", "null", "?", "message", ":", "StringUtils", ".", "EMPTY", ";", "}", "public", "String", "getFilename", "(", ")", "{", "return", "filename", ";", "}", "public", "int", "getLine", "(", ")", "{", "return", "line", ";", "}", "public", "int", "getColumn", "(", ")", "{", "return", "this", ".", "column", ";", "}", "public", "int", "getEndLine", "(", ")", "{", "return", "this", ".", "endLine", ";", "}", "public", "int", "getEndColumn", "(", ")", "{", "return", "this", ".", "endColumn", ";", "}", "public", "boolean", "isWarning", "(", ")", "{", "return", "warning", ";", "}", "public", "boolean", "equals", "(", "Object", "other", ")", "{", "if", "(", "!", "(", "other", "instanceof", "Error", ")", ")", "{", "return", "false", ";", "}", "if", "(", "this", "==", "other", ")", "{", "return", "true", ";", "}", "Error", "error", "=", "(", "Error", ")", "other", ";", "boolean", "equal", "=", "new", "EqualsBuilder", "(", ")", ".", "append", "(", "getFilename", "(", ")", ",", "error", ".", "getFilename", "(", ")", ")", ".", "append", "(", "getLine", "(", ")", ",", "error", ".", "getLine", "(", ")", ")", ".", "append", "(", "getColumn", "(", ")", ",", "error", ".", "getColumn", "(", ")", ")", ".", "append", "(", "getEndLine", "(", ")", ",", "error", ".", "getEndLine", "(", ")", ")", ".", "append", "(", "getEndColumn", "(", ")", ",", "error", ".", "getEndColumn", "(", ")", ")", ".", "append", "(", "getMessage", "(", ")", ",", "error", ".", "getMessage", "(", ")", ")", ".", "isEquals", "(", ")", ";", "return", "equal", ";", "}", "public", "int", "hashCode", "(", ")", "{", "return", "new", "HashCodeBuilder", "(", "17", ",", "37", ")", ".", "append", "(", "filename", ")", ".", "append", "(", "line", ")", ".", "append", "(", "column", ")", ".", "append", "(", "endLine", ")", ".", "append", "(", "endColumn", ")", ".", "append", "(", "message", ")", ".", "toHashCode", "(", ")", ";", "}", "}", "</s>" ]
1,441
[ "<s>", "package", "org", ".", "eclim", ".", "command", ";", "import", "java", ".", "util", ".", "Arrays", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "org", ".", "apache", ".", "commons", ".", "cli", ".", "Option", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang", ".", "StringUtils", ";", "public", "class", "CommandLine", "{", "private", "HashMap", "<", "String", ",", "Object", ">", "options", "=", "new", "HashMap", "<", "String", ",", "Object", ">", "(", ")", ";", "private", "Command", "command", ";", "private", "String", "[", "]", "args", ";", "private", "String", "[", "]", "unrecognized", ";", "public", "CommandLine", "(", "Command", "command", ",", "org", ".", "apache", ".", "commons", ".", "cli", ".", "CommandLine", "commandLine", ",", "String", "[", "]", "args", ")", "{", "this", ".", "command", "=", "command", ";", "this", ".", "args", "=", "args", ";", "Option", "[", "]", "options", "=", "commandLine", ".", "getOptions", "(", ")", ";", "for", "(", "Option", "option", ":", "options", ")", "{", "if", "(", "option", ".", "hasArgs", "(", ")", ")", "{", "this", ".", "options", ".", "put", "(", "option", ".", "getOpt", "(", ")", ",", "commandLine", ".", "getOptionValues", "(", "option", ".", "getOpt", "(", ")", ")", ")", ";", "}", "else", "{", "this", ".", "options", ".", "put", "(", "option", ".", "getOpt", "(", ")", ",", "commandLine", ".", "getOptionValue", "(", "option", ".", "getOpt", "(", ")", ")", ")", ";", "}", "}", "unrecognized", "=", "commandLine", ".", "getArgs", "(", ")", ";", "}", "public", "Command", "getCommand", "(", ")", "{", "return", "this", ".", "command", ";", "}", "public", "boolean", "hasOption", "(", "String", "name", ")", "{", "return", "options", ".", "containsKey", "(", "name", ")", ";", "}", "public", "String", "getValue", "(", "String", "name", ")", "throws", "Exception", "{", "String", "value", "=", "null", ";", "Object", "val", "=", "options", ".", "get", "(", "name", ")", ";", "if", "(", "val", "!=", "null", ")", "{", "if", "(", "val", ".", "getClass", "(", ")", ".", "isArray", "(", ")", ")", "{", "value", "=", "(", "(", "String", "[", "]", ")", "val", ")", "[", "0", "]", ";", "}", "else", "{", "value", "=", "(", "String", ")", "val", ";", "}", "value", "=", "StringUtils", ".", "replace", "(", "value", ",", "\"%2A\"", ",", "\"*\"", ")", ";", "value", "=", "StringUtils", ".", "replace", "(", "value", ",", "\"%24\"", ",", "\"$\"", ")", ";", "value", "=", "StringUtils", ".", "replace", "(", "value", ",", "\"%3C\"", ",", "\"<\"", ")", ";", "value", "=", "StringUtils", ".", "replace", "(", "value", ",", "\"%3E\"", ",", "\">\"", ")", ";", "return", "value", ";", "}", "return", "null", ";", "}", "public", "Object", "getRawValue", "(", "String", "name", ")", "throws", "Exception", "{", "return", "options", ".", "get", "(", "name", ")", ";", "}", "public", "String", "getValue", "(", "String", "name", ",", "String", "dflt", ")", "throws", "Exception", "{", "String", "value", "=", "getValue", "(", "name", ")", ";", "return", "value", "!=", "null", "?", "value", ":", "dflt", ";", "}", "public", "String", "[", "]", "getValues", "(", "String", "name", ")", "throws", "Exception", "{", "String", "[", "]", "values", "=", "null", ";", "Object", "val", "=", "options", ".", "get", "(", "name", ")", ";", "if", "(", "val", "!=", "null", ")", "{", "if", "(", "!", "val", ".", "getClass", "(", ")", ".", "isArray", "(", ")", ")", "{", "values", "=", "new", "String", "[", "]", "{", "(", "String", ")", "val", "}", ";", "}", "else", "{", "values", "=", "(", "String", "[", "]", ")", "val", ";", "}", "for", "(", "int", "ii", "=", "0", ";", "ii", "<", "values", ".", "length", ";", "ii", "++", ")", "{", "values", "[", "ii", "]", "=", "StringUtils", ".", "replace", "(", "values", "[", "ii", "]", ",", "\"%2A\"", ",", "\"*\"", ")", ";", "values", "[", "ii", "]", "=", "StringUtils", ".", "replace", "(", "values", "[", "ii", "]", ",", "\"%24\"", ",", "\"$\"", ")", ";", "values", "[", "ii", "]", "=", "StringUtils", ".", "replace", "(", "values", "[", "ii", "]", ",", "\"%3C\"", ",", "\"<\"", ")", ";", "values", "[", "ii", "]", "=", "StringUtils", ".", "replace", "(", "values", "[", "ii", "]", ",", "\"%3E\"", ",", "\">\"", ")", ";", "if", "(", "values", "[", "ii", "]", ".", "startsWith", "(", "\"\\\\-\"", ")", ")", "{", "values", "[", "ii", "]", "=", "values", "[", "ii", "]", ".", "substring", "(", "1", ")", ";", "}", "}", "return", "values", ";", "}", "return", "null", ";", "}", "public", "int", "getIntValue", "(", "String", "name", ")", "throws", "Exception", "{", "String", "arg", "=", "getValue", "(", "name", ")", ";", "return", "arg", "!=", "null", "?", "Integer", ".", "parseInt", "(", "arg", ")", ":", "-", "1", ";", "}", "public", "long", "getLongValue", "(", "String", "name", ")", "throws", "Exception", "{", "String", "arg", "=", "getValue", "(", "name", ")", ";", "return", "arg", "!=", "null", "?", "Long", ".", "parseLong", "(", "arg", ")", ":", "-", "1", ";", "}", "public", "String", "[", "]", "getUnrecognizedArgs", "(", ")", "{", "return", "unrecognized", ";", "}", "public", "String", "[", "]", "getArgs", "(", ")", "{", "return", "args", ";", "}", "public", "void", "addOption", "(", "String", "option", ",", "String", "value", ")", "{", "options", ".", "put", "(", "option", ",", "value", ")", ";", "}", "public", "String", "toString", "(", ")", "{", "StringBuffer", "buffer", "=", "new", "StringBuffer", "(", ")", ";", "for", "(", "Map", ".", "Entry", "<", "String", ",", "Object", ">", "entry", ":", "this", ".", "options", ".", "entrySet", "(", ")", ")", "{", "buffer", ".", "append", "(", "\"option:", "\"", ")", ".", "append", "(", "entry", ".", "getKey", "(", ")", ")", ";", "buffer", ".", "append", "(", "\"", "args:", "\"", ")", ";", "Object", "value", "=", "entry", ".", "getValue", "(", ")", ";", "if", "(", "value", "instanceof", "Object", "[", "]", ")", "{", "buffer", ".", "append", "(", "Arrays", ".", "toString", "(", "(", "Object", "[", "]", ")", "value", ")", ")", ";", "}", "else", "{", "buffer", ".", "append", "(", "value", ")", ";", "}", "buffer", ".", "append", "(", "'\\n'", ")", ";", "}", "if", "(", "unrecognized", "!=", "null", "&&", "unrecognized", ".", "length", ">", "0", ")", "{", "buffer", ".", "append", "(", "\"\"", "+", "Arrays", ".", "toString", "(", "unrecognized", ")", ")", ";", "}", "return", "buffer", ".", "toString", "(", ")", ";", "}", "}", "</s>" ]
1,442
[ "<s>", "package", "org", ".", "eclim", ".", "command", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Collection", ";", "import", "org", ".", "apache", ".", "commons", ".", "cli", ".", "CommandLineParser", ";", "import", "org", ".", "apache", ".", "commons", ".", "cli", ".", "GnuParser", ";", "import", "org", ".", "apache", ".", "commons", ".", "cli", ".", "Option", ";", "import", "org", ".", "apache", ".", "commons", ".", "cli", ".", "OptionBuilder", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang", ".", "StringUtils", ";", "import", "org", ".", "eclim", ".", "Services", ";", "@", "SuppressWarnings", "(", "\"\"", ")", "public", "class", "Options", "{", "public", "static", "final", "String", "COMMAND_OPTION", "=", "\"command\"", ";", "public", "static", "final", "String", "PRETTY_OPTION", "=", "\"pretty\"", ";", "public", "static", "final", "String", "EDITOR_OPTION", "=", "\"editor\"", ";", "public", "static", "final", "String", "ACTION_OPTION", "=", "\"a\"", ";", "public", "static", "final", "String", "APPLY_OPTION", "=", "\"a\"", ";", "public", "static", "final", "String", "ARGS_OPTION", "=", "\"a\"", ";", "public", "static", "final", "String", "BASEDIR_OPTION", "=", "\"b\"", ";", "public", "static", "final", "String", "BUILD_OPTION", "=", "\"b\"", ";", "public", "static", "final", "String", "BUILD_FILE_OPTION", "=", "\"b\"", ";", "public", "static", "final", "String", "CASE_INSENSITIVE_OPTION", "=", "\"i\"", ";", "public", "static", "final", "String", "CLASSNAME_OPTION", "=", "\"c\"", ";", "public", "static", "final", "String", "CONTEXT_OPTION", "=", "\"x\"", ";", "public", "static", "final", "String", "DEBUG_OPTION", "=", "\"d\"", ";", "public", "static", "final", "String", "DELIMETER_OPTION", "=", "\"d\"", ";", "public", "static", "final", "String", "DEPENDS_OPTION", "=", "\"d\"", ";", "public", "static", "final", "String", "DEST_OPTION", "=", "\"d\"", ";", "public", "static", "final", "String", "DIR_OPTION", "=", "\"d\"", ";", "public", "static", "final", "String", "ENCODING_OPTION", "=", "\"e\"", ";", "public", "static", "final", "String", "EXCLUDES_OPTION", "=", "\"e\"", ";", "public", "static", "final", "String", "ERRORS_OPTION", "=", "\"e\"", ";", "public", "static", "final", "String", "FAMILY_OPTION", "=", "\"f\"", ";", "public", "static", "final", "String", "FILE_OPTION", "=", "\"f\"", ";", "public", "static", "final", "String", "FOLDER_OPTION", "=", "\"f\"", ";", "public", "static", "final", "String", "HELP", "=", "\"help\"", ";", "public", "static", "final", "String", "HALT_OPTION", "=", "\"h\"", ";", "public", "static", "final", "String", "INDENT_OPTION", "=", "\"i\"", ";", "public", "static", "final", "String", "INDEXED_OPTION", "=", "\"i\"", ";", "public", "static", "final", "String", "JARS_OPTION", "=", "\"j\"", ";", "public", "static", "final", "String", "LANG_OPTION", "=", "\"l\"", ";", "public", "static", "final", "String", "LAYOUT_OPTION", "=", "\"l\"", ";", "public", "static", "final", "String", "LENGTH_OPTION", "=", "\"l\"", ";", "public", "static", "final", "String", "LINE_OPTION", "=", "\"l\"", ";", "public", "static", "final", "String", "LINE_WIDTH_OPTION", "=", "\"w\"", ";", "public", "static", "final", "String", "METHOD_OPTION", "=", "\"m\"", ";", "public", "static", "final", "String", "NAME_OPTION", "=", "\"n\"", ";", "public", "static", "final", "String", "NATURE_OPTION", "=", "\"n\"", ";", "public", "static", "final", "String", "OFFSET_OPTION", "=", "\"o\"", ";", "public", "static", "final", "String", "PATH_OPTION", "=", "\"p\"", ";", "public", "static", "final", "String", "PATTERN_OPTION", "=", "\"p\"", ";", "public", "static", "final", "String", "PEEK_OPTION", "=", "\"p\"", ";", "public", "static", "final", "String", "PROJECT_OPTION", "=", "\"p\"", ";", "public", "static", "final", "String", "PROPERTIES_OPTION", "=", "\"r\"", ";", "public", "static", "final", "String", "REVISION_OPTION", "=", "\"r\"", ";", "public", "static", "final", "String", "SCHEMA_OPTION", "=", "\"s\"", ";", "public", "static", "final", "String", "SCOPE_OPTION", "=", "\"s\"", ";", "public", "static", "final", "String", "SEARCH_OPTION", "=", "\"s\"", ";", "public", "static", "final", "String", "SETTINGS_OPTION", "=", "\"s\"", ";", "public", "static", "final", "String", "SETTING_OPTION", "=", "\"s\"", ";", "public", "static", "final", "String", "SOURCE_OPTION", "=", "\"s\"", ";", "public", "static", "final", "String", "SUPERTYPE_OPTION", "=", "\"s\"", ";", "public", "static", "final", "String", "TEMPLATE_OPTION", "=", "\"t\"", ";", "public", "static", "final", "String", "TEST_OPTION", "=", "\"t\"", ";", "public", "static", "final", "String", "TYPE_OPTION", "=", "\"t\"", ";", "public", "static", "final", "String", "URL_OPTION", "=", "\"u\"", ";", "public", "static", "final", "String", "VALIDATE_OPTION", "=", "\"v\"", ";", "public", "static", "final", "String", "VALUE_OPTION", "=", "\"v\"", ";", "public", "static", "final", "String", "VALUES_OPTION", "=", "\"v\"", ";", "public", "static", "final", "String", "VARIABLE_OPTION", "=", "\"v\"", ";", "private", "static", "final", "String", "ANY", "=", "\"ANY\"", ";", "private", "static", "final", "String", "ARG", "=", "\"ARG\"", ";", "private", "static", "final", "String", "REQUIRED", "=", "\"REQUIRED\"", ";", "private", "static", "org", ".", "apache", ".", "commons", ".", "cli", ".", "Options", "coreOptions", "=", "new", "org", ".", "apache", ".", "commons", ".", "cli", ".", "Options", "(", ")", ";", "static", "{", "coreOptions", ".", "addOption", "(", "OptionBuilder", ".", "withArgName", "(", "COMMAND_OPTION", ")", ".", "isRequired", "(", "true", ")", ".", "hasArg", "(", ")", ".", "withDescription", "(", "Services", ".", "getMessage", "(", "\"\"", ")", ")", ".", "create", "(", "COMMAND_OPTION", ")", ")", ";", "coreOptions", ".", "addOption", "(", "OptionBuilder", ".", "withArgName", "(", "PRETTY_OPTION", ")", ".", "withDescription", "(", "Services", ".", "getMessage", "(", "\"\"", ")", ")", ".", "create", "(", "PRETTY_OPTION", ")", ")", ";", "coreOptions", ".", "addOption", "(", "OptionBuilder", ".", "withArgName", "(", "EDITOR_OPTION", ")", ".", "hasArg", "(", ")", ".", "withDescription", "(", "Services", ".", "getMessage", "(", "\"\"", ")", ")", ".", "create", "(", "EDITOR_OPTION", ")", ")", ";", "}", "protected", "org", ".", "apache", ".", "commons", ".", "cli", ".", "Options", "options", "=", "new", "org", ".", "apache", ".", "commons", ".", "cli", ".", "Options", "(", ")", ";", "protected", "CommandLine", "commandLine", ";", "public", "Options", "(", ")", "{", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "Collection", "<", "Option", ">", "opts", "=", "coreOptions", ".", "getOptions", "(", ")", ";", "for", "(", "Option", "option", ":", "opts", ")", "{", "options", ".", "addOption", "(", "option", ")", ";", "}", "}", "public", "CommandLine", "parse", "(", "String", "[", "]", "args", ")", "throws", "Exception", "{", "String", "commandName", "=", "null", ";", "for", "(", "int", "ii", "=", "0", ";", "ii", "<", "args", ".", "length", ";", "ii", "++", ")", "{", "if", "(", "args", "[", "ii", "]", ".", "equals", "(", "'-'", "+", "COMMAND_OPTION", ")", ")", "{", "if", "(", "args", ".", "length", ">", "ii", "+", "1", ")", "{", "commandName", "=", "args", "[", "ii", "+", "1", "]", ".", "trim", "(", ")", ";", "}", "break", ";", "}", "}", "Command", "command", "=", "null", ";", "if", "(", "commandName", "!=", "null", ")", "{", "command", "=", "Services", ".", "getCommand", "(", "commandName", ")", ";", "if", "(", "command", "==", "null", ")", "{", "throw", "new", "RuntimeException", "(", "Services", ".", "getMessage", "(", "\"\"", ",", "commandName", ")", ")", ";", "}", "org", ".", "eclim", ".", "annotation", ".", "Command", "info", "=", "(", "org", ".", "eclim", ".", "annotation", ".", "Command", ")", "command", ".", "getClass", "(", ")", ".", "getAnnotation", "(", "org", ".", "eclim", ".", "annotation", ".", "Command", ".", "class", ")", ";", "Collection", "<", "Option", ">", "commandOptions", "=", "parseOptions", "(", "info", ".", "options", "(", ")", ")", ";", "for", "(", "Option", "option", ":", "commandOptions", ")", "{", "options", ".", "addOption", "(", "option", ")", ";", "}", "}", "CommandLineParser", "parser", "=", "new", "GnuParser", "(", ")", ";", "return", "new", "CommandLine", "(", "command", ",", "parser", ".", "parse", "(", "options", ",", "args", ")", ",", "args", ")", ";", "}", "public", "Collection", "<", "Option", ">", "parseOptions", "(", "String", "optionsString", ")", "{", "ArrayList", "<", "Option", ">", "options", "=", "new", "ArrayList", "<", "Option", ">", "(", ")", ";", "if", "(", "optionsString", "!=", "null", "&&", "optionsString", ".", "trim", "(", ")", ".", "length", "(", ")", ">", "0", ")", "{", "String", "[", "]", "lines", "=", "StringUtils", ".", "split", "(", "optionsString", ",", "','", ")", ";", "for", "(", "int", "ii", "=", "0", ";", "ii", "<", "lines", ".", "length", ";", "ii", "++", ")", "{", "if", "(", "lines", "[", "ii", "]", ".", "trim", "(", ")", ".", "length", "(", ")", ">", "0", ")", "{", "options", ".", "add", "(", "parseOption", "(", "lines", "[", "ii", "]", ".", "trim", "(", ")", ")", ")", ";", "}", "}", "}", "return", "options", ";", "}", "public", "Option", "parseOption", "(", "String", "option", ")", "{", "String", "[", "]", "parts", "=", "StringUtils", ".", "split", "(", "option", ")", ";", "if", "(", "REQUIRED", ".", "equals", "(", "parts", "[", "0", "]", ")", ")", "{", "OptionBuilder", ".", "isRequired", "(", ")", ";", "}", "if", "(", "ARG", ".", "equals", "(", "parts", "[", "3", "]", ")", ")", "{", "OptionBuilder", ".", "hasArg", "(", ")", ";", "}", "else", "if", "(", "ANY", ".", "equals", "(", "parts", "[", "3", "]", ")", ")", "{", "OptionBuilder", ".", "hasOptionalArgs", "(", ")", ";", "}", "OptionBuilder", ".", "withLongOpt", "(", "parts", "[", "2", "]", ")", ";", "return", "OptionBuilder", ".", "create", "(", "parts", "[", "1", "]", ")", ";", "}", "}", "</s>" ]
1,443
[ "<s>", "package", "org", ".", "eclim", ".", "command", ";", "public", "interface", "OutputFilter", "<", "T", ">", "{", "public", "String", "filter", "(", "CommandLine", "commandLine", ",", "T", "result", ")", ";", "}", "</s>" ]
1,444
[ "<s>", "package", "org", ".", "eclim", ".", "command", ";", "import", "java", ".", "io", ".", "PrintStream", ";", "import", "java", ".", "lang", ".", "reflect", ".", "Type", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Arrays", ";", "import", "java", ".", "util", ".", "Collection", ";", "import", "java", ".", "util", ".", "Collections", ";", "import", "java", ".", "util", ".", "Comparator", ";", "import", "java", ".", "util", ".", "Iterator", ";", "import", "org", ".", "apache", ".", "commons", ".", "cli", ".", "Option", ";", "import", "org", ".", "apache", ".", "commons", ".", "cli", ".", "ParseException", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang", ".", "StringUtils", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang", ".", "SystemUtils", ";", "import", "org", ".", "eclim", ".", "Services", ";", "import", "org", ".", "eclim", ".", "logging", ".", "Logger", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Display", ";", "import", "com", ".", "google", ".", "gson", ".", "GsonBuilder", ";", "import", "com", ".", "google", ".", "gson", ".", "JsonElement", ";", "import", "com", ".", "google", ".", "gson", ".", "JsonPrimitive", ";", "import", "com", ".", "google", ".", "gson", ".", "JsonSerializationContext", ";", "import", "com", ".", "google", ".", "gson", ".", "JsonSerializer", ";", "import", "com", ".", "martiansoftware", ".", "nailgun", ".", "NGContext", ";", "public", "class", "Main", "{", "private", "static", "final", "Logger", "logger", "=", "Logger", ".", "getLogger", "(", "Main", ".", "class", ")", ";", "public", "static", "final", "void", "nailMain", "(", "final", "NGContext", "context", ")", "{", "try", "{", "logger", ".", "debug", "(", "\"args:", "\"", "+", "Arrays", ".", "toString", "(", "context", ".", "getArgs", "(", ")", ")", ")", ";", "ArrayList", "<", "String", ">", "arguments", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "for", "(", "String", "arg", ":", "context", ".", "getArgs", "(", ")", ")", "{", "if", "(", "arg", ".", "startsWith", "(", "\"-D\"", ")", ")", "{", "String", "[", "]", "prop", "=", "StringUtils", ".", "split", "(", "arg", ".", "substring", "(", "2", ")", ",", "'='", ")", ";", "System", ".", "setProperty", "(", "prop", "[", "0", "]", ",", "prop", "[", "1", "]", ")", ";", "}", "else", "{", "arguments", ".", "add", "(", "arg", ")", ";", "}", "}", "if", "(", "arguments", ".", "isEmpty", "(", ")", "||", "arguments", ".", "contains", "(", "\"-?\"", ")", ")", "{", "usage", "(", "context", ".", "out", ")", ";", "System", ".", "exit", "(", "arguments", ".", "isEmpty", "(", ")", "?", "1", ":", "0", ")", ";", "}", "Options", "options", "=", "new", "Options", "(", ")", ";", "final", "CommandLine", "commandLine", "=", "options", ".", "parse", "(", "(", "String", "[", "]", ")", "arguments", ".", "toArray", "(", "new", "String", "[", "arguments", ".", "size", "(", ")", "]", ")", ")", ";", "String", "commandName", "=", "commandLine", ".", "getValue", "(", "Options", ".", "COMMAND_OPTION", ")", ";", "logger", ".", "debug", "(", "\"\"", ",", "commandName", ")", ";", "final", "Command", "command", "=", "commandLine", ".", "getCommand", "(", ")", ";", "command", ".", "setContext", "(", "context", ")", ";", "final", "Object", "[", "]", "results", "=", "new", "Object", "[", "1", "]", ";", "Display", ".", "getDefault", "(", ")", ".", "syncExec", "(", "new", "Runnable", "(", ")", "{", "public", "void", "run", "(", ")", "{", "try", "{", "results", "[", "0", "]", "=", "command", ".", "execute", "(", "commandLine", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "results", "[", "0", "]", "=", "e", ";", "}", "finally", "{", "command", ".", "cleanup", "(", "commandLine", ")", ";", "}", "}", "}", ")", ";", "Object", "result", "=", "results", "[", "0", "]", ";", "if", "(", "result", "!=", "null", ")", "{", "if", "(", "result", "instanceof", "Throwable", ")", "{", "throw", "(", "Throwable", ")", "result", ";", "}", "GsonBuilder", "builder", "=", "new", "GsonBuilder", "(", ")", ";", "if", "(", "commandLine", ".", "hasOption", "(", "Options", ".", "PRETTY_OPTION", ")", ")", "{", "builder", "=", "builder", ".", "setPrettyPrinting", "(", ")", ";", "}", "if", "(", "commandLine", ".", "hasOption", "(", "Options", ".", "EDITOR_OPTION", ")", "&&", "commandLine", ".", "getValue", "(", "Options", ".", "EDITOR_OPTION", ")", ".", "equals", "(", "\"vim\"", ")", ")", "{", "builder", "=", "builder", ".", "registerTypeAdapter", "(", "Boolean", ".", "TYPE", ",", "new", "BooleanSerializer", "(", ")", ")", ".", "registerTypeAdapter", "(", "Boolean", ".", "class", ",", "new", "BooleanSerializer", "(", ")", ")", ";", "}", "context", ".", "out", ".", "println", "(", "builder", ".", "create", "(", ")", ".", "toJson", "(", "result", ")", ")", ";", "}", "}", "catch", "(", "ParseException", "e", ")", "{", "context", ".", "out", ".", "println", "(", "Services", ".", "getMessage", "(", "e", ".", "getClass", "(", ")", ".", "getName", "(", ")", ",", "e", ".", "getMessage", "(", ")", ")", ")", ";", "logger", ".", "debug", "(", "\"\"", ")", ";", "System", ".", "exit", "(", "1", ")", ";", "}", "catch", "(", "Throwable", "e", ")", "{", "logger", ".", "debug", "(", "\"\"", "+", "Arrays", ".", "toString", "(", "context", ".", "getArgs", "(", ")", ")", ",", "e", ")", ";", "e", ".", "printStackTrace", "(", "context", ".", "err", ")", ";", "logger", ".", "debug", "(", "\"\"", ")", ";", "System", ".", "exit", "(", "1", ")", ";", "}", "}", "public", "static", "void", "usage", "(", "PrintStream", "out", ")", "{", "ArrayList", "<", "org", ".", "eclim", ".", "annotation", ".", "Command", ">", "commands", "=", "new", "ArrayList", "<", "org", ".", "eclim", ".", "annotation", ".", "Command", ">", "(", ")", ";", "for", "(", "Class", "<", "?", "extends", "Command", ">", "command", ":", "Services", ".", "getCommandClasses", "(", ")", ")", "{", "commands", ".", "add", "(", "command", ".", "getAnnotation", "(", "org", ".", "eclim", ".", "annotation", ".", "Command", ".", "class", ")", ")", ";", "}", "Collections", ".", "sort", "(", "commands", ",", "new", "Comparator", "<", "org", ".", "eclim", ".", "annotation", ".", "Command", ">", "(", ")", "{", "public", "int", "compare", "(", "org", ".", "eclim", ".", "annotation", ".", "Command", "o1", ",", "org", ".", "eclim", ".", "annotation", ".", "Command", "o2", ")", "{", "return", "o1", ".", "name", "(", ")", ".", "compareTo", "(", "o2", ".", "name", "(", ")", ")", ";", "}", "}", ")", ";", "String", "osOpts", "=", "StringUtils", ".", "EMPTY", ";", "if", "(", "SystemUtils", ".", "IS_OS_UNIX", ")", "{", "osOpts", "=", "\"\"", ";", "}", "out", ".", "println", "(", "\"Usage:", "eclim\"", "+", "osOpts", "+", "\"\"", ")", ";", "out", ".", "println", "(", "\"\"", ")", ";", "for", "(", "org", ".", "eclim", ".", "annotation", ".", "Command", "command", ":", "commands", ")", "{", "Collection", "<", "Option", ">", "options", "=", "new", "Options", "(", ")", ".", "parseOptions", "(", "command", ".", "options", "(", ")", ")", ";", "StringBuffer", "opts", "=", "new", "StringBuffer", "(", ")", ";", "Iterator", "<", "Option", ">", "iterator", "=", "options", ".", "iterator", "(", ")", ";", "for", "(", "int", "ii", "=", "0", ";", "iterator", ".", "hasNext", "(", ")", ";", "ii", "++", ")", "{", "Option", "option", "=", "iterator", ".", "next", "(", ")", ";", "opts", ".", "append", "(", "option", ".", "isRequired", "(", ")", "?", "\"", "\"", ":", "\"", "[\"", ")", ";", "opts", ".", "append", "(", "'-'", ")", ".", "append", "(", "option", ".", "getOpt", "(", ")", ")", ";", "if", "(", "option", ".", "hasArg", "(", ")", ")", "{", "opts", ".", "append", "(", "'", "'", ")", ".", "append", "(", "option", ".", "getLongOpt", "(", ")", ")", ";", "}", "if", "(", "!", "option", ".", "isRequired", "(", ")", ")", "{", "opts", ".", "append", "(", "']'", ")", ";", "}", "if", "(", "(", "ii", "+", "1", ")", "%", "4", "==", "0", "&&", "ii", "!=", "options", ".", "size", "(", ")", "-", "1", ")", "{", "opts", ".", "append", "(", "StringUtils", ".", "rightPad", "(", "\"n\"", ",", "command", ".", "name", "(", ")", ".", "length", "(", ")", "+", "5", ")", ")", ";", "}", "}", "StringBuffer", "info", "=", "new", "StringBuffer", "(", ")", ".", "append", "(", "\"", "\"", ")", ".", "append", "(", "command", ".", "name", "(", ")", ")", ".", "append", "(", "opts", ")", ";", "out", ".", "println", "(", "info", ")", ";", "if", "(", "!", "command", ".", "description", "(", ")", ".", "equals", "(", "StringUtils", ".", "EMPTY", ")", ")", "{", "out", ".", "println", "(", "\"", "\"", "+", "command", ".", "description", "(", ")", ")", ";", "}", "}", "}", "private", "static", "class", "BooleanSerializer", "implements", "JsonSerializer", "<", "Boolean", ">", "{", "public", "JsonElement", "serialize", "(", "Boolean", "bool", ",", "Type", "typeOfSrc", ",", "JsonSerializationContext", "context", ")", "{", "return", "new", "JsonPrimitive", "(", "bool", ".", "booleanValue", "(", ")", "?", "1", ":", "0", ")", ";", "}", "}", "}", "</s>" ]
1,445
[ "<s>", "package", "org", ".", "eclim", ".", "command", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "org", ".", "eclim", ".", "Services", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "Platform", ";", "import", "org", ".", "osgi", ".", "framework", ".", "Bundle", ";", "import", "org", ".", "osgi", ".", "framework", ".", "FrameworkListener", ";", "import", "org", ".", "osgi", ".", "framework", ".", "wiring", ".", "FrameworkWiring", ";", "import", "com", ".", "martiansoftware", ".", "nailgun", ".", "NGContext", ";", "@", "org", ".", "eclim", ".", "annotation", ".", "Command", "(", "name", "=", "\"reload\"", ")", "public", "class", "ReloadCommand", "implements", "Command", "{", "private", "NGContext", "context", ";", "@", "Override", "public", "Object", "execute", "(", "CommandLine", "commandLine", ")", "throws", "Exception", "{", "Bundle", "system", "=", "Platform", ".", "getBundle", "(", "\"\"", ")", ";", "FrameworkWiring", "framework", "=", "(", "FrameworkWiring", ")", "system", ".", "adapt", "(", "FrameworkWiring", ".", "class", ")", ";", "ArrayList", "<", "Bundle", ">", "bundles", "=", "new", "ArrayList", "<", "Bundle", ">", "(", ")", ";", "bundles", ".", "add", "(", "Platform", ".", "getBundle", "(", "\"\"", ")", ")", ";", "framework", ".", "refreshBundles", "(", "bundles", ",", "new", "FrameworkListener", "[", "0", "]", ")", ";", "return", "Services", ".", "getMessage", "(", "\"\"", ")", ";", "}", "@", "Override", "public", "NGContext", "getContext", "(", ")", "{", "return", "context", ";", "}", "@", "Override", "public", "void", "setContext", "(", "NGContext", "context", ")", "{", "this", ".", "context", "=", "context", ";", "}", "@", "Override", "public", "void", "cleanup", "(", "CommandLine", "commandLine", ")", "{", "}", "}", "</s>" ]
1,446
[ "<s>", "package", "org", ".", "eclim", ".", "command", ";", "import", "org", ".", "eclim", ".", "command", ".", "CommandLine", ";", "import", "com", ".", "martiansoftware", ".", "nailgun", ".", "NGContext", ";", "public", "interface", "Command", "{", "public", "Object", "execute", "(", "CommandLine", "commandLine", ")", "throws", "Exception", ";", "public", "void", "cleanup", "(", "CommandLine", "commandLine", ")", ";", "public", "NGContext", "getContext", "(", ")", ";", "public", "void", "setContext", "(", "NGContext", "context", ")", ";", "}", "</s>" ]
1,447
[ "<s>", "package", "org", ".", "eclim", ".", "eclipse", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "org", ".", "eclim", ".", "logging", ".", "Logger", ";", "import", "org", ".", "eclipse", ".", "e4", ".", "ui", ".", "internal", ".", "workbench", ".", "E4Workbench", ";", "import", "org", ".", "eclipse", ".", "equinox", ".", "app", ".", "IApplicationContext", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "IWorkbench", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "PlatformUI", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "internal", ".", "ide", ".", "application", ".", "IDEApplication", ";", "public", "class", "EclimApplication", "extends", "IDEApplication", "{", "private", "static", "final", "Logger", "logger", "=", "Logger", ".", "getLogger", "(", "EclimApplication", ".", "class", ")", ";", "private", "static", "EclimApplication", "instance", ";", "private", "static", "boolean", "stopping", ";", "@", "SuppressWarnings", "(", "{", "\"rawtypes\"", ",", "\"unchecked\"", "}", ")", "@", "Override", "public", "Object", "start", "(", "IApplicationContext", "context", ")", "throws", "Exception", "{", "Map", "args", "=", "context", ".", "getArguments", "(", ")", ";", "String", "[", "]", "appArgs", "=", "(", "String", "[", "]", ")", "args", ".", "get", "(", "IApplicationContext", ".", "APPLICATION_ARGS", ")", ";", "String", "[", "]", "presentationArgs", "=", "new", "String", "[", "]", "{", "\"-\"", "+", "E4Workbench", ".", "PERSIST_STATE", ",", "\"false\"", ",", "\"-\"", "+", "E4Workbench", ".", "PRESENTATION_URI_ARG", ",", "\"\"", ",", "}", ";", "String", "[", "]", "newArgs", "=", "new", "String", "[", "appArgs", ".", "length", "+", "presentationArgs", ".", "length", "]", ";", "System", ".", "arraycopy", "(", "appArgs", ",", "0", ",", "newArgs", ",", "0", ",", "appArgs", ".", "length", ")", ";", "System", ".", "arraycopy", "(", "presentationArgs", ",", "0", ",", "newArgs", ",", "appArgs", ".", "length", ",", "presentationArgs", ".", "length", ")", ";", "args", ".", "put", "(", "IApplicationContext", ".", "APPLICATION_ARGS", ",", "newArgs", ")", ";", "instance", "=", "this", ";", "Runtime", ".", "getRuntime", "(", ")", ".", "addShutdownHook", "(", "new", "Thread", "(", ")", "{", "public", "void", "run", "(", ")", "{", "try", "{", "EclimApplication", ".", "shutdown", "(", ")", ";", "}", "catch", "(", "Exception", "ex", ")", "{", "logger", ".", "error", "(", "\"\"", ",", "ex", ")", ";", "}", "}", "}", ")", ";", "return", "super", ".", "start", "(", "context", ")", ";", "}", "public", "static", "boolean", "isEnabled", "(", ")", "{", "return", "instance", "!=", "null", ";", "}", "public", "synchronized", "static", "void", "shutdown", "(", ")", "throws", "Exception", "{", "if", "(", "instance", "!=", "null", "&&", "!", "stopping", ")", "{", "stopping", "=", "true", ";", "EclimDaemon", ".", "getInstance", "(", ")", ".", "stop", "(", ")", ";", "final", "IWorkbench", "workbench", "=", "PlatformUI", ".", "getWorkbench", "(", ")", ";", "workbench", ".", "getDisplay", "(", ")", ".", "syncExec", "(", "new", "Runnable", "(", ")", "{", "public", "void", "run", "(", ")", "{", "workbench", ".", "getActiveWorkbenchWindow", "(", ")", ".", "close", "(", ")", ";", "}", "}", ")", ";", "}", "}", "}", "</s>" ]
1,448
[ "<s>", "package", "org", ".", "eclim", ".", "eclipse", ";", "import", "java", ".", "io", ".", "PrintWriter", ";", "import", "java", ".", "io", ".", "StringWriter", ";", "import", "java", ".", "net", ".", "URL", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "FileLocator", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "Plugin", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "internal", ".", "adaptor", ".", "EclipseAdaptorMsg", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "internal", ".", "adaptor", ".", "MessageHelper", ";", "import", "org", ".", "eclipse", ".", "osgi", ".", "service", ".", "resolver", ".", "BundleDescription", ";", "import", "org", ".", "eclipse", ".", "osgi", ".", "service", ".", "resolver", ".", "PlatformAdmin", ";", "import", "org", ".", "eclipse", ".", "osgi", ".", "service", ".", "resolver", ".", "ResolverError", ";", "import", "org", ".", "eclipse", ".", "osgi", ".", "service", ".", "resolver", ".", "State", ";", "import", "org", ".", "eclipse", ".", "osgi", ".", "service", ".", "resolver", ".", "VersionConstraint", ";", "import", "org", ".", "eclipse", ".", "osgi", ".", "util", ".", "NLS", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Display", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Shell", ";", "import", "org", ".", "osgi", ".", "framework", ".", "BundleContext", ";", "import", "org", ".", "osgi", ".", "framework", ".", "ServiceReference", ";", "public", "class", "EclimPlugin", "extends", "Plugin", "{", "private", "static", "EclimPlugin", "plugin", ";", "private", "static", "final", "String", "FILE_PREFIX", "=", "\"file:\"", ";", "private", "static", "final", "String", "PLUGIN_XML", "=", "\"plugin.xml\"", ";", "public", "EclimPlugin", "(", ")", "{", "plugin", "=", "this", ";", "}", "public", "void", "start", "(", "BundleContext", "context", ")", "throws", "Exception", "{", "super", ".", "start", "(", "context", ")", ";", "URL", "url", "=", "FileLocator", ".", "toFileURL", "(", "getBundle", "(", ")", ".", "getResource", "(", "PLUGIN_XML", ")", ")", ";", "String", "home", "=", "url", ".", "toString", "(", ")", ";", "home", "=", "home", ".", "substring", "(", "FILE_PREFIX", ".", "length", "(", ")", ",", "home", ".", "length", "(", ")", "-", "PLUGIN_XML", ".", "length", "(", ")", ")", ";", "home", "=", "home", ".", "replaceFirst", "(", "\"\"", ",", "\"$1\"", ")", ";", "System", ".", "setProperty", "(", "\"eclim.home\"", ",", "home", ")", ";", "}", "public", "void", "stop", "(", "BundleContext", "context", ")", "throws", "Exception", "{", "super", ".", "stop", "(", "context", ")", ";", "plugin", "=", "null", ";", "}", "public", "static", "EclimPlugin", "getDefault", "(", ")", "{", "return", "plugin", ";", "}", "public", "static", "Shell", "getShell", "(", ")", "{", "Display", "display", "=", "Display", ".", "getDefault", "(", ")", ";", "Shell", "shell", "=", "display", ".", "getActiveShell", "(", ")", ";", "if", "(", "shell", "!=", "null", ")", "{", "return", "shell", ";", "}", "Shell", "[", "]", "shells", "=", "display", ".", "getShells", "(", ")", ";", "if", "(", "shells", ".", "length", ">", "0", ")", "{", "return", "shells", "[", "0", "]", ";", "}", "return", "null", ";", "}", "@", "SuppressWarnings", "(", "{", "\"unchecked\"", ",", "\"rawtypes\"", "}", ")", "public", "String", "diagnose", "(", "String", "bundleName", ")", "{", "StringWriter", "out", "=", "new", "StringWriter", "(", ")", ";", "PrintWriter", "writer", "=", "new", "PrintWriter", "(", "out", ")", ";", "BundleContext", "context", "=", "getDefault", "(", ")", ".", "getBundle", "(", ")", ".", "getBundleContext", "(", ")", ";", "ServiceReference", "platformAdminRef", "=", "context", ".", "getServiceReference", "(", "PlatformAdmin", ".", "class", ".", "getName", "(", ")", ")", ";", "PlatformAdmin", "platformAdmin", "=", "(", "PlatformAdmin", ")", "context", ".", "getService", "(", "platformAdminRef", ")", ";", "State", "state", "=", "platformAdmin", ".", "getState", "(", "false", ")", ";", "BundleDescription", "bundle", "=", "null", ";", "BundleDescription", "[", "]", "allBundles", "=", "state", ".", "getBundles", "(", "bundleName", ")", ";", "if", "(", "allBundles", ".", "length", "==", "0", ")", "{", "writer", ".", "println", "(", "NLS", ".", "bind", "(", "EclipseAdaptorMsg", ".", "ECLIPSE_CONSOLE_CANNOT_FIND_BUNDLE_ERROR", ",", "bundleName", ")", ")", ";", "}", "else", "{", "bundle", "=", "allBundles", "[", "0", "]", ";", "VersionConstraint", "[", "]", "unsatisfied", "=", "platformAdmin", ".", "getStateHelper", "(", ")", ".", "getUnsatisfiedConstraints", "(", "bundle", ")", ";", "ResolverError", "[", "]", "resolverErrors", "=", "platformAdmin", ".", "getState", "(", "false", ")", ".", "getResolverErrors", "(", "bundle", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "resolverErrors", ".", "length", ";", "i", "++", ")", "{", "if", "(", "(", "resolverErrors", "[", "i", "]", ".", "getType", "(", ")", "&", "(", "ResolverError", ".", "MISSING_FRAGMENT_HOST", "|", "ResolverError", ".", "MISSING_GENERIC_CAPABILITY", "|", "ResolverError", ".", "MISSING_IMPORT_PACKAGE", "|", "ResolverError", ".", "MISSING_REQUIRE_BUNDLE", ")", ")", "!=", "0", ")", "{", "continue", ";", "}", "writer", ".", "print", "(", "\"", "\"", ")", ";", "writer", ".", "println", "(", "resolverErrors", "[", "i", "]", ".", "toString", "(", ")", ")", ";", "}", "if", "(", "unsatisfied", ".", "length", "==", "0", "&&", "resolverErrors", ".", "length", "==", "0", ")", "{", "writer", ".", "print", "(", "\"", "\"", ")", ";", "writer", ".", "println", "(", "EclipseAdaptorMsg", ".", "ECLIPSE_CONSOLE_NO_CONSTRAINTS", ")", ";", "}", "if", "(", "unsatisfied", ".", "length", ">", "0", ")", "{", "writer", ".", "print", "(", "\"", "\"", ")", ";", "writer", ".", "println", "(", "EclipseAdaptorMsg", ".", "ECLIPSE_CONSOLE_DIRECT_CONSTRAINTS", ")", ";", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "unsatisfied", ".", "length", ";", "i", "++", ")", "{", "writer", ".", "print", "(", "\"", "\"", ")", ";", "writer", ".", "println", "(", "MessageHelper", ".", "getResolutionFailureMessage", "(", "unsatisfied", "[", "i", "]", ")", ")", ";", "}", "VersionConstraint", "[", "]", "unsatisfiedLeaves", "=", "platformAdmin", ".", "getStateHelper", "(", ")", ".", "getUnsatisfiedLeaves", "(", "new", "BundleDescription", "[", "]", "{", "bundle", "}", ")", ";", "boolean", "foundLeaf", "=", "false", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "unsatisfiedLeaves", ".", "length", ";", "i", "++", ")", "{", "if", "(", "unsatisfiedLeaves", "[", "i", "]", ".", "getBundle", "(", ")", "==", "bundle", ")", "{", "continue", ";", "}", "if", "(", "!", "foundLeaf", ")", "{", "foundLeaf", "=", "true", ";", "writer", ".", "print", "(", "\"", "\"", ")", ";", "writer", ".", "println", "(", "EclipseAdaptorMsg", ".", "ECLIPSE_CONSOLE_LEAF_CONSTRAINTS", ")", ";", "}", "writer", ".", "print", "(", "\"", "\"", ")", ";", "writer", ".", "println", "(", "unsatisfiedLeaves", "[", "i", "]", ".", "getBundle", "(", ")", ".", "getLocation", "(", ")", "+", "\"", "[\"", "+", "unsatisfiedLeaves", "[", "i", "]", ".", "getBundle", "(", ")", ".", "getBundleId", "(", ")", "+", "\"]\"", ")", ";", "writer", ".", "print", "(", "\"", "\"", ")", ";", "writer", ".", "println", "(", "MessageHelper", ".", "getResolutionFailureMessage", "(", "unsatisfiedLeaves", "[", "i", "]", ")", ")", ";", "}", "}", "return", "out", ".", "toString", "(", ")", ";", "}", "}", "</s>" ]
1,449
[ "<s>", "package", "org", ".", "eclim", ".", "eclipse", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "io", ".", "FileFilter", ";", "import", "java", ".", "io", ".", "FileInputStream", ";", "import", "java", ".", "io", ".", "FileOutputStream", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "net", ".", "BindException", ";", "import", "java", ".", "net", ".", "InetAddress", ";", "import", "java", ".", "net", ".", "URL", ";", "import", "java", ".", "net", ".", "URLClassLoader", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "eclim", ".", "Services", ";", "import", "org", ".", "eclim", ".", "command", ".", "ReloadCommand", ";", "import", "org", ".", "eclim", ".", "logging", ".", "Logger", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "PluginResources", ";", "import", "org", ".", "eclim", ".", "util", ".", "IOUtils", ";", "import", "org", ".", "eclim", ".", "util", ".", "file", ".", "FileUtils", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "ResourcesPlugin", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "Platform", ";", "import", "org", ".", "osgi", ".", "framework", ".", "Bundle", ";", "import", "org", ".", "osgi", ".", "framework", ".", "FrameworkEvent", ";", "import", "org", ".", "osgi", ".", "framework", ".", "FrameworkListener", ";", "import", "com", ".", "martiansoftware", ".", "nailgun", ".", "NGServer", ";", "public", "class", "EclimDaemon", "implements", "FrameworkListener", "{", "private", "static", "final", "Logger", "logger", "=", "Logger", ".", "getLogger", "(", "EclimDaemon", ".", "class", ")", ";", "private", "static", "String", "CORE", "=", "\"\"", ";", "private", "static", "EclimDaemon", "instance", "=", "new", "EclimDaemon", "(", ")", ";", "private", "boolean", "started", ";", "private", "boolean", "starting", ";", "private", "boolean", "stopping", ";", "private", "NGServer", "server", ";", "private", "EclimDaemon", "(", ")", "{", "}", "public", "static", "EclimDaemon", "getInstance", "(", ")", "{", "return", "instance", ";", "}", "public", "void", "start", "(", ")", "{", "if", "(", "started", "||", "starting", ")", "{", "return", ";", "}", "String", "workspace", "=", "ResourcesPlugin", ".", "getWorkspace", "(", ")", ".", "getRoot", "(", ")", ".", "getRawLocation", "(", ")", ".", "toOSString", "(", ")", ".", "replace", "(", "'\\\\'", ",", "'/'", ")", ";", "logger", ".", "info", "(", "\"Workspace:", "\"", "+", "workspace", ")", ";", "starting", "=", "true", ";", "logger", ".", "info", "(", "\"\"", ")", ";", "final", "String", "host", "=", "Services", ".", "getPluginResources", "(", "\"org.eclim\"", ")", ".", "getProperty", "(", "\"\"", ")", ";", "final", "String", "portString", "=", "Services", ".", "getPluginResources", "(", "\"org.eclim\"", ")", ".", "getProperty", "(", "\"\"", ")", ";", "try", "{", "final", "int", "port", "=", "Integer", ".", "parseInt", "(", "portString", ")", ";", "registerInstance", "(", "workspace", ",", "port", ")", ";", "InetAddress", "address", "=", "InetAddress", ".", "getByName", "(", "host", ")", ";", "server", "=", "new", "NGServer", "(", "address", ",", "port", ",", "getExtensionClassLoader", "(", ")", ")", ";", "server", ".", "setCaptureSystemStreams", "(", "false", ")", ";", "logger", ".", "info", "(", "\"\"", ")", ";", "PluginResources", "defaultResources", "=", "Services", ".", "getPluginResources", "(", "\"org.eclim\"", ")", ";", "defaultResources", ".", "registerCommand", "(", "ReloadCommand", ".", "class", ")", ";", "logger", ".", "info", "(", "\"\"", ")", ";", "Bundle", "bundle", "=", "Platform", ".", "getBundle", "(", "CORE", ")", ";", "if", "(", "bundle", "==", "null", ")", "{", "String", "diagnosis", "=", "EclimPlugin", ".", "getDefault", "(", ")", ".", "diagnose", "(", "CORE", ")", ";", "logger", ".", "error", "(", "Services", ".", "getMessage", "(", "\"\"", ",", "CORE", ",", "diagnosis", ")", ")", ";", "return", ";", "}", "bundle", ".", "start", "(", "Bundle", ".", "START_TRANSIENT", ")", ";", "bundle", ".", "getBundleContext", "(", ")", ".", "addFrameworkListener", "(", "this", ")", ";", "synchronized", "(", "this", ")", "{", "wait", "(", "10000", ")", ";", "}", "starting", "=", "false", ";", "started", "=", "true", ";", "logger", ".", "info", "(", "\"\"", ",", "host", ",", "port", ")", ";", "server", ".", "run", "(", ")", ";", "}", "catch", "(", "NumberFormatException", "nfe", ")", "{", "logger", ".", "error", "(", "\"\"", ",", "new", "RuntimeException", "(", "\"\"", "+", "portString", "+", "\"'\"", ")", ")", ";", "}", "catch", "(", "BindException", "be", ")", "{", "logger", ".", "error", "(", "\"\"", ",", "host", ",", "portString", ",", "be", ")", ";", "}", "catch", "(", "Throwable", "t", ")", "{", "logger", ".", "error", "(", "\"\"", ",", "t", ")", ";", "}", "finally", "{", "starting", "=", "false", ";", "started", "=", "false", ";", "}", "}", "public", "void", "stop", "(", ")", "throws", "Exception", "{", "if", "(", "started", "&&", "!", "stopping", ")", "{", "try", "{", "stopping", "=", "true", ";", "logger", ".", "info", "(", "\"\"", ")", ";", "if", "(", "server", "!=", "null", "&&", "server", ".", "isRunning", "(", ")", ")", "{", "server", ".", "shutdown", "(", "false", ")", ";", "}", "unregisterInstance", "(", ")", ";", "logger", ".", "info", "(", "\"\"", "+", "CORE", ")", ";", "Bundle", "bundle", "=", "Platform", ".", "getBundle", "(", "CORE", ")", ";", "if", "(", "bundle", "!=", "null", ")", "{", "try", "{", "bundle", ".", "stop", "(", ")", ";", "}", "catch", "(", "IllegalStateException", "ise", ")", "{", "}", "}", "logger", ".", "info", "(", "\"\"", ")", ";", "}", "finally", "{", "stopping", "=", "false", ";", "}", "}", "}", "private", "void", "registerInstance", "(", "String", "workspace", ",", "int", "port", ")", "throws", "Exception", "{", "File", "instances", "=", "new", "File", "(", "FileUtils", ".", "concat", "(", "System", ".", "getProperty", "(", "\"user.home\"", ")", ",", "\"\"", ")", ")", ";", "FileOutputStream", "out", "=", "null", ";", "try", "{", "List", "<", "String", ">", "entries", "=", "readInstances", "(", ")", ";", "if", "(", "entries", "!=", "null", ")", "{", "String", "instance", "=", "workspace", "+", "':'", "+", "port", ";", "if", "(", "!", "entries", ".", "contains", "(", "instance", ")", ")", "{", "entries", ".", "add", "(", "0", ",", "instance", ")", ";", "out", "=", "new", "FileOutputStream", "(", "instances", ")", ";", "IOUtils", ".", "writeLines", "(", "entries", ",", "out", ")", ";", "}", "}", "}", "catch", "(", "IOException", "ioe", ")", "{", "logger", ".", "error", "(", "\"\"", "+", "ioe", ".", "getMessage", "(", ")", "+", "\"n\"", "+", "instances", ")", ";", "}", "finally", "{", "IOUtils", ".", "closeQuietly", "(", "out", ")", ";", "}", "}", "private", "void", "unregisterInstance", "(", ")", "throws", "Exception", "{", "File", "instances", "=", "new", "File", "(", "FileUtils", ".", "concat", "(", "System", ".", "getProperty", "(", "\"user.home\"", ")", ",", "\"\"", ")", ")", ";", "FileOutputStream", "out", "=", "null", ";", "try", "{", "List", "<", "String", ">", "entries", "=", "readInstances", "(", ")", ";", "if", "(", "entries", "==", "null", ")", "{", "return", ";", "}", "String", "workspace", "=", "ResourcesPlugin", ".", "getWorkspace", "(", ")", ".", "getRoot", "(", ")", ".", "getRawLocation", "(", ")", ".", "toOSString", "(", ")", ".", "replace", "(", "'\\\\'", ",", "'/'", ")", ";", "String", "port", "=", "Services", ".", "getPluginResources", "(", "\"org.eclim\"", ")", ".", "getProperty", "(", "\"\"", ")", ";", "String", "instance", "=", "workspace", "+", "':'", "+", "port", ";", "entries", ".", "remove", "(", "instance", ")", ";", "if", "(", "entries", ".", "size", "(", ")", "==", "0", ")", "{", "if", "(", "!", "instances", ".", "delete", "(", ")", ")", "{", "logger", ".", "error", "(", "\"\"", "+", "instances", ")", ";", "}", "}", "else", "{", "out", "=", "new", "FileOutputStream", "(", "instances", ")", ";", "IOUtils", ".", "writeLines", "(", "entries", ",", "out", ")", ";", "}", "}", "catch", "(", "IOException", "ioe", ")", "{", "logger", ".", "error", "(", "\"\"", "+", "ioe", ".", "getMessage", "(", ")", "+", "\"n\"", "+", "instances", ")", ";", "return", ";", "}", "finally", "{", "IOUtils", ".", "closeQuietly", "(", "out", ")", ";", "}", "}", "private", "List", "<", "String", ">", "readInstances", "(", ")", "throws", "Exception", "{", "File", "doteclim", "=", "new", "File", "(", "FileUtils", ".", "concat", "(", "System", ".", "getProperty", "(", "\"user.home\"", ")", ",", "\".eclim\"", ")", ")", ";", "if", "(", "!", "doteclim", ".", "exists", "(", ")", ")", "{", "if", "(", "!", "doteclim", ".", "mkdirs", "(", ")", ")", "{", "logger", ".", "error", "(", "\"\"", "+", "doteclim", ")", ";", "return", "null", ";", "}", "}", "File", "instances", "=", "new", "File", "(", "FileUtils", ".", "concat", "(", "doteclim", ".", "getAbsolutePath", "(", ")", ",", "\"\"", ")", ")", ";", "if", "(", "!", "instances", ".", "exists", "(", ")", ")", "{", "try", "{", "instances", ".", "createNewFile", "(", ")", ";", "}", "catch", "(", "IOException", "ioe", ")", "{", "logger", ".", "error", "(", "\"\"", "+", "ioe", ".", "getMessage", "(", ")", "+", "\"n\"", "+", "instances", ")", ";", "return", "null", ";", "}", "}", "FileInputStream", "in", "=", "null", ";", "try", "{", "in", "=", "new", "FileInputStream", "(", "instances", ")", ";", "List", "<", "String", ">", "entries", "=", "IOUtils", ".", "readLines", "(", "in", ")", ";", "return", "entries", ";", "}", "finally", "{", "IOUtils", ".", "closeQuietly", "(", "in", ")", ";", "}", "}", "private", "ClassLoader", "getExtensionClassLoader", "(", ")", "throws", "Exception", "{", "File", "extdir", "=", "new", "File", "(", "FileUtils", ".", "concat", "(", "Services", ".", "DOT_ECLIM", ",", "\"\"", ")", ")", ";", "if", "(", "extdir", ".", "exists", "(", ")", ")", "{", "FileFilter", "filter", "=", "new", "FileFilter", "(", ")", "{", "public", "boolean", "accept", "(", "File", "file", ")", "{", "return", "file", ".", "isDirectory", "(", ")", "||", "file", ".", "getName", "(", ")", ".", "endsWith", "(", "\".jar\"", ")", ";", "}", "}", ";", "ArrayList", "<", "URL", ">", "urls", "=", "new", "ArrayList", "<", "URL", ">", "(", ")", ";", "listFileUrls", "(", "extdir", ",", "filter", ",", "urls", ")", ";", "return", "new", "URLClassLoader", "(", "urls", ".", "toArray", "(", "new", "URL", "[", "urls", ".", "size", "(", ")", "]", ")", ",", "this", ".", "getClass", "(", ")", ".", "getClassLoader", "(", ")", ")", ";", "}", "return", "null", ";", "}", "private", "void", "listFileUrls", "(", "File", "dir", ",", "FileFilter", "filter", ",", "ArrayList", "<", "URL", ">", "results", ")", "throws", "Exception", "{", "File", "[", "]", "files", "=", "dir", ".", "listFiles", "(", "filter", ")", ";", "for", "(", "File", "file", ":", "files", ")", "{", "if", "(", "file", ".", "isFile", "(", ")", ")", "{", "results", ".", "add", "(", "file", ".", "toURI", "(", ")", ".", "toURL", "(", ")", ")", ";", "}", "else", "{", "listFileUrls", "(", "file", ",", "filter", ",", "results", ")", ";", "}", "}", "}", "@", "Override", "public", "synchronized", "void", "frameworkEvent", "(", "FrameworkEvent", "event", ")", "{", "Bundle", "bundle", "=", "event", ".", "getBundle", "(", ")", ";", "if", "(", "event", ".", "getType", "(", ")", "==", "FrameworkEvent", ".", "INFO", "&&", "CORE", ".", "equals", "(", "bundle", ".", "getSymbolicName", "(", ")", ")", ")", "{", "logger", ".", "info", "(", "\"\"", ")", ";", "notify", "(", ")", ";", "}", "}", "}", "</s>" ]
1,450
[ "<s>", "package", "org", ".", "eclim", ".", "eclipse", ".", "jface", ".", "text", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "ISelection", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "ISelectionChangedListener", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "ISelectionProvider", ";", "public", "class", "DummySelectionProvider", "implements", "ISelectionProvider", "{", "private", "ISelection", "selection", ";", "public", "DummySelectionProvider", "(", "ISelection", "selection", ")", "{", "this", ".", "selection", "=", "selection", ";", "}", "public", "void", "addSelectionChangedListener", "(", "ISelectionChangedListener", "listener", ")", "{", "}", "public", "ISelection", "getSelection", "(", ")", "{", "return", "selection", ";", "}", "public", "void", "removeSelectionChangedListener", "(", "ISelectionChangedListener", "listener", ")", "{", "}", "public", "void", "setSelection", "(", "ISelection", "selection", ")", "{", "this", ".", "selection", "=", "selection", ";", "}", "}", "</s>" ]
1,451
[ "<s>", "package", "org", ".", "eclim", ".", "eclipse", ".", "jface", ".", "text", ".", "contentassist", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "text", ".", "ITextViewer", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "text", ".", "contentassist", ".", "ICompletionListener", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "text", ".", "contentassist", ".", "IContentAssistProcessor", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "text", ".", "contentassist", ".", "IContentAssistant", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "text", ".", "contentassist", ".", "IContentAssistantExtension2", ";", "public", "class", "DummyContentAssistantExtension2", "implements", "IContentAssistant", ",", "IContentAssistantExtension2", "{", "public", "void", "install", "(", "ITextViewer", "textViewer", ")", "{", "}", "public", "void", "uninstall", "(", ")", "{", "}", "public", "String", "showPossibleCompletions", "(", ")", "{", "return", "null", ";", "}", "public", "String", "showContextInformation", "(", ")", "{", "return", "null", ";", "}", "public", "IContentAssistProcessor", "getContentAssistProcessor", "(", "String", "contentType", ")", "{", "return", "null", ";", "}", "public", "void", "addCompletionListener", "(", "ICompletionListener", "listener", ")", "{", "}", "public", "void", "removeCompletionListener", "(", "ICompletionListener", "listener", ")", "{", "}", "public", "void", "setRepeatedInvocationMode", "(", "boolean", "cycling", ")", "{", "}", "public", "void", "setShowEmptyList", "(", "boolean", "showEmpty", ")", "{", "}", "public", "void", "setStatusLineVisible", "(", "boolean", "show", ")", "{", "}", "public", "void", "setStatusMessage", "(", "String", "message", ")", "{", "}", "public", "void", "setEmptyMessage", "(", "String", "message", ")", "{", "}", "}", "</s>" ]
1,452
[ "<s>", "package", "org", ".", "eclim", ".", "eclipse", ".", "jface", ".", "text", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "text", ".", "IDocument", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "text", ".", "IEventConsumer", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "text", ".", "IFindReplaceTarget", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "text", ".", "IRegion", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "text", ".", "ITextDoubleClickStrategy", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "text", ".", "ITextHover", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "text", ".", "ITextInputListener", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "text", ".", "ITextListener", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "text", ".", "ITextOperationTarget", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "text", ".", "ITextViewer", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "text", ".", "IUndoManager", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "text", ".", "IViewportListener", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "text", ".", "TextPresentation", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "text", ".", "TextSelection", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "ISelectionProvider", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "custom", ".", "StyledText", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Color", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Point", ";", "public", "class", "DummyTextViewer", "implements", "ITextViewer", "{", "public", "IDocument", "document", ";", "public", "ISelectionProvider", "selectionProvider", ";", "public", "DummyTextViewer", "(", "IDocument", "document", ",", "int", "offset", ",", "int", "length", ")", "{", "this", ".", "document", "=", "document", ";", "selectionProvider", "=", "new", "DummySelectionProvider", "(", "new", "TextSelection", "(", "document", ",", "offset", ",", "length", ")", ")", ";", "}", "public", "StyledText", "getTextWidget", "(", ")", "{", "return", "null", ";", "}", "public", "void", "setUndoManager", "(", "IUndoManager", "undoManager", ")", "{", "}", "public", "void", "setTextDoubleClickStrategy", "(", "ITextDoubleClickStrategy", "strategy", ",", "String", "contentType", ")", "{", "}", "@", "SuppressWarnings", "(", "\"deprecation\"", ")", "public", "void", "setAutoIndentStrategy", "(", "org", ".", "eclipse", ".", "jface", ".", "text", ".", "IAutoIndentStrategy", "strategy", ",", "String", "contentType", ")", "{", "}", "public", "void", "setTextHover", "(", "ITextHover", "textViewerHover", ",", "String", "contentType", ")", "{", "}", "public", "void", "activatePlugins", "(", ")", "{", "}", "public", "void", "resetPlugins", "(", ")", "{", "}", "public", "void", "addViewportListener", "(", "IViewportListener", "listener", ")", "{", "}", "public", "void", "removeViewportListener", "(", "IViewportListener", "listener", ")", "{", "}", "public", "void", "addTextListener", "(", "ITextListener", "listener", ")", "{", "}", "public", "void", "removeTextListener", "(", "ITextListener", "listener", ")", "{", "}", "public", "void", "addTextInputListener", "(", "ITextInputListener", "listener", ")", "{", "}", "public", "void", "removeTextInputListener", "(", "ITextInputListener", "listener", ")", "{", "}", "public", "void", "setDocument", "(", "IDocument", "document", ")", "{", "}", "public", "IDocument", "getDocument", "(", ")", "{", "return", "document", ";", "}", "public", "void", "setEventConsumer", "(", "IEventConsumer", "consumer", ")", "{", "}", "public", "void", "setEditable", "(", "boolean", "editable", ")", "{", "}", "public", "boolean", "isEditable", "(", ")", "{", "return", "true", ";", "}", "public", "void", "setDocument", "(", "IDocument", "document", ",", "int", "modelRangeOffset", ",", "int", "modelRangeLength", ")", "{", "}", "public", "void", "setVisibleRegion", "(", "int", "offset", ",", "int", "length", ")", "{", "}", "public", "void", "resetVisibleRegion", "(", ")", "{", "}", "public", "IRegion", "getVisibleRegion", "(", ")", "{", "return", "null", ";", "}", "public", "boolean", "overlapsWithVisibleRegion", "(", "int", "offset", ",", "int", "length", ")", "{", "return", "false", ";", "}", "public", "void", "changeTextPresentation", "(", "TextPresentation", "presentation", ",", "boolean", "controlRedraw", ")", "{", "}", "public", "void", "invalidateTextPresentation", "(", ")", "{", "}", "public", "void", "setTextColor", "(", "Color", "color", ")", "{", "}", "public", "void", "setTextColor", "(", "Color", "color", ",", "int", "offset", ",", "int", "length", ",", "boolean", "controlRedraw", ")", "{", "}", "public", "ITextOperationTarget", "getTextOperationTarget", "(", ")", "{", "return", "null", ";", "}", "public", "IFindReplaceTarget", "getFindReplaceTarget", "(", ")", "{", "return", "null", ";", "}", "public", "void", "setDefaultPrefixes", "(", "String", "[", "]", "defaultPrefixes", ",", "String", "contentType", ")", "{", "}", "public", "void", "setIndentPrefixes", "(", "String", "[", "]", "indentPrefixes", ",", "String", "contentType", ")", "{", "}", "public", "void", "setSelectedRange", "(", "int", "offset", ",", "int", "length", ")", "{", "}", "public", "Point", "getSelectedRange", "(", ")", "{", "return", "new", "Point", "(", "-", "1", ",", "-", "1", ")", ";", "}", "public", "ISelectionProvider", "getSelectionProvider", "(", ")", "{", "return", "selectionProvider", ";", "}", "public", "void", "revealRange", "(", "int", "offset", ",", "int", "length", ")", "{", "}", "public", "void", "setTopIndex", "(", "int", "index", ")", "{", "}", "public", "int", "getTopIndex", "(", ")", "{", "return", "-", "1", ";", "}", "public", "int", "getTopIndexStartOffset", "(", ")", "{", "return", "-", "1", ";", "}", "public", "int", "getBottomIndex", "(", ")", "{", "return", "-", "1", ";", "}", "public", "int", "getBottomIndexEndOffset", "(", ")", "{", "return", "-", "1", ";", "}", "public", "int", "getTopInset", "(", ")", "{", "return", "-", "1", ";", "}", "}", "</s>" ]
1,453
[ "<s>", "package", "org", ".", "eclim", ".", "eclipse", ";", "import", "org", ".", "eclim", ".", "logging", ".", "Logger", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "IStartup", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "IWorkbench", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "PlatformUI", ";", "public", "class", "EclimStartup", "implements", "IStartup", "{", "private", "static", "final", "Logger", "logger", "=", "Logger", ".", "getLogger", "(", "EclimStartup", ".", "class", ")", ";", "@", "Override", "public", "void", "earlyStartup", "(", ")", "{", "if", "(", "EclimApplication", ".", "isEnabled", "(", ")", ")", "{", "final", "IWorkbench", "workbench", "=", "PlatformUI", ".", "getWorkbench", "(", ")", ";", "workbench", ".", "getDisplay", "(", ")", ".", "asyncExec", "(", "new", "Runnable", "(", ")", "{", "public", "void", "run", "(", ")", "{", "try", "{", "new", "Thread", "(", ")", "{", "public", "void", "run", "(", ")", "{", "EclimDaemon", ".", "getInstance", "(", ")", ".", "start", "(", ")", ";", "}", "}", ".", "start", "(", ")", ";", "}", "catch", "(", "Exception", "ex", ")", "{", "logger", ".", "error", "(", "\"\"", ",", "ex", ")", ";", "}", "}", "}", ")", ";", "}", "}", "}", "</s>" ]
1,454
[ "<s>", "package", "org", ".", "eclim", ".", "eclipse", ".", "ui", ";", "import", "org", ".", "eclim", ".", "eclipse", ".", "EclimDaemon", ";", "import", "org", ".", "eclim", ".", "logging", ".", "Logger", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "SWT", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Composite", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Text", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "part", ".", "ViewPart", ";", "public", "class", "EclimdView", "extends", "ViewPart", "{", "private", "static", "final", "Logger", "logger", "=", "Logger", ".", "getLogger", "(", "EclimdView", ".", "class", ")", ";", "private", "static", "Text", "log", ";", "@", "Override", "public", "void", "createPartControl", "(", "Composite", "parent", ")", "{", "log", "=", "new", "Text", "(", "parent", ",", "SWT", ".", "LEFT", "|", "SWT", ".", "MULTI", "|", "SWT", ".", "READ_ONLY", "|", "SWT", ".", "H_SCROLL", "|", "SWT", ".", "V_SCROLL", ")", ";", "try", "{", "new", "Thread", "(", ")", "{", "public", "void", "run", "(", ")", "{", "EclimDaemon", ".", "getInstance", "(", ")", ".", "start", "(", ")", ";", "}", "}", ".", "start", "(", ")", ";", "}", "catch", "(", "Exception", "ex", ")", "{", "logger", ".", "error", "(", "\"\"", ",", "ex", ")", ";", "}", "}", "@", "Override", "public", "void", "dispose", "(", ")", "{", "try", "{", "EclimDaemon", ".", "getInstance", "(", ")", ".", "stop", "(", ")", ";", "}", "catch", "(", "Exception", "ex", ")", "{", "logger", ".", "error", "(", "\"\"", ",", "ex", ")", ";", "}", "}", "@", "Override", "public", "void", "setFocus", "(", ")", "{", "log", ".", "setFocus", "(", ")", ";", "}", "public", "static", "Text", "getLog", "(", ")", "{", "return", "log", ";", "}", "}", "</s>" ]
1,455
[ "<s>", "package", "org", ".", "eclim", ".", "eclipse", ".", "ui", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "SWT", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Composite", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Text", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "part", ".", "ViewPart", ";", "public", "class", "VimpluginDebugView", "extends", "ViewPart", "{", "private", "static", "Text", "log", ";", "@", "Override", "public", "void", "createPartControl", "(", "Composite", "parent", ")", "{", "log", "=", "new", "Text", "(", "parent", ",", "SWT", ".", "LEFT", "|", "SWT", ".", "MULTI", "|", "SWT", ".", "READ_ONLY", "|", "SWT", ".", "H_SCROLL", "|", "SWT", ".", "V_SCROLL", ")", ";", "}", "@", "Override", "public", "void", "dispose", "(", ")", "{", "log", ".", "dispose", "(", ")", ";", "log", "=", "null", ";", "}", "@", "Override", "public", "void", "setFocus", "(", ")", "{", "log", ".", "setFocus", "(", ")", ";", "}", "public", "static", "Text", "getLog", "(", ")", "{", "return", "log", ";", "}", "}", "</s>" ]
1,456
[ "<s>", "package", "org", ".", "eclim", ".", "eclipse", ".", "ui", ".", "internal", ";", "import", "java", ".", "lang", ".", "reflect", ".", "InvocationTargetException", ";", "import", "org", ".", "eclim", ".", "eclipse", ".", "EclimPlugin", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "ResourcesPlugin", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "operation", ".", "IRunnableWithProgress", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Shell", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "IWorkbenchPage", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "internal", ".", "WorkbenchWindow", ";", "public", "class", "EclimWorkbenchWindow", "extends", "WorkbenchWindow", "{", "private", "IWorkbenchPage", "page", ";", "public", "EclimWorkbenchWindow", "(", ")", "{", "super", "(", "null", ",", "null", ")", ";", "}", "public", "IWorkbenchPage", "getActivePage", "(", ")", "{", "try", "{", "if", "(", "page", "==", "null", ")", "{", "page", "=", "new", "EclimWorkbenchPage", "(", "this", ",", "ResourcesPlugin", ".", "getWorkspace", "(", ")", ".", "getRoot", "(", ")", ")", ";", "}", "return", "page", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "}", "public", "Shell", "getShell", "(", ")", "{", "return", "EclimPlugin", ".", "getShell", "(", ")", ";", "}", "public", "void", "run", "(", "boolean", "fork", ",", "boolean", "cancelable", ",", "IRunnableWithProgress", "runnable", ")", "throws", "InvocationTargetException", ",", "InterruptedException", "{", "}", "@", "Override", "public", "void", "fillActionBars", "(", "int", "flags", ")", "{", "}", "}", "</s>" ]
1,457
[ "<s>", "package", "org", ".", "eclim", ".", "eclipse", ".", "ui", ".", "internal", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "IAdaptable", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "IEditorPart", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "WorkbenchException", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "internal", ".", "WorkbenchPage", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "internal", ".", "WorkbenchWindow", ";", "public", "class", "EclimWorkbenchPage", "extends", "WorkbenchPage", "{", "private", "IEditorPart", "editor", ";", "public", "EclimWorkbenchPage", "(", "WorkbenchWindow", "window", ",", "IAdaptable", "input", ")", "throws", "WorkbenchException", "{", "super", "(", "window", ",", "input", ")", ";", "}", "public", "IEditorPart", "getActiveEditor", "(", ")", "{", "return", "editor", ";", "}", "public", "void", "setActiveEditor", "(", "IEditorPart", "editor", ")", "{", "this", ".", "editor", "=", "editor", ";", "}", "}", "</s>" ]
1,458
[ "<s>", "package", "org", ".", "eclim", ".", "eclipse", ".", "ui", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang", ".", "StringUtils", ";", "import", "org", ".", "eclim", ".", "eclipse", ".", "EclimPlugin", ";", "import", "org", ".", "eclim", ".", "eclipse", ".", "ui", ".", "internal", ".", "EclimWorkbenchWindow", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "action", ".", "MenuManager", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "ISelectionProvider", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Shell", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "IActionBars", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "IEditorActionBarContributor", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "IEditorSite", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "IWorkbenchPage", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "IWorkbenchPart", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "IWorkbenchWindow", ";", "@", "SuppressWarnings", "(", "\"rawtypes\"", ")", "public", "class", "EclimEditorSite", "implements", "IEditorSite", "{", "private", "IWorkbenchWindow", "window", ";", "private", "ISelectionProvider", "selectionProvider", ";", "public", "EclimEditorSite", "(", ")", "{", "window", "=", "new", "EclimWorkbenchWindow", "(", ")", ";", "}", "public", "String", "getId", "(", ")", "{", "return", "StringUtils", ".", "EMPTY", ";", "}", "public", "String", "getPluginId", "(", ")", "{", "return", "\"org.eclim\"", ";", "}", "public", "String", "getRegisteredName", "(", ")", "{", "return", "StringUtils", ".", "EMPTY", ";", "}", "public", "void", "registerContextMenu", "(", "String", "arg0", ",", "MenuManager", "arg1", ",", "ISelectionProvider", "arg2", ")", "{", "}", "public", "void", "registerContextMenu", "(", "MenuManager", "arg0", ",", "ISelectionProvider", "arg1", ")", "{", "}", "@", "SuppressWarnings", "(", "\"deprecation\"", ")", "public", "org", ".", "eclipse", ".", "ui", ".", "IKeyBindingService", "getKeyBindingService", "(", ")", "{", "return", "null", ";", "}", "public", "IWorkbenchPart", "getPart", "(", ")", "{", "return", "null", ";", "}", "public", "IWorkbenchPage", "getPage", "(", ")", "{", "return", "window", ".", "getActivePage", "(", ")", ";", "}", "public", "ISelectionProvider", "getSelectionProvider", "(", ")", "{", "return", "selectionProvider", ";", "}", "public", "Shell", "getShell", "(", ")", "{", "return", "EclimPlugin", ".", "getShell", "(", ")", ";", "}", "public", "IWorkbenchWindow", "getWorkbenchWindow", "(", ")", "{", "return", "window", ";", "}", "public", "void", "setSelectionProvider", "(", "ISelectionProvider", "provider", ")", "{", "this", ".", "selectionProvider", "=", "provider", ";", "}", "public", "Object", "getAdapter", "(", "Class", "arg0", ")", "{", "return", "null", ";", "}", "public", "Object", "getService", "(", "Class", "arg0", ")", "{", "return", "null", ";", "}", "public", "boolean", "hasService", "(", "Class", "arg0", ")", "{", "return", "false", ";", "}", "public", "IEditorActionBarContributor", "getActionBarContributor", "(", ")", "{", "return", "null", ";", "}", "public", "IActionBars", "getActionBars", "(", ")", "{", "return", "null", ";", "}", "public", "void", "registerContextMenu", "(", "MenuManager", "arg0", ",", "ISelectionProvider", "arg1", ",", "boolean", "arg2", ")", "{", "}", "public", "void", "registerContextMenu", "(", "String", "arg0", ",", "MenuManager", "arg1", ",", "ISelectionProvider", "arg2", ",", "boolean", "arg3", ")", "{", "}", "}", "</s>" ]
1,459
[ "<s>", "package", "org", ".", "eclim", ".", "eclipse", ".", "e4", ";", "import", "java", ".", "util", ".", "List", ";", "import", "javax", ".", "inject", ".", "Inject", ";", "import", "javax", ".", "inject", ".", "Named", ";", "import", "org", ".", "eclipse", ".", "e4", ".", "core", ".", "di", ".", "annotations", ".", "Optional", ";", "import", "org", ".", "eclipse", ".", "e4", ".", "ui", ".", "internal", ".", "workbench", ".", "E4Workbench", ";", "import", "org", ".", "eclipse", ".", "e4", ".", "ui", ".", "internal", ".", "workbench", ".", "swt", ".", "PartRenderingEngine", ";", "import", "org", ".", "eclipse", ".", "e4", ".", "ui", ".", "model", ".", "application", ".", "ui", ".", "MUIElement", ";", "import", "org", ".", "eclipse", ".", "e4", ".", "ui", ".", "model", ".", "application", ".", "ui", ".", "basic", ".", "MWindow", ";", "public", "class", "HeadlessPresentationEngine", "extends", "PartRenderingEngine", "{", "@", "Inject", "public", "HeadlessPresentationEngine", "(", "@", "Named", "(", "E4Workbench", ".", "RENDERER_FACTORY_URI", ")", "@", "Optional", "String", "factoryUrl", ")", "{", "super", "(", "factoryUrl", ")", ";", "}", "@", "Override", "protected", "Object", "createWidget", "(", "MUIElement", "element", ",", "Object", "parent", ")", "{", "if", "(", "parent", "==", "null", "&&", "element", "instanceof", "MWindow", ")", "{", "element", ".", "setVisible", "(", "false", ")", ";", "}", "return", "super", ".", "createWidget", "(", "element", ",", "parent", ")", ";", "}", "@", "Override", "protected", "boolean", "someAreVisible", "(", "List", "<", "MWindow", ">", "windows", ")", "{", "for", "(", "MWindow", "win", ":", "windows", ")", "{", "if", "(", "win", ".", "isToBeRendered", "(", ")", "&&", "win", ".", "getWidget", "(", ")", "!=", "null", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}", "}", "</s>" ]
1,460
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "io", ".", "InputStream", ";", "import", "java", ".", "net", ".", "URL", ";", "import", "java", ".", "text", ".", "MessageFormat", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Collection", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Locale", ";", "import", "java", ".", "util", ".", "Properties", ";", "import", "java", ".", "util", ".", "ResourceBundle", ";", "import", "org", ".", "eclim", ".", "Services", ";", "import", "org", ".", "eclim", ".", "command", ".", "Command", ";", "import", "org", ".", "eclim", ".", "logging", ".", "Logger", ";", "import", "org", ".", "eclim", ".", "util", ".", "file", ".", "FileUtils", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "FileLocator", ";", "public", "abstract", "class", "AbstractPluginResources", "implements", "PluginResources", "{", "private", "static", "final", "Logger", "logger", "=", "Logger", ".", "getLogger", "(", "AbstractPluginResources", ".", "class", ")", ";", "private", "static", "final", "String", "PLUGIN_PROPERTIES", "=", "\"\"", ";", "private", "String", "name", ";", "private", "String", "pluginName", ";", "private", "Properties", "properties", ";", "private", "ResourceBundle", "bundle", ";", "private", "List", "<", "String", ">", "missingResources", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "private", "HashMap", "<", "String", ",", "Class", "<", "?", "extends", "Command", ">", ">", "commands", "=", "new", "HashMap", "<", "String", ",", "Class", "<", "?", "extends", "Command", ">", ">", "(", ")", ";", "public", "void", "initialize", "(", "String", "name", ")", "{", "this", ".", "name", "=", "name", ";", "int", "index", "=", "name", ".", "lastIndexOf", "(", "'.'", ")", ";", "pluginName", "=", "index", "!=", "-", "1", "?", "name", ".", "substring", "(", "index", "+", "1", ")", ":", "name", ";", "}", "public", "String", "getName", "(", ")", "{", "return", "name", ";", "}", "public", "Collection", "<", "?", "extends", "Class", "<", "?", "extends", "Command", ">", ">", "getCommandClasses", "(", ")", "{", "return", "commands", ".", "values", "(", ")", ";", "}", "public", "Command", "getCommand", "(", "String", "name", ")", "throws", "Exception", "{", "if", "(", "!", "containsCommand", "(", "name", ")", ")", "{", "throw", "new", "RuntimeException", "(", "Services", ".", "getMessage", "(", "\"\"", ",", "name", ")", ")", ";", "}", "Class", "<", "?", "extends", "Command", ">", "cc", "=", "commands", ".", "get", "(", "name", ")", ";", "return", "cc", ".", "newInstance", "(", ")", ";", "}", "public", "boolean", "containsCommand", "(", "String", "name", ")", "{", "return", "commands", ".", "containsKey", "(", "name", ")", ";", "}", "public", "String", "getMessage", "(", "String", "key", ",", "Object", "...", "args", ")", "{", "ResourceBundle", "bundle", "=", "getResourceBundle", "(", ")", ";", "String", "message", "=", "bundle", ".", "getString", "(", "key", ")", ";", "return", "MessageFormat", ".", "format", "(", "message", ",", "args", ")", ";", "}", "public", "ResourceBundle", "getResourceBundle", "(", ")", "{", "if", "(", "bundle", "==", "null", ")", "{", "bundle", "=", "ResourceBundle", ".", "getBundle", "(", "getBundleBaseName", "(", ")", ",", "Locale", ".", "getDefault", "(", ")", ",", "getClass", "(", ")", ".", "getClassLoader", "(", ")", ")", ";", "}", "return", "bundle", ";", "}", "public", "String", "getProperty", "(", "String", "name", ")", "{", "return", "getProperty", "(", "name", ",", "null", ")", ";", "}", "public", "String", "getProperty", "(", "String", "name", ",", "String", "defaultValue", ")", "{", "if", "(", "properties", "==", "null", ")", "{", "properties", "=", "new", "Properties", "(", ")", ";", "try", "{", "properties", ".", "load", "(", "getClass", "(", ")", ".", "getResourceAsStream", "(", "PLUGIN_PROPERTIES", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "logger", ".", "warn", "(", "\"\"", "+", "getName", "(", ")", "+", "\"'\"", ",", "e", ")", ";", "}", "}", "return", "System", ".", "getProperty", "(", "name", ",", "properties", ".", "getProperty", "(", "name", ",", "defaultValue", ")", ")", ";", "}", "public", "URL", "getResource", "(", "String", "resource", ")", "{", "if", "(", "missingResources", ".", "contains", "(", "resource", ")", ")", "{", "return", "null", ";", "}", "try", "{", "String", "localResource", "=", "resource", ";", "int", "index", "=", "localResource", ".", "indexOf", "(", "\"resources\"", ")", ";", "if", "(", "index", "!=", "-", "1", ")", "{", "localResource", "=", "FileUtils", ".", "concat", "(", "localResource", ".", "substring", "(", "0", ",", "index", "+", "9", ")", ",", "pluginName", ",", "localResource", ".", "substring", "(", "index", "+", "9", ")", ")", ";", "}", "String", "file", "=", "FileUtils", ".", "concat", "(", "Services", ".", "DOT_ECLIM", ",", "localResource", ")", ";", "if", "(", "new", "File", "(", "file", ")", ".", "exists", "(", ")", ")", "{", "return", "new", "URL", "(", "\"file://\"", "+", "FileUtils", ".", "separatorsToUnix", "(", "file", ")", ")", ";", "}", "URL", "url", "=", "getClass", "(", ")", ".", "getResource", "(", "resource", ")", ";", "if", "(", "url", "!=", "null", ")", "{", "return", "FileLocator", ".", "resolve", "(", "url", ")", ";", "}", "missingResources", ".", "add", "(", "resource", ")", ";", "logger", ".", "debug", "(", "\"\"", "+", "getName", "(", ")", "+", "\"':", "\"", "+", "resource", ")", ";", "return", "null", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "}", "public", "InputStream", "getResourceAsStream", "(", "String", "resource", ")", "{", "try", "{", "URL", "url", "=", "getResource", "(", "resource", ")", ";", "if", "(", "url", "!=", "null", ")", "{", "return", "url", ".", "openStream", "(", ")", ";", "}", "return", "null", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "}", "public", "void", "close", "(", ")", "throws", "Exception", "{", "}", "public", "void", "registerCommand", "(", "Class", "<", "?", "extends", "Command", ">", "command", ")", "{", "org", ".", "eclim", ".", "annotation", ".", "Command", "info", "=", "(", "org", ".", "eclim", ".", "annotation", ".", "Command", ")", "command", ".", "getAnnotation", "(", "org", ".", "eclim", ".", "annotation", ".", "Command", ".", "class", ")", ";", "if", "(", "info", "!=", "null", ")", "{", "commands", ".", "put", "(", "info", ".", "name", "(", ")", ",", "command", ")", ";", "}", "else", "{", "logger", ".", "error", "(", "Services", ".", "getMessage", "(", "\"\"", ",", "command", ")", ")", ";", "}", "}", "protected", "abstract", "String", "getBundleBaseName", "(", ")", ";", "@", "Override", "public", "boolean", "equals", "(", "Object", "other", ")", "{", "return", "(", "(", "PluginResources", ")", "other", ")", ".", "getName", "(", ")", ".", "equals", "(", "getName", "(", ")", ")", ";", "}", "@", "Override", "public", "int", "hashCode", "(", ")", "{", "return", "getName", "(", ")", ".", "hashCode", "(", ")", ";", "}", "}", "</s>" ]
1,461
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ";", "import", "java", ".", "io", ".", "InputStream", ";", "import", "java", ".", "net", ".", "URL", ";", "import", "java", ".", "util", ".", "Properties", ";", "import", "java", ".", "util", ".", "Set", ";", "import", "org", ".", "eclim", ".", "Services", ";", "import", "org", ".", "eclim", ".", "command", ".", "Command", ";", "import", "org", ".", "eclim", ".", "logging", ".", "Logger", ";", "import", "org", ".", "eclim", ".", "util", ".", "IOUtils", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "FileLocator", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "Path", ";", "import", "org", ".", "osgi", ".", "framework", ".", "Bundle", ";", "import", "org", ".", "osgi", ".", "framework", ".", "BundleContext", ";", "import", "org", ".", "osgi", ".", "framework", ".", "BundleEvent", ";", "import", "org", ".", "osgi", ".", "framework", ".", "BundleListener", ";", "import", "org", ".", "scannotation", ".", "AnnotationDB", ";", "public", "class", "Plugin", "extends", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "Plugin", "implements", "BundleListener", "{", "private", "static", "final", "Logger", "logger", "=", "Logger", ".", "getLogger", "(", "Plugin", ".", "class", ")", ";", "private", "static", "Plugin", "plugin", ";", "public", "Plugin", "(", ")", "{", "plugin", "=", "this", ";", "}", "public", "static", "Plugin", "getDefault", "(", ")", "{", "return", "plugin", ";", "}", "public", "void", "start", "(", "BundleContext", "context", ")", "throws", "Exception", "{", "logger", ".", "debug", "(", "\"{}:", "start\"", ",", "context", ".", "getBundle", "(", ")", ".", "getSymbolicName", "(", ")", ")", ";", "super", ".", "start", "(", "context", ")", ";", "context", ".", "addBundleListener", "(", "this", ")", ";", "}", "public", "void", "activate", "(", "BundleContext", "context", ")", "{", "String", "name", "=", "context", ".", "getBundle", "(", ")", ".", "getSymbolicName", "(", ")", ";", "logger", ".", "debug", "(", "\"{}:", "activate\"", ",", "name", ")", ";", "logger", ".", "debug", "(", "\"\"", ",", "name", ")", ";", "Properties", "properties", "=", "new", "Properties", "(", ")", ";", "InputStream", "in", "=", "null", ";", "try", "{", "in", "=", "context", ".", "getBundle", "(", ")", ".", "getResource", "(", "\"\"", ")", ".", "openStream", "(", ")", ";", "properties", ".", "load", "(", "in", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "logger", ".", "error", "(", "\"\"", ",", "e", ")", ";", "}", "finally", "{", "IOUtils", ".", "closeQuietly", "(", "in", ")", ";", "}", "String", "resourceClass", "=", "properties", ".", "getProperty", "(", "\"\"", ")", ";", "logger", ".", "debug", "(", "\"\"", ",", "name", ",", "resourceClass", ")", ";", "Bundle", "bundle", "=", "this", ".", "getBundle", "(", ")", ";", "try", "{", "PluginResources", "resources", "=", "(", "PluginResources", ")", "bundle", ".", "loadClass", "(", "resourceClass", ")", ".", "newInstance", "(", ")", ";", "logger", ".", "debug", "(", "\"\"", ",", "name", ")", ";", "resources", ".", "initialize", "(", "name", ")", ";", "Services", ".", "addPluginResources", "(", "resources", ")", ";", "loadCommands", "(", "bundle", ",", "resources", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "logger", ".", "error", "(", "\"\"", "+", "name", ",", "e", ")", ";", "}", "}", "public", "void", "stop", "(", "BundleContext", "context", ")", "throws", "Exception", "{", "super", ".", "stop", "(", "context", ")", ";", "PluginResources", "resources", "=", "Services", ".", "removePluginResources", "(", "Services", ".", "getPluginResources", "(", "context", ".", "getBundle", "(", ")", ".", "getSymbolicName", "(", ")", ")", ")", ";", "resources", ".", "close", "(", ")", ";", "}", "private", "void", "loadCommands", "(", "Bundle", "bundle", ",", "PluginResources", "resources", ")", "{", "String", "name", "=", "this", ".", "getBundle", "(", ")", ".", "getSymbolicName", "(", ")", ";", "try", "{", "Class", "<", "?", ">", "rclass", "=", "resources", ".", "getClass", "(", ")", ";", "ClassLoader", "classloader", "=", "rclass", ".", "getClassLoader", "(", ")", ";", "String", "resourceName", "=", "rclass", ".", "getName", "(", ")", ".", "replace", "(", "'.'", ",", "'/'", ")", "+", "\".class\"", ";", "URL", "resource", "=", "classloader", ".", "getResource", "(", "resourceName", ")", ";", "String", "url", "=", "resource", ".", "toString", "(", ")", ";", "url", "=", "url", ".", "substring", "(", "0", ",", "url", ".", "indexOf", "(", "resourceName", ")", ")", ";", "String", "jarName", "=", "resources", ".", "getName", "(", ")", ".", "substring", "(", "\"org.\"", ".", "length", "(", ")", ")", "+", "\".jar\"", ";", "URL", "jarUrl", "=", "FileLocator", ".", "toFileURL", "(", "FileLocator", ".", "find", "(", "bundle", ",", "new", "Path", "(", "jarName", ")", ",", "null", ")", ")", ";", "logger", ".", "debug", "(", "\"\"", ",", "name", ")", ";", "AnnotationDB", "db", "=", "new", "AnnotationDB", "(", ")", ";", "db", ".", "setScanClassAnnotations", "(", "true", ")", ";", "db", ".", "setScanFieldAnnotations", "(", "false", ")", ";", "db", ".", "setScanMethodAnnotations", "(", "false", ")", ";", "db", ".", "setScanParameterAnnotations", "(", "false", ")", ";", "db", ".", "scanArchives", "(", "jarUrl", ")", ";", "Set", "<", "String", ">", "commandClasses", "=", "db", ".", "getAnnotationIndex", "(", ")", ".", "get", "(", "org", ".", "eclim", ".", "annotation", ".", "Command", ".", "class", ".", "getName", "(", ")", ")", ";", "if", "(", "commandClasses", "!=", "null", ")", "{", "for", "(", "String", "commandClass", ":", "commandClasses", ")", "{", "logger", ".", "debug", "(", "\"\"", ",", "name", ",", "commandClass", ")", ";", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "Class", "<", "?", "extends", "Command", ">", "cclass", "=", "(", "Class", "<", "?", "extends", "Command", ">", ")", "classloader", ".", "loadClass", "(", "commandClass", ")", ";", "resources", ".", "registerCommand", "(", "cclass", ")", ";", "}", "}", "else", "{", "logger", ".", "debug", "(", "\"\"", ",", "name", ")", ";", "}", "}", "catch", "(", "Throwable", "t", ")", "{", "logger", ".", "error", "(", "\"\"", ",", "t", ")", ";", "}", "}", "public", "void", "bundleChanged", "(", "BundleEvent", "event", ")", "{", "Bundle", "bundle", "=", "event", ".", "getBundle", "(", ")", ";", "if", "(", "this", ".", "getBundle", "(", ")", ".", "getSymbolicName", "(", ")", ".", "equals", "(", "bundle", ".", "getSymbolicName", "(", ")", ")", ")", "{", "if", "(", "logger", ".", "isDebugEnabled", "(", ")", ")", "{", "String", "state", "=", "\"unknown\"", ";", "switch", "(", "bundle", ".", "getState", "(", ")", ")", "{", "case", "Bundle", ".", "ACTIVE", ":", "state", "=", "\"active\"", ";", "break", ";", "case", "Bundle", ".", "INSTALLED", ":", "state", "=", "\"installed\"", ";", "break", ";", "case", "Bundle", ".", "RESOLVED", ":", "state", "=", "\"resolved\"", ";", "break", ";", "case", "Bundle", ".", "STARTING", ":", "state", "=", "\"starting\"", ";", "break", ";", "case", "Bundle", ".", "STOPPING", ":", "state", "=", "\"starting\"", ";", "break", ";", "case", "Bundle", ".", "UNINSTALLED", ":", "state", "=", "\"starting\"", ";", "break", ";", "}", "logger", ".", "debug", "(", "\"\"", ",", "bundle", ".", "getSymbolicName", "(", ")", ",", "state", ")", ";", "}", "if", "(", "bundle", ".", "getState", "(", ")", "==", "Bundle", ".", "ACTIVE", ")", "{", "this", ".", "activate", "(", "bundle", ".", "getBundleContext", "(", ")", ")", ";", "}", "}", "}", "}", "</s>" ]
1,462
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ";", "import", "java", ".", "io", ".", "InputStream", ";", "import", "java", ".", "net", ".", "URL", ";", "import", "java", ".", "util", ".", "Collection", ";", "import", "java", ".", "util", ".", "ResourceBundle", ";", "import", "org", ".", "eclim", ".", "command", ".", "Command", ";", "public", "interface", "PluginResources", "{", "public", "void", "initialize", "(", "String", "name", ")", ";", "public", "void", "registerCommand", "(", "Class", "<", "?", "extends", "Command", ">", "command", ")", ";", "public", "Command", "getCommand", "(", "String", "name", ")", "throws", "Exception", ";", "public", "boolean", "containsCommand", "(", "String", "name", ")", ";", "public", "String", "getMessage", "(", "String", "key", ",", "Object", "...", "args", ")", ";", "public", "ResourceBundle", "getResourceBundle", "(", ")", ";", "public", "String", "getProperty", "(", "String", "name", ")", ";", "public", "String", "getProperty", "(", "String", "name", ",", "String", "defaultValue", ")", ";", "public", "URL", "getResource", "(", "String", "resource", ")", ";", "public", "InputStream", "getResourceAsStream", "(", "String", "resource", ")", ";", "public", "void", "close", "(", ")", "throws", "Exception", ";", "public", "String", "getName", "(", ")", ";", "public", "Collection", "<", "?", "extends", "Class", "<", "?", "extends", "Command", ">", ">", "getCommandClasses", "(", ")", ";", "}", "</s>" ]
1,463
[ "<s>", "package", "org", ".", "eclim", ";", "import", "java", ".", "io", ".", "InputStream", ";", "import", "java", ".", "net", ".", "URL", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "MissingResourceException", ";", "import", "java", ".", "util", ".", "ResourceBundle", ";", "import", "org", ".", "eclim", ".", "command", ".", "Command", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "AbstractPluginResources", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "PluginResources", ";", "public", "class", "Services", "{", "public", "static", "final", "String", "DOT_ECLIM", "=", "System", ".", "getProperty", "(", "\"user.home\"", ")", "+", "\"/.eclim\"", ";", "private", "static", "HashMap", "<", "String", ",", "PluginResources", ">", "pluginResources", "=", "new", "HashMap", "<", "String", ",", "PluginResources", ">", "(", ")", ";", "static", "{", "PluginResources", "defaultResources", "=", "new", "DefaultPluginResources", "(", ")", ";", "defaultResources", ".", "initialize", "(", "\"org.eclim\"", ")", ";", "addPluginResources", "(", "defaultResources", ")", ";", "}", "public", "static", "List", "<", "Class", "<", "?", "extends", "Command", ">", ">", "getCommandClasses", "(", ")", "{", "ArrayList", "<", "Class", "<", "?", "extends", "Command", ">", ">", "commands", "=", "new", "ArrayList", "<", "Class", "<", "?", "extends", "Command", ">", ">", "(", ")", ";", "for", "(", "PluginResources", "resources", ":", "pluginResources", ".", "values", "(", ")", ")", "{", "commands", ".", "addAll", "(", "resources", ".", "getCommandClasses", "(", ")", ")", ";", "}", "return", "commands", ";", "}", "public", "static", "Command", "getCommand", "(", "String", "name", ")", "throws", "Exception", "{", "for", "(", "PluginResources", "resources", ":", "pluginResources", ".", "values", "(", ")", ")", "{", "if", "(", "resources", ".", "containsCommand", "(", "name", ")", ")", "{", "return", "resources", ".", "getCommand", "(", "name", ")", ";", "}", "}", "return", "null", ";", "}", "public", "static", "String", "getMessage", "(", "String", "key", ",", "Object", "...", "args", ")", "{", "for", "(", "PluginResources", "resources", ":", "pluginResources", ".", "values", "(", ")", ")", "{", "try", "{", "String", "message", "=", "resources", ".", "getMessage", "(", "key", ",", "args", ")", ";", "return", "message", ";", "}", "catch", "(", "MissingResourceException", "nsme", ")", "{", "}", "}", "return", "key", ";", "}", "public", "static", "ResourceBundle", "getResourceBundle", "(", "String", "plugin", ")", "{", "if", "(", "plugin", "!=", "null", ")", "{", "PluginResources", "resources", "=", "(", "PluginResources", ")", "pluginResources", ".", "get", "(", "plugin", ")", ";", "if", "(", "resources", "!=", "null", ")", "{", "return", "resources", ".", "getResourceBundle", "(", ")", ";", "}", "}", "return", "null", ";", "}", "public", "static", "URL", "getResource", "(", "String", "resource", ")", "{", "for", "(", "PluginResources", "resources", ":", "pluginResources", ".", "values", "(", ")", ")", "{", "URL", "url", "=", "resources", ".", "getResource", "(", "resource", ")", ";", "if", "(", "url", "!=", "null", ")", "{", "return", "url", ";", "}", "}", "return", "null", ";", "}", "public", "static", "InputStream", "getResourceAsStream", "(", "String", "resource", ")", "{", "for", "(", "PluginResources", "resources", ":", "pluginResources", ".", "values", "(", ")", ")", "{", "InputStream", "stream", "=", "resources", ".", "getResourceAsStream", "(", "resource", ")", ";", "if", "(", "stream", "!=", "null", ")", "{", "return", "stream", ";", "}", "}", "return", "null", ";", "}", "public", "static", "PluginResources", "getPluginResources", "(", "String", "plugin", ")", "{", "PluginResources", "resources", "=", "(", "PluginResources", ")", "pluginResources", ".", "get", "(", "plugin", ")", ";", "if", "(", "resources", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "Services", ".", "getMessage", "(", "\"\"", ",", "plugin", ")", ")", ";", "}", "return", "resources", ";", "}", "public", "static", "void", "addPluginResources", "(", "PluginResources", "resources", ")", "{", "pluginResources", ".", "put", "(", "resources", ".", "getName", "(", ")", ",", "resources", ")", ";", "}", "public", "static", "PluginResources", "removePluginResources", "(", "PluginResources", "resources", ")", "{", "return", "pluginResources", ".", "remove", "(", "resources", ".", "getName", "(", ")", ")", ";", "}", "public", "static", "class", "DefaultPluginResources", "extends", "AbstractPluginResources", "{", "public", "static", "final", "String", "NAME", "=", "\"org.eclim\"", ";", "protected", "String", "getBundleBaseName", "(", ")", "{", "return", "\"\"", ";", "}", "public", "String", "getName", "(", ")", "{", "return", "NAME", ";", "}", "}", "}", "</s>" ]
1,464
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "cdt", ";", "import", "org", ".", "eclim", ".", "Services", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "AbstractPluginResources", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "cdt", ".", "project", ".", "CProjectManager", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "project", ".", "ProjectManagement", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "project", ".", "ProjectNatureFactory", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "CCProjectNature", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "CProjectNature", ";", "public", "class", "PluginResources", "extends", "AbstractPluginResources", "{", "public", "static", "final", "String", "NAME", "=", "\"\"", ";", "public", "static", "final", "String", "NATURE_C", "=", "CProjectNature", ".", "C_NATURE_ID", ";", "public", "static", "final", "String", "NATURE_CPP", "=", "CCProjectNature", ".", "CC_NATURE_ID", ";", "@", "Override", "public", "void", "initialize", "(", "String", "name", ")", "{", "super", ".", "initialize", "(", "name", ")", ";", "ProjectNatureFactory", ".", "addNature", "(", "\"c\"", ",", "CProjectNature", ".", "C_NATURE_ID", ")", ";", "ProjectNatureFactory", ".", "addNature", "(", "\"c++\"", ",", "new", "String", "[", "]", "{", "CProjectNature", ".", "C_NATURE_ID", ",", "CCProjectNature", ".", "CC_NATURE_ID", ",", "}", ")", ";", "ProjectNatureFactory", ".", "addNature", "(", "\"cpp\"", ",", "new", "String", "[", "]", "{", "CProjectNature", ".", "C_NATURE_ID", ",", "CCProjectNature", ".", "CC_NATURE_ID", ",", "}", ")", ";", "ProjectManagement", ".", "addProjectManager", "(", "CProjectNature", ".", "C_NATURE_ID", ",", "new", "CProjectManager", "(", ")", ")", ";", "ProjectManagement", ".", "addProjectManager", "(", "CCProjectNature", ".", "CC_NATURE_ID", ",", "new", "CProjectManager", "(", ")", ")", ";", "}", "@", "Override", "protected", "String", "getBundleBaseName", "(", ")", "{", "return", "\"\"", ";", "}", "}", "</s>" ]
1,465
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "cdt", ".", "util", ";", "import", "org", ".", "eclim", ".", "Services", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "cdt", ".", "PluginResources", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "project", ".", "ProjectNatureFactory", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "util", ".", "ProjectUtils", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "model", ".", "CoreModel", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "model", ".", "CoreModelUtil", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "model", ".", "ICProject", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "model", ".", "ITranslationUnit", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "IProject", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "Path", ";", "public", "class", "CUtils", "{", "public", "static", "ICProject", "getCProject", "(", "String", "project", ")", "throws", "Exception", "{", "return", "getCProject", "(", "ProjectUtils", ".", "getProject", "(", "project", ",", "true", ")", ")", ";", "}", "public", "static", "ICProject", "getCProject", "(", "IProject", "project", ")", "throws", "Exception", "{", "if", "(", "ProjectUtils", ".", "getPath", "(", "project", ")", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "Services", ".", "getMessage", "(", "\"\"", ",", "project", ".", "getName", "(", ")", ")", ")", ";", "}", "if", "(", "!", "project", ".", "hasNature", "(", "PluginResources", ".", "NATURE_C", ")", "&&", "!", "project", ".", "hasNature", "(", "PluginResources", ".", "NATURE_CPP", ")", ")", "{", "String", "name", "=", "ProjectNatureFactory", ".", "getAliasForNature", "(", "PluginResources", ".", "NATURE_C", ")", "+", "\"", "/", "\"", "+", "ProjectNatureFactory", ".", "getAliasForNature", "(", "PluginResources", ".", "NATURE_CPP", ")", ";", "throw", "new", "IllegalArgumentException", "(", "Services", ".", "getMessage", "(", "\"\"", ",", "project", ".", "getName", "(", ")", ",", "name", ")", ")", ";", "}", "ICProject", "cproject", "=", "CoreModel", ".", "getDefault", "(", ")", ".", "create", "(", "project", ")", ";", "if", "(", "cproject", "==", "null", "||", "!", "cproject", ".", "exists", "(", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "Services", ".", "getMessage", "(", "\"\"", ",", "project", ")", ")", ";", "}", "return", "cproject", ";", "}", "public", "static", "ITranslationUnit", "getTranslationUnit", "(", "String", "project", ",", "String", "file", ")", "throws", "Exception", "{", "return", "getTranslationUnit", "(", "getCProject", "(", "project", ")", ",", "file", ")", ";", "}", "public", "static", "ITranslationUnit", "getTranslationUnit", "(", "ICProject", "project", ",", "String", "file", ")", "throws", "Exception", "{", "Path", "path", "=", "new", "Path", "(", "ProjectUtils", ".", "getFilePath", "(", "project", ".", "getProject", "(", ")", ",", "file", ")", ")", ";", "ITranslationUnit", "src", "=", "CoreModelUtil", ".", "findTranslationUnitForLocation", "(", "path", ",", "project", ")", ";", "if", "(", "src", "==", "null", "||", "!", "src", ".", "exists", "(", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "Services", ".", "getMessage", "(", "\"\"", ",", "file", ")", ")", ";", "}", "src", ".", "close", "(", ")", ";", "src", ".", "open", "(", "null", ")", ";", "return", "src", ";", "}", "}", "</s>" ]
1,466
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "cdt", ".", "project", ";", "import", "java", ".", "io", ".", "FileInputStream", ";", "import", "java", ".", "util", ".", "Arrays", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "regex", ".", "Matcher", ";", "import", "java", ".", "util", ".", "regex", ".", "Pattern", ";", "import", "org", ".", "eclim", ".", "Services", ";", "import", "org", ".", "eclim", ".", "command", ".", "CommandLine", ";", "import", "org", ".", "eclim", ".", "command", ".", "Error", ";", "import", "org", ".", "eclim", ".", "eclipse", ".", "EclimPlugin", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "cdt", ".", "PluginResources", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "cdt", ".", "util", ".", "CUtils", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "project", ".", "ProjectManager", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "util", ".", "XmlUtils", ";", "import", "org", ".", "eclim", ".", "util", ".", "IOUtils", ";", "import", "org", ".", "eclim", ".", "util", ".", "file", ".", "FileOffsets", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "CCorePlugin", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "index", ".", "IIndexManager", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "model", ".", "CoreModel", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "model", ".", "ICModelStatus", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "model", ".", "ICProject", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "model", ".", "IPathEntry", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "settings", ".", "model", ".", "ICConfigurationDescription", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "settings", ".", "model", ".", "ICProjectDescription", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "settings", ".", "model", ".", "ICProjectDescriptionManager", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "settings", ".", "model", ".", "extension", ".", "CConfigurationData", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "settings", ".", "model", ".", "util", ".", "PathEntryTranslator", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "managedbuilder", ".", "buildproperties", ".", "IBuildPropertyManager", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "managedbuilder", ".", "buildproperties", ".", "IBuildPropertyValue", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "managedbuilder", ".", "core", ".", "BuildListComparator", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "managedbuilder", ".", "core", ".", "IBuilder", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "managedbuilder", ".", "core", ".", "IConfiguration", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "managedbuilder", ".", "core", ".", "IToolChain", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "managedbuilder", ".", "core", ".", "ManagedBuildManager", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "managedbuilder", ".", "internal", ".", "core", ".", "Configuration", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "managedbuilder", ".", "internal", ".", "core", ".", "ManagedBuildInfo", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "managedbuilder", ".", "internal", ".", "core", ".", "ManagedProject", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "managedbuilder", ".", "internal", ".", "core", ".", "ToolChain", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "managedbuilder", ".", "internal", ".", "dataprovider", ".", "ConfigurationDataProvider", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "managedbuilder", ".", "ui", ".", "wizards", ".", "CfgHolder", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "managedbuilder", ".", "ui", ".", "wizards", ".", "MBSWizardHandler", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "IFile", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "IProject", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "CoreException", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "IProgressMonitor", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "NullProgressMonitor", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "wizard", ".", "IWizard", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Composite", ";", "public", "class", "CProjectManager", "implements", "ProjectManager", "{", "private", "static", "final", "String", "CPROJECT_XSD", "=", "\"\"", ";", "private", "static", "final", "Pattern", "ENTRY_PATTERN", "=", "Pattern", ".", "compile", "(", "\"\"", ")", ";", "private", "static", "final", "Pattern", "INCLUDE_PATTERN", "=", "Pattern", ".", "compile", "(", "\"\"", ")", ";", "@", "Override", "public", "void", "create", "(", "final", "IProject", "project", ",", "CommandLine", "commandLine", ")", "throws", "Exception", "{", "final", "IBuildPropertyManager", "buildManager", "=", "ManagedBuildManager", ".", "getBuildPropertyManager", "(", ")", ";", "final", "IBuildPropertyValue", "[", "]", "vs", "=", "buildManager", ".", "getPropertyType", "(", "MBSWizardHandler", ".", "ARTIFACT", ")", ".", "getSupportedValues", "(", ")", ";", "Arrays", ".", "sort", "(", "vs", ",", "BuildListComparator", ".", "getInstance", "(", ")", ")", ";", "MBSWizardHandler", "handler", "=", "null", ";", "toolchainLoop", ":", "for", "(", "IBuildPropertyValue", "value", ":", "vs", ")", "{", "final", "IToolChain", "[", "]", "toolChains", "=", "ManagedBuildManager", ".", "getExtensionsToolChains", "(", "MBSWizardHandler", ".", "ARTIFACT", ",", "value", ".", "getId", "(", ")", ",", "false", ")", ";", "if", "(", "toolChains", "!=", "null", "&&", "toolChains", ".", "length", ">", "0", ")", "{", "for", "(", "IToolChain", "tc", ":", "toolChains", ")", "{", "if", "(", "!", "tc", ".", "isAbstract", "(", ")", "&&", "!", "tc", ".", "isSystemObject", "(", ")", "&&", "tc", ".", "isSupported", "(", ")", "&&", "ManagedBuildManager", ".", "isPlatformOk", "(", "tc", ")", ")", "{", "handler", "=", "new", "LocalMBSWizardHandler", "(", "value", ",", "EclimPlugin", ".", "getShell", "(", ")", ",", "null", ",", "tc", ")", ";", "CfgHolder", "[", "]", "cfgs", "=", "handler", ".", "getCfgItems", "(", "false", ")", ";", "if", "(", "cfgs", "!=", "null", "&&", "cfgs", ".", "length", ">", "0", "&&", "cfgs", "[", "0", "]", ".", "getConfiguration", "(", ")", "!=", "null", ")", "{", "break", "toolchainLoop", ";", "}", "}", "}", "IToolChain", "ntc", "=", "ManagedBuildManager", ".", "getExtensionToolChain", "(", "ConfigurationDataProvider", ".", "PREF_TC_ID", ")", ";", "handler", "=", "new", "LocalSTDWizardHandler", "(", "value", ",", "EclimPlugin", ".", "getShell", "(", ")", ",", "null", ",", "ntc", ")", ";", "}", "}", "try", "{", "handler", ".", "createProject", "(", "project", ",", "true", ",", "true", ",", "new", "NullProgressMonitor", "(", ")", ")", ";", "ICProject", "cproject", "=", "CUtils", ".", "getCProject", "(", "project", ")", ";", "CCorePlugin", ".", "getIndexManager", "(", ")", ".", "reindex", "(", "cproject", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "}", "@", "Override", "public", "List", "<", "Error", ">", "update", "(", "IProject", "project", ",", "CommandLine", "commandLine", ")", "throws", "Exception", "{", "PluginResources", "resources", "=", "(", "PluginResources", ")", "Services", ".", "getPluginResources", "(", "PluginResources", ".", "NAME", ")", ";", "List", "<", "Error", ">", "errors", "=", "XmlUtils", ".", "validateXml", "(", "project", ".", "getName", "(", ")", ",", "\".cproject\"", ",", "resources", ".", "getResource", "(", "CPROJECT_XSD", ")", ".", "toString", "(", ")", ")", ";", "if", "(", "errors", ".", "size", "(", ")", ">", "0", ")", "{", "return", "errors", ";", "}", "ICProjectDescriptionManager", "manager", "=", "CoreModel", ".", "getDefault", "(", ")", ".", "getProjectDescriptionManager", "(", ")", ";", "ICProjectDescription", "desc", "=", "manager", ".", "getProjectDescription", "(", "project", ",", "false", ")", ";", "ICConfigurationDescription", "config", "=", "desc", ".", "getDefaultSettingConfiguration", "(", ")", ";", "PathEntryTranslator", ".", "PathEntryCollector", "cr", "=", "PathEntryTranslator", ".", "collectEntries", "(", "project", ",", "config", ")", ";", "IPathEntry", "[", "]", "entries", "=", "cr", ".", "getEntries", "(", "PathEntryTranslator", ".", "INCLUDE_USER", ",", "config", ")", ";", "ICProject", "cproject", "=", "CoreModel", ".", "getDefault", "(", ")", ".", "create", "(", "project", ")", ";", "String", "dotcproject", "=", "project", ".", "getFile", "(", "\".cproject\"", ")", ".", "getRawLocation", "(", ")", ".", "toOSString", "(", ")", ";", "FileOffsets", "offsets", "=", "FileOffsets", ".", "compile", "(", "dotcproject", ")", ";", "String", "cprojectValue", "=", "IOUtils", ".", "toString", "(", "new", "FileInputStream", "(", "dotcproject", ")", ")", ";", "for", "(", "IPathEntry", "entry", ":", "entries", ")", "{", "ICModelStatus", "status", "=", "CoreModel", ".", "validatePathEntry", "(", "cproject", ",", "entry", ",", "true", ",", "true", ")", ";", "if", "(", "!", "status", ".", "isOK", "(", ")", ")", "{", "errors", ".", "add", "(", "createErrorFromStatus", "(", "offsets", ",", "dotcproject", ",", "cprojectValue", ",", "entry", ",", "status", ")", ")", ";", "}", "}", "return", "errors", ";", "}", "@", "Override", "public", "void", "delete", "(", "IProject", "project", ",", "CommandLine", "commandLine", ")", "throws", "Exception", "{", "}", "@", "Override", "public", "void", "refresh", "(", "IProject", "project", ",", "CommandLine", "commandLine", ")", "throws", "Exception", "{", "ICProject", "cproject", "=", "CUtils", ".", "getCProject", "(", "project", ")", ";", "CCorePlugin", ".", "getIndexManager", "(", ")", ".", "reindex", "(", "cproject", ")", ";", "CCorePlugin", ".", "getIndexManager", "(", ")", ".", "joinIndexer", "(", "IIndexManager", ".", "FOREVER", ",", "new", "NullProgressMonitor", "(", ")", ")", ";", "}", "@", "Override", "public", "void", "refresh", "(", "IProject", "project", ",", "IFile", "file", ")", "throws", "Exception", "{", "}", "private", "Error", "createErrorFromStatus", "(", "FileOffsets", "offsets", ",", "String", "filename", ",", "String", "contents", ",", "IPathEntry", "entry", ",", "ICModelStatus", "status", ")", "throws", "Exception", "{", "int", "line", "=", "0", ";", "int", "col", "=", "0", ";", "Matcher", "matcher", "=", "null", ";", "String", "pattern", "=", "null", ";", "switch", "(", "entry", ".", "getEntryKind", "(", ")", ")", "{", "case", "IPathEntry", ".", "CDT_OUTPUT", ":", "case", "IPathEntry", ".", "CDT_SOURCE", ":", "matcher", "=", "ENTRY_PATTERN", ".", "matcher", "(", "status", ".", "getString", "(", ")", ")", ";", "pattern", "=", "\"name=\\\"\"", "+", "matcher", ".", "replaceFirst", "(", "\"$1\"", ")", "+", "\"\\\"\"", ";", "break", ";", "case", "IPathEntry", ".", "CDT_INCLUDE", ":", "case", "IPathEntry", ".", "CDT_INCLUDE_FILE", ":", "matcher", "=", "INCLUDE_PATTERN", ".", "matcher", "(", "status", ".", "getString", "(", ")", ")", ";", "pattern", "=", "\"value=\\\"\"", "+", "matcher", ".", "replaceFirst", "(", "\"$1\"", ")", "+", "\"\\\"\"", ";", "break", ";", "}", "if", "(", "matcher", "!=", "null", ")", "{", "matcher", "=", "Pattern", ".", "compile", "(", "\"\\\\Q\"", "+", "pattern", "+", "\"\\\\E\"", ")", ".", "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", ")", ";", "}", "private", "class", "LocalMBSWizardHandler", "extends", "MBSWizardHandler", "{", "private", "IToolChain", "toolchain", ";", "public", "LocalMBSWizardHandler", "(", "IBuildPropertyValue", "val", ",", "Composite", "p", ",", "IWizard", "w", ",", "IToolChain", "tc", ")", "{", "super", "(", "val", ",", "p", ",", "w", ")", ";", "this", ".", "toolchain", "=", "tc", ";", "}", "public", "IToolChain", "[", "]", "getSelectedToolChains", "(", ")", "{", "return", "new", "IToolChain", "[", "]", "{", "toolchain", "}", ";", "}", "protected", "void", "doCustom", "(", "IProject", "project", ")", "{", "}", "public", "CfgHolder", "[", "]", "getCfgItems", "(", "boolean", "defaults", ")", "{", "CfgHolder", "[", "]", "cfgs", "=", "super", ".", "getCfgItems", "(", "defaults", ")", ";", "if", "(", "cfgs", "==", "null", "||", "cfgs", ".", "length", "==", "0", ")", "{", "IToolChain", "tc", "=", "ManagedBuildManager", ".", "getExtensionToolChain", "(", "ConfigurationDataProvider", ".", "PREF_TC_ID", ")", ";", "cfgs", "=", "new", "CfgHolder", "[", "1", "]", ";", "cfgs", "[", "0", "]", "=", "new", "CfgHolder", "(", "tc", ",", "null", ")", ";", "}", "return", "cfgs", ";", "}", "}", "private", "class", "LocalSTDWizardHandler", "extends", "LocalMBSWizardHandler", "{", "public", "LocalSTDWizardHandler", "(", "IBuildPropertyValue", "val", ",", "Composite", "p", ",", "IWizard", "w", ",", "IToolChain", "tc", ")", "{", "super", "(", "val", ",", "p", ",", "w", ",", "tc", ")", ";", "}", "public", "void", "createProject", "(", "IProject", "project", ",", "boolean", "defaults", ",", "boolean", "onFinish", ",", "IProgressMonitor", "monitor", ")", "throws", "CoreException", "{", "try", "{", "monitor", ".", "beginTask", "(", "\"\"", ",", "100", ")", ";", "setProjectDescription", "(", "project", ",", "defaults", ",", "onFinish", ",", "monitor", ")", ";", "doTemplatesPostProcess", "(", "project", ")", ";", "doCustom", "(", "project", ")", ";", "monitor", ".", "worked", "(", "30", ")", ";", "}", "finally", "{", "monitor", ".", "done", "(", ")", ";", "}", "}", "private", "void", "setProjectDescription", "(", "IProject", "project", ",", "boolean", "defaults", ",", "boolean", "onFinish", ",", "IProgressMonitor", "monitor", ")", "throws", "CoreException", "{", "ICProjectDescriptionManager", "mngr", "=", "CoreModel", ".", "getDefault", "(", ")", ".", "getProjectDescriptionManager", "(", ")", ";", "ICProjectDescription", "des", "=", "mngr", ".", "createProjectDescription", "(", "project", ",", "false", ",", "!", "onFinish", ")", ";", "ManagedBuildInfo", "info", "=", "ManagedBuildManager", ".", "createBuildInfo", "(", "project", ")", ";", "ManagedProject", "mProj", "=", "new", "ManagedProject", "(", "des", ")", ";", "info", ".", "setManagedProject", "(", "mProj", ")", ";", "monitor", ".", "worked", "(", "20", ")", ";", "cfgs", "=", "CfgHolder", ".", "unique", "(", "getCfgItems", "(", "false", ")", ")", ";", "cfgs", "=", "CfgHolder", ".", "reorder", "(", "cfgs", ")", ";", "int", "work", "=", "50", "/", "cfgs", ".", "length", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "cfgs", ".", "length", ";", "i", "++", ")", "{", "String", "s", "=", "(", "cfgs", "[", "i", "]", ".", "getToolChain", "(", ")", "==", "null", ")", "?", "\"0\"", ":", "(", "(", "ToolChain", ")", "(", "cfgs", "[", "i", "]", ".", "getToolChain", "(", ")", ")", ")", ".", "getId", "(", ")", ";", "Configuration", "cfg", "=", "new", "Configuration", "(", "mProj", ",", "(", "ToolChain", ")", "cfgs", "[", "i", "]", ".", "getToolChain", "(", ")", ",", "ManagedBuildManager", ".", "calculateChildId", "(", "s", ",", "null", ")", ",", "cfgs", "[", "i", "]", ".", "getName", "(", ")", ")", ";", "cfgs", "[", "i", "]", ".", "setConfiguration", "(", "cfg", ")", ";", "IBuilder", "bld", "=", "cfg", ".", "getEditableBuilder", "(", ")", ";", "if", "(", "bld", "!=", "null", ")", "{", "if", "(", "bld", ".", "isInternalBuilder", "(", ")", ")", "{", "IConfiguration", "prefCfg", "=", "ManagedBuildManager", ".", "getPreferenceConfiguration", "(", "false", ")", ";", "IBuilder", "prefBuilder", "=", "prefCfg", ".", "getBuilder", "(", ")", ";", "cfg", ".", "changeBuilder", "(", "prefBuilder", ",", "ManagedBuildManager", ".", "calculateChildId", "(", "cfg", ".", "getId", "(", ")", ",", "null", ")", ",", "prefBuilder", ".", "getName", "(", ")", ")", ";", "bld", "=", "cfg", ".", "getEditableBuilder", "(", ")", ";", "bld", ".", "setBuildPath", "(", "null", ")", ";", "}", "bld", ".", "setManagedBuildOn", "(", "false", ")", ";", "}", "cfg", ".", "setArtifactName", "(", "mProj", ".", "getDefaultArtifactName", "(", ")", ")", ";", "CConfigurationData", "data", "=", "cfg", ".", "getConfigurationData", "(", ")", ";", "des", ".", "createConfiguration", "(", "ManagedBuildManager", ".", "CFG_DATA_PROVIDER_ID", ",", "data", ")", ";", "monitor", ".", "worked", "(", "work", ")", ";", "}", "mngr", ".", "setProjectDescription", "(", "project", ",", "des", ")", ";", "}", "}", "}", "</s>" ]
1,467
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "cdt", ".", "command", ".", "hierarchy", ";", "import", "java", ".", "lang", ".", "reflect", ".", "Field", ";", "import", "java", ".", "lang", ".", "reflect", ".", "Method", ";", "import", "java", ".", "text", ".", "Collator", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Collections", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "HashSet", ";", "import", "java", ".", "util", ".", "Set", ";", "import", "org", ".", "eclim", ".", "annotation", ".", "Command", ";", "import", "org", ".", "eclim", ".", "command", ".", "CommandLine", ";", "import", "org", ".", "eclim", ".", "command", ".", "Options", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "cdt", ".", "command", ".", "search", ".", "SearchCommand", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "cdt", ".", "util", ".", "CUtils", ";", "import", "org", ".", "eclim", ".", "util", ".", "StringUtils", ";", "import", "org", ".", "eclim", ".", "util", ".", "file", ".", "Position", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "CCorePlugin", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "dom", ".", "ast", ".", "IASTNode", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "dom", ".", "ast", ".", "IBinding", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "dom", ".", "ast", ".", "cpp", ".", "ICPPMethod", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "index", ".", "IIndex", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "index", ".", "IIndexBinding", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "index", ".", "IIndexManager", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "index", ".", "IIndexName", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "model", ".", "ICElement", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "model", ".", "ICProject", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "model", ".", "IFunction", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "model", ".", "IFunctionDeclaration", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "model", ".", "ITranslationUnit", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "model", ".", "IWorkingCopy", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "internal", ".", "core", ".", "dom", ".", "parser", ".", "cpp", ".", "ClassTypeHelper", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "internal", ".", "core", ".", "model", ".", "ASTCache", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "internal", ".", "ui", ".", "callhierarchy", ".", "CallHierarchyUI", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "internal", ".", "ui", ".", "editor", ".", "ASTProvider", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "internal", ".", "ui", ".", "editor", ".", "WorkingCopyManager", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "internal", ".", "ui", ".", "viewsupport", ".", "IndexUI", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "ui", ".", "CUIPlugin", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "IFile", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "IResource", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "NullProgressMonitor", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "text", ".", "ITextSelection", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "text", ".", "TextSelection", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "IEditorInput", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "part", ".", "FileEditorInput", ";", "@", "Command", "(", "name", "=", "\"\"", ",", "options", "=", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", ")", "public", "class", "CallHierarchyCommand", "extends", "SearchCommand", "{", "@", "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", ")", ";", "int", "length", "=", "commandLine", ".", "getIntValue", "(", "Options", ".", "LENGTH_OPTION", ")", ";", "ICProject", "cproject", "=", "CUtils", ".", "getCProject", "(", "projectName", ")", ";", "CUIPlugin", "cuiPlugin", "=", "CUIPlugin", ".", "getDefault", "(", ")", ";", "ITranslationUnit", "src", "=", "CUtils", ".", "getTranslationUnit", "(", "cproject", ",", "file", ")", ";", "CCorePlugin", ".", "getIndexManager", "(", ")", ".", "update", "(", "new", "ICElement", "[", "]", "{", "src", "}", ",", "IIndexManager", ".", "UPDATE_ALL", ")", ";", "CCorePlugin", ".", "getIndexManager", "(", ")", ".", "joinIndexer", "(", "3000", ",", "new", "NullProgressMonitor", "(", ")", ")", ";", "src", "=", "src", ".", "getWorkingCopy", "(", ")", ";", "IEditorInput", "input", "=", "new", "FileEditorInput", "(", "(", "IFile", ")", "src", ".", "getResource", "(", ")", ")", ";", "WorkingCopyManager", "manager", "=", "(", "WorkingCopyManager", ")", "cuiPlugin", ".", "getWorkingCopyManager", "(", ")", ";", "manager", ".", "connect", "(", "input", ")", ";", "manager", ".", "setWorkingCopy", "(", "input", ",", "(", "IWorkingCopy", ")", "src", ")", ";", "HashMap", "<", "String", ",", "Object", ">", "result", "=", "new", "HashMap", "<", "String", ",", "Object", ">", "(", ")", ";", "try", "{", "ASTProvider", "provider", "=", "ASTProvider", ".", "getASTProvider", "(", ")", ";", "Field", "astCache", "=", "ASTProvider", ".", "class", ".", "getDeclaredField", "(", "\"fCache\"", ")", ";", "astCache", ".", "setAccessible", "(", "true", ")", ";", "(", "(", "ASTCache", ")", "astCache", ".", "get", "(", "provider", ")", ")", ".", "setActiveElement", "(", "src", ")", ";", "TextSelection", "selection", "=", "new", "TextSelection", "(", "offset", ",", "length", ")", ";", "Method", "findDefinitions", "=", "CallHierarchyUI", ".", "class", ".", "getDeclaredMethod", "(", "\"\"", ",", "ICProject", ".", "class", ",", "IEditorInput", ".", "class", ",", "ITextSelection", ".", "class", ")", ";", "findDefinitions", ".", "setAccessible", "(", "true", ")", ";", "ICElement", "[", "]", "elements", "=", "(", "ICElement", "[", "]", ")", "findDefinitions", ".", "invoke", "(", "null", ",", "cproject", ",", "input", ",", "selection", ")", ";", "if", "(", "elements", "!=", "null", "&&", "elements", ".", "length", ">", "0", ")", "{", "ICElement", "callee", "=", "elements", "[", "0", "]", ";", "Set", "<", "ICElement", ">", "seen", "=", "new", "HashSet", "<", "ICElement", ">", "(", ")", ";", "ICProject", "project", "=", "callee", ".", "getCProject", "(", ")", ";", "ICProject", "[", "]", "scope", "=", "getScope", "(", "SCOPE_PROJECT", ",", "project", ")", ";", "IIndex", "index", "=", "CCorePlugin", ".", "getIndexManager", "(", ")", ".", "getIndex", "(", "scope", ",", "IIndexManager", ".", "ADD_DEPENDENCIES", "|", "IIndexManager", ".", "ADD_DEPENDENT", ")", ";", "index", ".", "acquireReadLock", "(", ")", ";", "try", "{", "IIndexName", "name", "=", "IndexUI", ".", "elementToName", "(", "index", ",", "callee", ")", ";", "result", "=", "formatElement", "(", "index", ",", "callee", ",", "name", ",", "seen", ")", ";", "}", "finally", "{", "index", ".", "releaseReadLock", "(", ")", ";", "}", "}", "}", "finally", "{", "manager", ".", "removeWorkingCopy", "(", "input", ")", ";", "manager", ".", "disconnect", "(", "input", ")", ";", "}", "return", "result", ";", "}", "private", "ArrayList", "<", "HashMap", "<", "String", ",", "Object", ">", ">", "findCalledBy", "(", "IIndex", "index", ",", "ICElement", "callee", ",", "Set", "<", "ICElement", ">", "seen", ")", "throws", "Exception", "{", "ArrayList", "<", "HashMap", "<", "String", ",", "Object", ">", ">", "results", "=", "new", "ArrayList", "<", "HashMap", "<", "String", ",", "Object", ">", ">", "(", ")", ";", "ICProject", "project", "=", "callee", ".", "getCProject", "(", ")", ";", "IIndexBinding", "calleeBinding", "=", "IndexUI", ".", "elementToBinding", "(", "index", ",", "callee", ")", ";", "if", "(", "calleeBinding", "!=", "null", ")", "{", "results", ".", "addAll", "(", "findCalledBy", "(", "index", ",", "calleeBinding", ",", "true", ",", "project", ",", "seen", ")", ")", ";", "if", "(", "calleeBinding", "instanceof", "ICPPMethod", ")", "{", "IBinding", "[", "]", "overriddenBindings", "=", "null", ";", "try", "{", "Method", "findOverridden", "=", "ClassTypeHelper", ".", "class", ".", "getMethod", "(", "\"\"", ",", "ICPPMethod", ".", "class", ",", "IASTNode", ".", "class", ")", ";", "overriddenBindings", "=", "(", "IBinding", "[", "]", ")", "findOverridden", ".", "invoke", "(", "null", ",", "(", "ICPPMethod", ")", "calleeBinding", ",", "null", ")", ";", "}", "catch", "(", "NoSuchMethodException", "nsme", ")", "{", "Method", "findOverridden", "=", "ClassTypeHelper", ".", "class", ".", "getMethod", "(", "\"\"", ",", "ICPPMethod", ".", "class", ")", ";", "overriddenBindings", "=", "(", "IBinding", "[", "]", ")", "findOverridden", ".", "invoke", "(", "null", ",", "(", "ICPPMethod", ")", "calleeBinding", ")", ";", "}", "for", "(", "IBinding", "overriddenBinding", ":", "overriddenBindings", ")", "{", "results", ".", "addAll", "(", "findCalledBy", "(", "index", ",", "overriddenBinding", ",", "false", ",", "project", ",", "seen", ")", ")", ";", "}", "}", "}", "return", "results", ";", "}", "private", "ArrayList", "<", "HashMap", "<", "String", ",", "Object", ">", ">", "findCalledBy", "(", "IIndex", "index", ",", "IBinding", "callee", ",", "boolean", "includeOrdinaryCalls", ",", "ICProject", "project", ",", "Set", "<", "ICElement", ">", "seen", ")", "throws", "Exception", "{", "IIndexName", "[", "]", "names", "=", "index", ".", "findNames", "(", "callee", ",", "IIndex", ".", "FIND_REFERENCES", "|", "IIndex", ".", "SEARCH_ACROSS_LANGUAGE_BOUNDARIES", ")", ";", "ArrayList", "<", "Call", ">", "calls", "=", "new", "ArrayList", "<", "Call", ">", "(", "names", ".", "length", ")", ";", "for", "(", "IIndexName", "name", ":", "names", ")", "{", "if", "(", "includeOrdinaryCalls", "||", "name", ".", "couldBePolymorphicMethodCall", "(", ")", ")", "{", "IIndexName", "caller", "=", "name", ".", "getEnclosingDefinition", "(", ")", ";", "if", "(", "caller", "==", "null", ")", "{", "continue", ";", "}", "ICElement", "element", "=", "IndexUI", ".", "getCElementForName", "(", "project", ",", "index", ",", "caller", ")", ";", "if", "(", "element", "==", "null", ")", "{", "continue", ";", "}", "calls", ".", "add", "(", "new", "Call", "(", "name", ",", "element", ")", ")", ";", "}", "}", "Collections", ".", "sort", "(", "calls", ")", ";", "ArrayList", "<", "HashMap", "<", "String", ",", "Object", ">", ">", "results", "=", "new", "ArrayList", "<", "HashMap", "<", "String", ",", "Object", ">", ">", "(", ")", ";", "for", "(", "Call", "call", ":", "calls", ")", "{", "results", ".", "add", "(", "formatElement", "(", "index", ",", "call", ".", "element", ",", "call", ".", "name", ",", "seen", ")", ")", ";", "}", "return", "results", ";", "}", "private", "HashMap", "<", "String", ",", "Object", ">", "formatElement", "(", "IIndex", "index", ",", "ICElement", "element", ",", "IIndexName", "name", ",", "Set", "<", "ICElement", ">", "seen", ")", "throws", "Exception", "{", "HashMap", "<", "String", ",", "Object", ">", "result", "=", "new", "HashMap", "<", "String", ",", "Object", ">", "(", ")", ";", "String", "[", "]", "types", "=", "null", ";", "if", "(", "element", "instanceof", "IFunction", ")", "{", "types", "=", "(", "(", "IFunction", ")", "element", ")", ".", "getParameterTypes", "(", ")", ";", "}", "else", "if", "(", "element", "instanceof", "IFunctionDeclaration", ")", "{", "types", "=", "(", "(", "IFunctionDeclaration", ")", "element", ")", ".", "getParameterTypes", "(", ")", ";", "}", "String", "message", "=", "element", ".", "getElementName", "(", ")", "+", "'('", "+", "StringUtils", ".", "join", "(", "types", ",", "\",", "\"", ")", "+", "')'", ";", "result", ".", "put", "(", "\"name\"", ",", "message", ")", ";", "if", "(", "name", "!=", "null", ")", "{", "IResource", "resource", "=", "element", ".", "getResource", "(", ")", ";", "if", "(", "resource", "!=", "null", ")", "{", "String", "file", "=", "element", ".", "getResource", "(", ")", ".", "getLocation", "(", ")", ".", "toOSString", "(", ")", ".", "replace", "(", "'\\\\'", ",", "'/'", ")", ";", "result", ".", "put", "(", "\"position\"", ",", "Position", ".", "fromOffset", "(", "file", ",", "null", ",", "name", ".", "getNodeOffset", "(", ")", ",", "0", ")", ")", ";", "}", "}", "if", "(", "!", "seen", ".", "contains", "(", "element", ")", ")", "{", "seen", ".", "add", "(", "element", ")", ";", "result", ".", "put", "(", "\"calledBy\"", ",", "findCalledBy", "(", "index", ",", "element", ",", "seen", ")", ")", ";", "}", "return", "result", ";", "}", "private", "static", "class", "Call", "implements", "Comparable", "<", "Call", ">", "{", "private", "static", "final", "Collator", "COLLATOR", "=", "Collator", ".", "getInstance", "(", ")", ";", "public", "IIndexName", "name", ";", "public", "ICElement", "element", ";", "public", "String", "location", ";", "public", "Call", "(", "IIndexName", "name", ",", "ICElement", "element", ")", "{", "this", ".", "name", "=", "name", ";", "this", ".", "element", "=", "element", ";", "this", ".", "location", "=", "element", ".", "getResource", "(", ")", ".", "getLocation", "(", ")", ".", "toOSString", "(", ")", "+", "element", ".", "getElementName", "(", ")", ";", "}", "@", "Override", "public", "int", "compareTo", "(", "Call", "o", ")", "{", "int", "result", "=", "COLLATOR", ".", "compare", "(", "location", ",", "o", ".", "location", ")", ";", "if", "(", "result", "==", "0", ")", "{", "return", "name", ".", "getNodeOffset", "(", ")", "-", "o", ".", "name", ".", "getNodeOffset", "(", ")", ";", "}", "return", "result", ";", "}", "}", "}", "</s>" ]
1,468
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "cdt", ".", "command", ".", "complete", ";", "import", "java", ".", "lang", ".", "reflect", ".", "Method", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang", ".", "StringUtils", ";", "import", "org", ".", "eclim", ".", "annotation", ".", "Command", ";", "import", "org", ".", "eclim", ".", "command", ".", "CommandLine", ";", "import", "org", ".", "eclim", ".", "eclipse", ".", "EclimPlugin", ";", "import", "org", ".", "eclim", ".", "eclipse", ".", "ui", ".", "EclimEditorSite", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "command", ".", "complete", ".", "AbstractCodeCompleteCommand", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "util", ".", "ProjectUtils", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "internal", ".", "ui", ".", "editor", ".", "CEditor", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "internal", ".", "ui", ".", "editor", ".", "CSourceViewer", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "internal", ".", "ui", ".", "text", ".", "CTextTools", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "internal", ".", "ui", ".", "text", ".", "contentassist", ".", "CCompletionProposal", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "ui", ".", "CUIPlugin", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "ui", ".", "text", ".", "CSourceViewerConfiguration", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "IProject", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "preference", ".", "IPreferenceStore", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "text", ".", "ITextViewer", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "text", ".", "contentassist", ".", "ContentAssistant", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "text", ".", "contentassist", ".", "ICompletionProposal", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "SWT", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "IEditorInput", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "part", ".", "FileEditorInput", ";", "@", "Command", "(", "name", "=", "\"c_complete\"", ",", "options", "=", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", ")", "public", "class", "CodeCompleteCommand", "extends", "AbstractCodeCompleteCommand", "{", "@", "Override", "protected", "ICompletionProposal", "[", "]", "getCompletionProposals", "(", "CommandLine", "commandLine", ",", "String", "projectName", ",", "String", "file", ",", "int", "offset", ")", "throws", "Exception", "{", "IProject", "project", "=", "ProjectUtils", ".", "getProject", "(", "projectName", ")", ";", "CEditor", "editor", "=", "new", "CEditor", "(", ")", ";", "IEditorInput", "input", "=", "new", "FileEditorInput", "(", "ProjectUtils", ".", "getFile", "(", "project", ",", "file", ")", ")", ";", "editor", ".", "init", "(", "new", "EclimEditorSite", "(", ")", ",", "input", ")", ";", "editor", ".", "setInput", "(", "input", ")", ";", "CTextTools", "textTools", "=", "CUIPlugin", ".", "getDefault", "(", ")", ".", "getTextTools", "(", ")", ";", "IPreferenceStore", "store", "=", "CUIPlugin", ".", "getDefault", "(", ")", ".", "getCombinedPreferenceStore", "(", ")", ";", "CSourceViewerConfiguration", "config", "=", "new", "CSourceViewerConfiguration", "(", "textTools", ".", "getColorManager", "(", ")", ",", "store", ",", "editor", ",", "textTools", ".", "getDocumentPartitioning", "(", ")", ")", ";", "CSourceViewer", "viewer", "=", "new", "CSourceViewer", "(", "EclimPlugin", ".", "getShell", "(", ")", ",", "null", ",", "null", ",", "false", ",", "SWT", ".", "V_SCROLL", "|", "SWT", ".", "H_SCROLL", "|", "SWT", ".", "MULTI", "|", "SWT", ".", "FULL_SELECTION", ",", "CUIPlugin", ".", "getDefault", "(", ")", ".", "getPreferenceStore", "(", ")", ")", ";", "viewer", ".", "setDocument", "(", "ProjectUtils", ".", "getDocument", "(", "project", ",", "file", ")", ")", ";", "ContentAssistant", "ca", "=", "(", "ContentAssistant", ")", "config", ".", "getContentAssistant", "(", "viewer", ")", ";", "Method", "computeCompletionProposals", "=", "ContentAssistant", ".", "class", ".", "getDeclaredMethod", "(", "\"\"", ",", "ITextViewer", ".", "class", ",", "Integer", ".", "TYPE", ")", ";", "computeCompletionProposals", ".", "setAccessible", "(", "true", ")", ";", "return", "(", "ICompletionProposal", "[", "]", ")", "computeCompletionProposals", ".", "invoke", "(", "ca", ",", "viewer", ",", "offset", ")", ";", "}", "@", "Override", "protected", "String", "getCompletion", "(", "ICompletionProposal", "proposal", ")", "{", "if", "(", "proposal", "instanceof", "CCompletionProposal", ")", "{", "String", "displayString", "=", "proposal", ".", "getDisplayString", "(", ")", ";", "String", "completion", "=", "(", "(", "CCompletionProposal", ")", "proposal", ")", ".", "getReplacementString", "(", ")", ";", "if", "(", "displayString", ".", "lastIndexOf", "(", "')'", ")", ">", "displayString", ".", "lastIndexOf", "(", "'('", ")", "+", "1", "&&", "(", "completion", ".", "length", "(", ")", ">", "0", "&&", "completion", ".", "charAt", "(", "completion", ".", "length", "(", ")", "-", "1", ")", "==", "')'", ")", ")", "{", "completion", "=", "completion", ".", "substring", "(", "0", ",", "completion", ".", "length", "(", ")", "-", "1", ")", ";", "}", "else", "if", "(", "completion", ".", "charAt", "(", "0", ")", "==", "'<'", ")", "{", "completion", "=", "completion", ".", "substring", "(", "1", ",", "completion", ".", "length", "(", ")", ")", ";", "}", "return", "completion", ";", "}", "return", "super", ".", "getCompletion", "(", "proposal", ")", ";", "}", "@", "Override", "protected", "String", "getMenu", "(", "ICompletionProposal", "proposal", ")", "{", "String", "menu", "=", "proposal", ".", "getDisplayString", "(", ")", ";", "return", "menu", "!=", "null", "?", "menu", ":", "StringUtils", ".", "EMPTY", ";", "}", "@", "Override", "protected", "String", "getInfo", "(", "ICompletionProposal", "proposal", ")", "{", "String", "info", "=", "proposal", ".", "getAdditionalProposalInfo", "(", ")", ";", "if", "(", "info", "==", "null", ")", "{", "String", "display", "=", "proposal", ".", "getDisplayString", "(", ")", ";", "if", "(", "display", "!=", "null", "&&", "display", ".", "matches", "(", "\".*\\\\W.*\"", ")", ")", "{", "info", "=", "display", ";", "}", "}", "if", "(", "info", "==", "null", ")", "{", "info", "=", "StringUtils", ".", "EMPTY", ";", "}", "return", "info", ";", "}", "}", "</s>" ]
1,469
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "cdt", ".", "command", ".", "src", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Collections", ";", "import", "java", ".", "util", ".", "Comparator", ";", "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", ".", "cdt", ".", "util", ".", "CUtils", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "command", ".", "AbstractCommand", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "util", ".", "ProjectUtils", ";", "import", "org", ".", "eclim", ".", "util", ".", "CollectionUtils", ";", "import", "org", ".", "eclim", ".", "util", ".", "file", ".", "FileOffsets", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "codan", ".", "core", ".", "model", ".", "CheckerLaunchMode", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "codan", ".", "internal", ".", "core", ".", "CodanRunner", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "CCorePlugin", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "dom", ".", "ast", ".", "IASTTranslationUnit", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "index", ".", "IIndex", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "index", ".", "IIndexManager", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "model", ".", "CoreModel", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "model", ".", "ICElement", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "model", ".", "ICProject", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "model", ".", "ITranslationUnit", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "parser", ".", "IProblem", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "internal", ".", "core", ".", "dom", ".", "parser", ".", "cpp", ".", "semantics", ".", "CPPVisitor", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "IMarker", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "IProject", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "IResource", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "IncrementalProjectBuilder", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "NullProgressMonitor", ";", "@", "Command", "(", "name", "=", "\"c_src_update\"", ",", "options", "=", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", ")", "public", "class", "SrcUpdateCommand", "extends", "AbstractCommand", "{", "private", "static", "final", "int", "AST_STYLE", "=", "ITranslationUnit", ".", "AST_CONFIGURE_USING_SOURCE_CONTEXT", "|", "ITranslationUnit", ".", "AST_SKIP_INDEXED_HEADERS", ";", "@", "Override", "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", ")", ";", "ICProject", "cproject", "=", "CUtils", ".", "getCProject", "(", "project", ")", ";", "if", "(", "cproject", ".", "exists", "(", ")", ")", "{", "ITranslationUnit", "src", "=", "CUtils", ".", "getTranslationUnit", "(", "cproject", ",", "file", ")", ";", "CCorePlugin", ".", "getIndexManager", "(", ")", ".", "update", "(", "new", "ICElement", "[", "]", "{", "src", "}", ",", "IIndexManager", ".", "UPDATE_ALL", ")", ";", "if", "(", "commandLine", ".", "hasOption", "(", "Options", ".", "VALIDATE_OPTION", ")", ")", "{", "List", "<", "IProblem", ">", "problems", "=", "getProblems", "(", "src", ")", ";", "ArrayList", "<", "Error", ">", "errors", "=", "new", "ArrayList", "<", "Error", ">", "(", ")", ";", "String", "filename", "=", "src", ".", "getResource", "(", ")", ".", "getLocation", "(", ")", ".", "toOSString", "(", ")", ".", "replace", "(", "'\\\\'", ",", "'/'", ")", ";", "FileOffsets", "offsets", "=", "FileOffsets", ".", "compile", "(", "filename", ")", ";", "for", "(", "IProblem", "problem", ":", "problems", ")", "{", "int", "[", "]", "lineColumn", "=", "offsets", ".", "offsetToLineColumn", "(", "problem", ".", "getSourceStart", "(", ")", ")", ";", "errors", ".", "add", "(", "new", "Error", "(", "problem", ".", "getMessage", "(", ")", ",", "filename", ",", "lineColumn", "[", "0", "]", ",", "lineColumn", "[", "1", "]", ",", "problem", ".", "isWarning", "(", ")", ")", ")", ";", "}", "IMarker", "[", "]", "markers", "=", "getMarkers", "(", "src", ")", ";", "for", "(", "IMarker", "marker", ":", "markers", ")", "{", "int", "[", "]", "lineColumn", "=", "offsets", ".", "offsetToLineColumn", "(", "(", "(", "Integer", ")", "marker", ".", "getAttribute", "(", "IMarker", ".", "CHAR_START", ")", ")", ".", "intValue", "(", ")", ")", ";", "int", "severity", "=", "(", "(", "Integer", ")", "marker", ".", "getAttribute", "(", "IMarker", ".", "SEVERITY", ")", ")", ".", "intValue", "(", ")", ";", "errors", ".", "add", "(", "new", "Error", "(", "(", "String", ")", "marker", ".", "getAttribute", "(", "IMarker", ".", "MESSAGE", ")", ",", "filename", ",", "lineColumn", "[", "0", "]", ",", "lineColumn", "[", "1", "]", ",", "severity", "!=", "IMarker", ".", "SEVERITY_ERROR", ")", ")", ";", "}", "Collections", ".", "sort", "(", "errors", ",", "new", "Comparator", "<", "Error", ">", "(", ")", "{", "public", "int", "compare", "(", "Error", "e1", ",", "Error", "e2", ")", "{", "if", "(", "e1", ".", "getLine", "(", ")", "!=", "e2", ".", "getLine", "(", ")", ")", "{", "return", "e1", ".", "getLine", "(", ")", "-", "e2", ".", "getLine", "(", ")", ";", "}", "if", "(", "e1", ".", "getColumn", "(", ")", "!=", "e2", ".", "getColumn", "(", ")", ")", "{", "return", "e1", ".", "getColumn", "(", ")", "-", "e2", ".", "getColumn", "(", ")", ";", "}", "return", "0", ";", "}", "public", "boolean", "equals", "(", "Object", "obj", ")", "{", "return", "false", ";", "}", "}", ")", ";", "if", "(", "commandLine", ".", "hasOption", "(", "Options", ".", "BUILD_OPTION", ")", ")", "{", "project", ".", "build", "(", "IncrementalProjectBuilder", ".", "INCREMENTAL_BUILD", ",", "new", "NullProgressMonitor", "(", ")", ")", ";", "}", "return", "errors", ";", "}", "}", "return", "null", ";", "}", "private", "List", "<", "IProblem", ">", "getProblems", "(", "ITranslationUnit", "src", ")", "throws", "Exception", "{", "IIndex", "index", "=", "null", ";", "try", "{", "ICProject", "[", "]", "projects", "=", "CoreModel", ".", "getDefault", "(", ")", ".", "getCModel", "(", ")", ".", "getCProjects", "(", ")", ";", "index", "=", "CCorePlugin", ".", "getIndexManager", "(", ")", ".", "getIndex", "(", "projects", ")", ";", "index", ".", "acquireReadLock", "(", ")", ";", "IASTTranslationUnit", "ast", "=", "src", ".", "getAST", "(", "index", ",", "AST_STYLE", ")", ";", "ArrayList", "<", "IProblem", ">", "problems", "=", "new", "ArrayList", "<", "IProblem", ">", "(", ")", ";", "CollectionUtils", ".", "addAll", "(", "problems", ",", "ast", ".", "getPreprocessorProblems", "(", ")", ")", ";", "CollectionUtils", ".", "addAll", "(", "problems", ",", "CPPVisitor", ".", "getProblems", "(", "ast", ")", ")", ";", "return", "problems", ";", "}", "finally", "{", "if", "(", "index", "!=", "null", ")", "{", "index", ".", "releaseReadLock", "(", ")", ";", "}", "}", "}", "private", "IMarker", "[", "]", "getMarkers", "(", "ITranslationUnit", "src", ")", "throws", "Exception", "{", "IResource", "resource", "=", "src", ".", "getResource", "(", ")", ";", "CodanRunner", ".", "processResource", "(", "resource", ",", "CheckerLaunchMode", ".", "RUN_ON_DEMAND", ",", "new", "NullProgressMonitor", "(", ")", ")", ";", "return", "resource", ".", "findMarkers", "(", "null", ",", "true", ",", "IResource", ".", "DEPTH_ZERO", ")", ";", "}", "}", "</s>" ]
1,470
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "cdt", ".", "command", ".", "project", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "HashMap", ";", "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", ".", "eclipse", ".", "cdt", ".", "core", ".", "CCProjectNature", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "CCorePlugin", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "CProjectNature", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "settings", ".", "model", ".", "ICConfigurationDescription", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "settings", ".", "model", ".", "ICProjectDescription", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "settings", ".", "model", ".", "ICSourceEntry", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "managedbuilder", ".", "core", ".", "IConfiguration", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "managedbuilder", ".", "core", ".", "IOption", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "managedbuilder", ".", "core", ".", "ITool", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "managedbuilder", ".", "core", ".", "ManagedBuildManager", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "IProject", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "IPath", ";", "@", "Command", "(", "name", "=", "\"\"", ",", "options", "=", "\"\"", ")", "public", "class", "ConfigurationsCommand", "extends", "AbstractCommand", "{", "public", "Object", "execute", "(", "CommandLine", "commandLine", ")", "throws", "Exception", "{", "String", "projectName", "=", "commandLine", ".", "getValue", "(", "Options", ".", "PROJECT_OPTION", ")", ";", "IProject", "project", "=", "ProjectUtils", ".", "getProject", "(", "projectName", ")", ";", "ICProjectDescription", "desc", "=", "CCorePlugin", ".", "getDefault", "(", ")", ".", "getProjectDescription", "(", "project", ",", "false", ")", ";", "ICConfigurationDescription", "[", "]", "cconfigs", "=", "desc", ".", "getConfigurations", "(", ")", ";", "ArrayList", "<", "HashMap", "<", "String", ",", "Object", ">", ">", "configs", "=", "new", "ArrayList", "<", "HashMap", "<", "String", ",", "Object", ">", ">", "(", ")", ";", "for", "(", "ICConfigurationDescription", "cconfig", ":", "cconfigs", ")", "{", "HashMap", "<", "String", ",", "Object", ">", "cfg", "=", "new", "HashMap", "<", "String", ",", "Object", ">", "(", ")", ";", "configs", ".", "add", "(", "cfg", ")", ";", "cfg", ".", "put", "(", "\"name\"", ",", "cconfig", ".", "getName", "(", ")", ")", ";", "ICSourceEntry", "[", "]", "sources", "=", "cconfig", ".", "getSourceEntries", "(", ")", ";", "if", "(", "sources", ".", "length", ">", "0", ")", "{", "ArrayList", "<", "HashMap", "<", "String", ",", "Object", ">", ">", "srcs", "=", "new", "ArrayList", "<", "HashMap", "<", "String", ",", "Object", ">", ">", "(", ")", ";", "cfg", ".", "put", "(", "\"sources\"", ",", "srcs", ")", ";", "for", "(", "ICSourceEntry", "entry", ":", "sources", ")", "{", "HashMap", "<", "String", ",", "Object", ">", "src", "=", "new", "HashMap", "<", "String", ",", "Object", ">", "(", ")", ";", "srcs", ".", "add", "(", "src", ")", ";", "String", "dirname", "=", "entry", ".", "getFullPath", "(", ")", ".", "removeFirstSegments", "(", "1", ")", ".", "toString", "(", ")", ";", "if", "(", "dirname", ".", "length", "(", ")", "==", "0", ")", "{", "dirname", "=", "\"/\"", ";", "}", "src", ".", "put", "(", "\"dir\"", ",", "dirname", ")", ";", "IPath", "[", "]", "excludes", "=", "entry", ".", "getExclusionPatterns", "(", ")", ";", "if", "(", "excludes", ".", "length", ">", "0", ")", "{", "ArrayList", "<", "String", ">", "ex", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "src", ".", "put", "(", "\"excludes\"", ",", "ex", ")", ";", "for", "(", "int", "ii", "=", "0", ";", "ii", "<", "excludes", ".", "length", ";", "ii", "++", ")", "{", "ex", ".", "add", "(", "excludes", "[", "ii", "]", ".", "toString", "(", ")", ")", ";", "}", "}", "}", "}", "IConfiguration", "config", "=", "ManagedBuildManager", ".", "getConfigurationForDescription", "(", "cconfig", ")", ";", "ITool", "[", "]", "tools", "=", "config", ".", "getTools", "(", ")", ";", "if", "(", "tools", ".", "length", ">", "0", ")", "{", "ArrayList", "<", "HashMap", "<", "String", ",", "Object", ">", ">", "tls", "=", "new", "ArrayList", "<", "HashMap", "<", "String", ",", "Object", ">", ">", "(", ")", ";", "cfg", ".", "put", "(", "\"tools\"", ",", "tls", ")", ";", "for", "(", "ITool", "tool", ":", "tools", ")", "{", "if", "(", "!", "tool", ".", "isEnabled", "(", ")", "||", "!", "acceptTool", "(", "project", ",", "tool", ")", ")", "{", "continue", ";", "}", "IOption", "ioption", "=", "getOptionByType", "(", "tool", ",", "IOption", ".", "INCLUDE_PATH", ")", ";", "IOption", "soption", "=", "getOptionByType", "(", "tool", ",", "IOption", ".", "PREPROCESSOR_SYMBOLS", ")", ";", "if", "(", "ioption", "==", "null", "&&", "soption", "==", "null", ")", "{", "continue", ";", "}", "HashMap", "<", "String", ",", "Object", ">", "tl", "=", "new", "HashMap", "<", "String", ",", "Object", ">", "(", ")", ";", "tls", ".", "add", "(", "tl", ")", ";", "tl", ".", "put", "(", "\"name\"", ",", "tool", ".", "getName", "(", ")", ")", ";", "if", "(", "ioption", "!=", "null", ")", "{", "String", "[", "]", "includes", "=", "ioption", ".", "getIncludePaths", "(", ")", ";", "if", "(", "includes", ".", "length", ">", "0", ")", "{", "ArrayList", "<", "String", ">", "ins", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "tl", ".", "put", "(", "\"includes\"", ",", "ins", ")", ";", "for", "(", "String", "include", ":", "includes", ")", "{", "ins", ".", "add", "(", "include", ")", ";", "}", "}", "}", "if", "(", "soption", "!=", "null", ")", "{", "String", "[", "]", "symbols", "=", "soption", ".", "getDefinedSymbols", "(", ")", ";", "if", "(", "symbols", ".", "length", ">", "0", ")", "{", "ArrayList", "<", "String", ">", "syms", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "tl", ".", "put", "(", "\"symbols\"", ",", "syms", ")", ";", "for", "(", "String", "symbol", ":", "symbols", ")", "{", "syms", ".", "add", "(", "symbol", ")", ";", "}", "}", "}", "}", "}", "}", "return", "configs", ";", "}", "private", "boolean", "acceptTool", "(", "IProject", "project", ",", "ITool", "tool", ")", "throws", "Exception", "{", "switch", "(", "tool", ".", "getNatureFilter", "(", ")", ")", "{", "case", "ITool", ".", "FILTER_C", ":", "if", "(", "project", ".", "hasNature", "(", "CProjectNature", ".", "C_NATURE_ID", ")", "&&", "!", "project", ".", "hasNature", "(", "CCProjectNature", ".", "CC_NATURE_ID", ")", ")", "{", "return", "true", ";", "}", "break", ";", "case", "ITool", ".", "FILTER_CC", ":", "if", "(", "project", ".", "hasNature", "(", "CCProjectNature", ".", "CC_NATURE_ID", ")", ")", "{", "return", "true", ";", "}", "break", ";", "case", "ITool", ".", "FILTER_BOTH", ":", "return", "true", ";", "}", "return", "false", ";", "}", "private", "IOption", "getOptionByType", "(", "ITool", "tool", ",", "int", "type", ")", "throws", "Exception", "{", "IOption", "[", "]", "options", "=", "tool", ".", "getOptions", "(", ")", ";", "for", "(", "IOption", "option", ":", "options", ")", "{", "if", "(", "option", ".", "getValueType", "(", ")", "==", "type", ")", "{", "return", "option", ";", "}", "}", "return", "null", ";", "}", "}", "</s>" ]
1,471
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "cdt", ".", "command", ".", "project", ";", "import", "org", ".", "eclim", ".", "annotation", ".", "Command", ";", "import", "org", ".", "eclim", ".", "command", ".", "CommandLine", ";", "import", "org", ".", "eclim", ".", "command", ".", "Options", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "settings", ".", "model", ".", "CMacroEntry", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "settings", ".", "model", ".", "ICLanguageSettingEntry", ";", "@", "Command", "(", "name", "=", "\"\"", ",", "options", "=", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", ")", "public", "class", "SymbolEntryCommand", "extends", "AbstractSettingEntryCommand", "{", "@", "Override", "protected", "ICLanguageSettingEntry", "createEntry", "(", "CommandLine", "commandLine", ")", "throws", "Exception", "{", "String", "name", "=", "commandLine", ".", "getValue", "(", "Options", ".", "NAME_OPTION", ")", ";", "String", "value", "=", "commandLine", ".", "getValue", "(", "Options", ".", "VALUE_OPTION", ")", ";", "return", "new", "CMacroEntry", "(", "name", ",", "value", ",", "0", ")", ";", "}", "}", "</s>" ]
1,472
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "cdt", ".", "command", ".", "project", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "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", ".", "eclipse", ".", "cdt", ".", "core", ".", "model", ".", "CoreModel", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "model", ".", "ICProject", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "model", ".", "IIncludeReference", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "IProject", ";", "@", "Command", "(", "name", "=", "\"\"", ",", "options", "=", "\"\"", ")", "public", "class", "IncludePathsCommand", "extends", "AbstractCommand", "{", "public", "Object", "execute", "(", "CommandLine", "commandLine", ")", "throws", "Exception", "{", "String", "projectName", "=", "commandLine", ".", "getValue", "(", "Options", ".", "PROJECT_OPTION", ")", ";", "IProject", "project", "=", "ProjectUtils", ".", "getProject", "(", "projectName", ")", ";", "ICProject", "cproject", "=", "CoreModel", ".", "getDefault", "(", ")", ".", "create", "(", "project", ")", ";", "ArrayList", "<", "String", ">", "results", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "for", "(", "IIncludeReference", "ref", ":", "cproject", ".", "getIncludeReferences", "(", ")", ")", "{", "results", ".", "add", "(", "ref", ".", "getPath", "(", ")", ".", "toOSString", "(", ")", ")", ";", "}", "return", "results", ";", "}", "}", "</s>" ]
1,473
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "cdt", ".", "command", ".", "project", ";", "import", "org", ".", "eclim", ".", "annotation", ".", "Command", ";", "import", "org", ".", "eclim", ".", "command", ".", "CommandLine", ";", "import", "org", ".", "eclim", ".", "command", ".", "Options", ";", "import", "org", ".", "eclim", ".", "util", ".", "file", ".", "FileUtils", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "settings", ".", "model", ".", "CIncludePathEntry", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "settings", ".", "model", ".", "ICLanguageSettingEntry", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "settings", ".", "model", ".", "ICSettingEntry", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "Path", ";", "@", "Command", "(", "name", "=", "\"\"", ",", "options", "=", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", ")", "public", "class", "IncludeEntryCommand", "extends", "AbstractSettingEntryCommand", "{", "@", "Override", "protected", "ICLanguageSettingEntry", "createEntry", "(", "CommandLine", "commandLine", ")", "throws", "Exception", "{", "String", "dir", "=", "commandLine", ".", "getValue", "(", "Options", ".", "DIR_OPTION", ")", ";", "dir", "=", "FileUtils", ".", "removeTrailingSlash", "(", "dir", ")", ";", "Path", "path", "=", "new", "Path", "(", "dir", ")", ";", "if", "(", "path", ".", "isAbsolute", "(", ")", ")", "{", "return", "new", "CIncludePathEntry", "(", "path", ",", "ICSettingEntry", ".", "LOCAL", ")", ";", "}", "return", "new", "CIncludePathEntry", "(", "path", ",", "ICSettingEntry", ".", "VALUE_WORKSPACE_PATH", ")", ";", "}", "}", "</s>" ]
1,474
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "cdt", ".", "command", ".", "project", ";", "import", "java", ".", "util", ".", "Iterator", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "eclim", ".", "Services", ";", "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", ".", "util", ".", "StringUtils", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "CCorePlugin", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "settings", ".", "model", ".", "ICConfigurationDescription", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "settings", ".", "model", ".", "ICFolderDescription", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "settings", ".", "model", ".", "ICLanguageSetting", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "settings", ".", "model", ".", "ICLanguageSettingEntry", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "settings", ".", "model", ".", "ICProjectDescription", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "IProject", ";", "public", "abstract", "class", "AbstractSettingEntryCommand", "extends", "AbstractCommand", "{", "private", "static", "final", "String", "ADD", "=", "\"add\"", ";", "private", "static", "final", "String", "DELETE", "=", "\"delete\"", ";", "public", "Object", "execute", "(", "CommandLine", "commandLine", ")", "throws", "Exception", "{", "String", "action", "=", "commandLine", ".", "getValue", "(", "Options", ".", "ACTION_OPTION", ")", ";", "if", "(", "ADD", ".", "equals", "(", "action", ")", ")", "{", "return", "add", "(", "commandLine", ")", ";", "}", "if", "(", "DELETE", ".", "equals", "(", "action", ")", ")", "{", "return", "delete", "(", "commandLine", ")", ";", "}", "throw", "new", "RuntimeException", "(", "Services", ".", "getMessage", "(", "\"\"", ",", "action", ")", ")", ";", "}", "protected", "String", "add", "(", "CommandLine", "commandLine", ")", "throws", "Exception", "{", "String", "projectName", "=", "commandLine", ".", "getValue", "(", "Options", ".", "PROJECT_OPTION", ")", ";", "String", "lang", "=", "commandLine", ".", "getValue", "(", "Options", ".", "LANG_OPTION", ")", ";", "IProject", "project", "=", "ProjectUtils", ".", "getProject", "(", "projectName", ")", ";", "ICProjectDescription", "desc", "=", "CCorePlugin", ".", "getDefault", "(", ")", ".", "getProjectDescription", "(", "project", ",", "true", ")", ";", "ICConfigurationDescription", "[", "]", "configs", "=", "desc", ".", "getConfigurations", "(", ")", ";", "ICLanguageSettingEntry", "entry", "=", "createEntry", "(", "commandLine", ")", ";", "for", "(", "ICConfigurationDescription", "config", ":", "configs", ")", "{", "ICFolderDescription", "fdesc", "=", "config", ".", "getRootFolderDescription", "(", ")", ";", "ICLanguageSetting", "[", "]", "ls", "=", "fdesc", ".", "getLanguageSettings", "(", ")", ";", "for", "(", "ICLanguageSetting", "l", ":", "ls", ")", "{", "String", "name", "=", "StringUtils", ".", "split", "(", "l", ".", "getName", "(", ")", ")", "[", "0", "]", ".", "toLowerCase", "(", ")", ";", "if", "(", "name", ".", "equals", "(", "lang", ")", ")", "{", "List", "<", "ICLanguageSettingEntry", ">", "lst", "=", "l", ".", "getSettingEntriesList", "(", "entry", ".", "getKind", "(", ")", ")", ";", "lst", ".", "add", "(", "entry", ")", ";", "l", ".", "setSettingEntries", "(", "entry", ".", "getKind", "(", ")", ",", "lst", ")", ";", "}", "}", "}", "CCorePlugin", ".", "getDefault", "(", ")", ".", "setProjectDescription", "(", "project", ",", "desc", ")", ";", "return", "Services", ".", "getMessage", "(", "\"entry.added\"", ")", ";", "}", "protected", "String", "delete", "(", "CommandLine", "commandLine", ")", "throws", "Exception", "{", "String", "projectName", "=", "commandLine", ".", "getValue", "(", "Options", ".", "PROJECT_OPTION", ")", ";", "String", "lang", "=", "commandLine", ".", "getValue", "(", "Options", ".", "LANG_OPTION", ")", ";", "IProject", "project", "=", "ProjectUtils", ".", "getProject", "(", "projectName", ")", ";", "ICProjectDescription", "desc", "=", "CCorePlugin", ".", "getDefault", "(", ")", ".", "getProjectDescription", "(", "project", ",", "true", ")", ";", "ICConfigurationDescription", "[", "]", "configs", "=", "desc", ".", "getConfigurations", "(", ")", ";", "ICLanguageSettingEntry", "entry", "=", "createEntry", "(", "commandLine", ")", ";", "boolean", "deleted", "=", "false", ";", "for", "(", "ICConfigurationDescription", "config", ":", "configs", ")", "{", "ICFolderDescription", "fdesc", "=", "config", ".", "getRootFolderDescription", "(", ")", ";", "ICLanguageSetting", "[", "]", "ls", "=", "fdesc", ".", "getLanguageSettings", "(", ")", ";", "for", "(", "ICLanguageSetting", "l", ":", "ls", ")", "{", "String", "name", "=", "StringUtils", ".", "split", "(", "l", ".", "getName", "(", ")", ")", "[", "0", "]", ".", "toLowerCase", "(", ")", ";", "if", "(", "name", ".", "equals", "(", "lang", ")", ")", "{", "List", "<", "ICLanguageSettingEntry", ">", "lst", "=", "l", ".", "getSettingEntriesList", "(", "entry", ".", "getKind", "(", ")", ")", ";", "Iterator", "<", "ICLanguageSettingEntry", ">", "iterator", "=", "lst", ".", "iterator", "(", ")", ";", "while", "(", "iterator", ".", "hasNext", "(", ")", ")", "{", "if", "(", "iterator", ".", "next", "(", ")", ".", "getName", "(", ")", ".", "equals", "(", "entry", ".", "getName", "(", ")", ")", ")", "{", "iterator", ".", "remove", "(", ")", ";", "}", "}", "l", ".", "setSettingEntries", "(", "entry", ".", "getKind", "(", ")", ",", "lst", ")", ";", "deleted", "=", "true", ";", "}", "}", "}", "if", "(", "deleted", ")", "{", "CCorePlugin", ".", "getDefault", "(", ")", ".", "setProjectDescription", "(", "project", ",", "desc", ")", ";", "return", "Services", ".", "getMessage", "(", "\"\"", ")", ";", "}", "return", "Services", ".", "getMessage", "(", "\"\"", ",", "entry", ".", "getName", "(", ")", ")", ";", "}", "protected", "abstract", "ICLanguageSettingEntry", "createEntry", "(", "CommandLine", "commandLine", ")", "throws", "Exception", ";", "}", "</s>" ]
1,475
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "cdt", ".", "command", ".", "project", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "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", ".", "eclipse", ".", "cdt", ".", "core", ".", "model", ".", "CoreModel", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "model", ".", "ICProject", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "model", ".", "ISourceRoot", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "IProject", ";", "@", "Command", "(", "name", "=", "\"\"", ",", "options", "=", "\"\"", ")", "public", "class", "SourcePathsCommand", "extends", "AbstractCommand", "{", "public", "Object", "execute", "(", "CommandLine", "commandLine", ")", "throws", "Exception", "{", "String", "projectName", "=", "commandLine", ".", "getValue", "(", "Options", ".", "PROJECT_OPTION", ")", ";", "IProject", "project", "=", "ProjectUtils", ".", "getProject", "(", "projectName", ")", ";", "ICProject", "cproject", "=", "CoreModel", ".", "getDefault", "(", ")", ".", "create", "(", "project", ")", ";", "ArrayList", "<", "String", ">", "results", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "for", "(", "ISourceRoot", "root", ":", "cproject", ".", "getSourceRoots", "(", ")", ")", "{", "results", ".", "add", "(", "ProjectUtils", ".", "getFilePath", "(", "project", ",", "root", ".", "getPath", "(", ")", ".", "toOSString", "(", ")", ")", ")", ";", "}", "return", "results", ";", "}", "}", "</s>" ]
1,476
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "cdt", ".", "command", ".", "project", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "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", ".", "util", ".", "StringUtils", ";", "import", "org", ".", "eclim", ".", "util", ".", "file", ".", "FileUtils", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "CCorePlugin", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "settings", ".", "model", ".", "CSourceEntry", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "settings", ".", "model", ".", "ICConfigurationDescription", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "settings", ".", "model", ".", "ICProjectDescription", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "settings", ".", "model", ".", "ICSourceEntry", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "IProject", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "IPath", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "Path", ";", "@", "Command", "(", "name", "=", "\"\"", ",", "options", "=", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", ")", "public", "class", "SourceEntryCommand", "extends", "AbstractCommand", "{", "private", "static", "final", "String", "ADD", "=", "\"add\"", ";", "private", "static", "final", "String", "DELETE", "=", "\"delete\"", ";", "public", "Object", "execute", "(", "CommandLine", "commandLine", ")", "throws", "Exception", "{", "String", "action", "=", "commandLine", ".", "getValue", "(", "Options", ".", "ACTION_OPTION", ")", ";", "if", "(", "ADD", ".", "equals", "(", "action", ")", ")", "{", "return", "add", "(", "commandLine", ")", ";", "}", "if", "(", "DELETE", ".", "equals", "(", "action", ")", ")", "{", "return", "delete", "(", "commandLine", ")", ";", "}", "throw", "new", "RuntimeException", "(", "Services", ".", "getMessage", "(", "\"\"", ",", "action", ")", ")", ";", "}", "private", "String", "add", "(", "CommandLine", "commandLine", ")", "throws", "Exception", "{", "String", "projectName", "=", "commandLine", ".", "getValue", "(", "Options", ".", "PROJECT_OPTION", ")", ";", "String", "dir", "=", "commandLine", ".", "getValue", "(", "Options", ".", "DIR_OPTION", ")", ";", "String", "excludes", "=", "commandLine", ".", "getValue", "(", "Options", ".", "EXCLUDES_OPTION", ")", ";", "dir", "=", "FileUtils", ".", "removeTrailingSlash", "(", "dir", ")", ";", "IProject", "project", "=", "ProjectUtils", ".", "getProject", "(", "projectName", ")", ";", "ICProjectDescription", "desc", "=", "CCorePlugin", ".", "getDefault", "(", ")", ".", "getProjectDescription", "(", "project", ",", "true", ")", ";", "ICConfigurationDescription", "[", "]", "configs", "=", "desc", ".", "getConfigurations", "(", ")", ";", "ArrayList", "<", "IPath", ">", "excludePaths", "=", "new", "ArrayList", "<", "IPath", ">", "(", ")", ";", "if", "(", "excludes", "!=", "null", ")", "{", "for", "(", "String", "exclude", ":", "StringUtils", ".", "split", "(", "excludes", ",", "','", ")", ")", "{", "excludePaths", ".", "add", "(", "new", "Path", "(", "exclude", ")", ")", ";", "}", "}", "ICSourceEntry", "source", "=", "new", "CSourceEntry", "(", "new", "Path", "(", "dir", ")", ",", "excludePaths", ".", "toArray", "(", "new", "IPath", "[", "excludePaths", ".", "size", "(", ")", "]", ")", ",", "CSourceEntry", ".", "VALUE_WORKSPACE_PATH", ")", ";", "for", "(", "ICConfigurationDescription", "config", ":", "configs", ")", "{", "ICSourceEntry", "[", "]", "sources", "=", "config", ".", "getSourceEntries", "(", ")", ";", "ArrayList", "<", "ICSourceEntry", ">", "keep", "=", "new", "ArrayList", "<", "ICSourceEntry", ">", "(", ")", ";", "for", "(", "ICSourceEntry", "entry", ":", "sources", ")", "{", "String", "name", "=", "entry", ".", "getFullPath", "(", ")", ".", "removeFirstSegments", "(", "1", ")", ".", "toString", "(", ")", ";", "if", "(", "!", "name", ".", "equals", "(", "dir", ")", ")", "{", "keep", ".", "add", "(", "entry", ")", ";", "}", "}", "keep", ".", "add", "(", "source", ")", ";", "config", ".", "setSourceEntries", "(", "keep", ".", "toArray", "(", "new", "ICSourceEntry", "[", "keep", ".", "size", "(", ")", "]", ")", ")", ";", "}", "CCorePlugin", ".", "getDefault", "(", ")", ".", "setProjectDescription", "(", "project", ",", "desc", ")", ";", "return", "Services", ".", "getMessage", "(", "\"entry.added\"", ")", ";", "}", "private", "String", "delete", "(", "CommandLine", "commandLine", ")", "throws", "Exception", "{", "String", "projectName", "=", "commandLine", ".", "getValue", "(", "Options", ".", "PROJECT_OPTION", ")", ";", "String", "dir", "=", "commandLine", ".", "getValue", "(", "Options", ".", "DIR_OPTION", ")", ";", "dir", "=", "FileUtils", ".", "removeTrailingSlash", "(", "dir", ")", ";", "IProject", "project", "=", "ProjectUtils", ".", "getProject", "(", "projectName", ")", ";", "ICProjectDescription", "desc", "=", "CCorePlugin", ".", "getDefault", "(", ")", ".", "getProjectDescription", "(", "project", ",", "true", ")", ";", "ICConfigurationDescription", "[", "]", "configs", "=", "desc", ".", "getConfigurations", "(", ")", ";", "boolean", "deleted", "=", "false", ";", "for", "(", "ICConfigurationDescription", "config", ":", "configs", ")", "{", "ICSourceEntry", "[", "]", "sources", "=", "config", ".", "getSourceEntries", "(", ")", ";", "ArrayList", "<", "ICSourceEntry", ">", "keep", "=", "new", "ArrayList", "<", "ICSourceEntry", ">", "(", ")", ";", "for", "(", "ICSourceEntry", "entry", ":", "sources", ")", "{", "String", "name", "=", "entry", ".", "getFullPath", "(", ")", ".", "removeFirstSegments", "(", "1", ")", ".", "toString", "(", ")", ";", "if", "(", "!", "name", ".", "equals", "(", "dir", ")", ")", "{", "keep", ".", "add", "(", "entry", ")", ";", "}", "}", "if", "(", "sources", ".", "length", "!=", "keep", ".", "size", "(", ")", ")", "{", "deleted", "=", "true", ";", "config", ".", "setSourceEntries", "(", "keep", ".", "toArray", "(", "new", "ICSourceEntry", "[", "keep", ".", "size", "(", ")", "]", ")", ")", ";", "}", "}", "if", "(", "deleted", ")", "{", "CCorePlugin", ".", "getDefault", "(", ")", ".", "setProjectDescription", "(", "project", ",", "desc", ")", ";", "return", "Services", ".", "getMessage", "(", "\"\"", ")", ";", "}", "return", "Services", ".", "getMessage", "(", "\"\"", ",", "dir", ")", ";", "}", "}", "</s>" ]
1,477
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "cdt", ".", "command", ".", "search", ";", "import", "java", ".", "lang", ".", "reflect", ".", "Method", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "LinkedHashSet", ";", "import", "org", ".", "apache", ".", "tools", ".", "ant", ".", "taskdefs", ".", "condition", ".", "Os", ";", "import", "org", ".", "eclim", ".", "annotation", ".", "Command", ";", "import", "org", ".", "eclim", ".", "command", ".", "CommandLine", ";", "import", "org", ".", "eclim", ".", "command", ".", "Options", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "cdt", ".", "PluginResources", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "cdt", ".", "util", ".", "CUtils", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "command", ".", "AbstractCommand", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "util", ".", "ProjectUtils", ";", "import", "org", ".", "eclim", ".", "util", ".", "CollectionUtils", ";", "import", "org", ".", "eclim", ".", "util", ".", "file", ".", "Position", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "CCProjectNature", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "CCorePlugin", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "CProjectNature", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "dom", ".", "IName", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "dom", ".", "ast", ".", "IASTFileLocation", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "dom", ".", "ast", ".", "IASTName", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "dom", ".", "ast", ".", "IASTNodeSelector", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "dom", ".", "ast", ".", "IASTTranslationUnit", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "dom", ".", "ast", ".", "IBinding", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "index", ".", "IIndex", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "index", ".", "IIndexFileLocation", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "index", ".", "IIndexManager", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "model", ".", "CoreModel", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "model", ".", "ICProject", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "core", ".", "model", ".", "ITranslationUnit", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "internal", ".", "ui", ".", "search", ".", "CSearchMessages", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "internal", ".", "ui", ".", "search", ".", "CSearchElement", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "internal", ".", "ui", ".", "search", ".", "CSearchMatch", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "internal", ".", "ui", ".", "search", ".", "CSearchPatternQuery", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "internal", ".", "ui", ".", "search", ".", "CSearchQuery", ";", "import", "org", ".", "eclipse", ".", "cdt", ".", "internal", ".", "ui", ".", "search", ".", "CSearchResult", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "IProject", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "ResourcesPlugin", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "NullProgressMonitor", ";", "import", "org", ".", "eclipse", ".", "search", ".", "ui", ".", "text", ".", "Match", ";", "@", "Command", "(", "name", "=", "\"c_search\"", ",", "options", "=", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", ")", "public", "class", "SearchCommand", "extends", "AbstractCommand", "{", "public", "static", "final", "String", "CONTEXT_ALL", "=", "\"all\"", ";", "public", "static", "final", "String", "CONTEXT_CONTEXT", "=", "\"context\"", ";", "public", "static", "final", "String", "CONTEXT_DECLARATIONS", "=", "\"declarations\"", ";", "public", "static", "final", "String", "CONTEXT_DEFINITIONS", "=", "\"definitions\"", ";", "public", "static", "final", "String", "CONTEXT_REFERENCES", "=", "\"references\"", ";", "private", "static", "final", "int", "FIND_CONTEXT", "=", "-", "1", ";", "public", "static", "final", "String", "SCOPE_ALL", "=", "\"all\"", ";", "public", "static", "final", "String", "SCOPE_PROJECT", "=", "\"project\"", ";", "public", "static", "final", "String", "TYPE_ALL", "=", "\"all\"", ";", "public", "static", "final", "String", "TYPE_CLASS_STRUCT", "=", "\"class_struct\"", ";", "public", "static", "final", "String", "TYPE_FUNCTION", "=", "\"function\"", ";", "public", "static", "final", "String", "TYPE_VARIABLE", "=", "\"variable\"", ";", "public", "static", "final", "String", "TYPE_UNION", "=", "\"union\"", ";", "public", "static", "final", "String", "TYPE_METHOD", "=", "\"method\"", ";", "public", "static", "final", "String", "TYPE_FIELD", "=", "\"field\"", ";", "public", "static", "final", "String", "TYPE_ENUM", "=", "\"enum\"", ";", "public", "static", "final", "String", "TYPE_ENUMERATOR", "=", "\"enumerator\"", ";", "public", "static", "final", "String", "TYPE_NAMESPACE", "=", "\"namespace\"", ";", "public", "static", "final", "String", "TYPE_TYPEDEF", "=", "\"typedef\"", ";", "public", "static", "final", "String", "TYPE_MACRO", "=", "\"macro\"", ";", "public", "Object", "execute", "(", "CommandLine", "commandLine", ")", "throws", "Exception", "{", "String", "projectName", "=", "commandLine", ".", "getValue", "(", "Options", ".", "NAME_OPTION", ")", ";", "String", "file", "=", "commandLine", ".", "getValue", "(", "Options", ".", "FILE_OPTION", ")", ";", "String", "offset", "=", "commandLine", ".", "getValue", "(", "Options", ".", "OFFSET_OPTION", ")", ";", "String", "length", "=", "commandLine", ".", "getValue", "(", "Options", ".", "LENGTH_OPTION", ")", ";", "IProject", "project", "=", "projectName", "!=", "null", "?", "ProjectUtils", ".", "getProject", "(", "projectName", ")", ":", "null", ";", "ICProject", "cproject", "=", "null", ";", "if", "(", "project", "!=", "null", ")", "{", "cproject", "=", "CUtils", ".", "getCProject", "(", "project", ")", ";", "}", "if", "(", "file", "!=", "null", "&&", "offset", "!=", "null", "&&", "length", "!=", "null", ")", "{", "return", "executeElementSearch", "(", "commandLine", ",", "cproject", ")", ";", "}", "return", "executePatternSearch", "(", "commandLine", ",", "cproject", ")", ";", "}", "private", "Object", "executeElementSearch", "(", "CommandLine", "commandLine", ",", "ICProject", "cproject", ")", "throws", "Exception", "{", "ArrayList", "<", "Position", ">", "results", "=", "new", "ArrayList", "<", "Position", ">", "(", ")", ";", "String", "file", "=", "commandLine", ".", "getValue", "(", "Options", ".", "FILE_OPTION", ")", ";", "ITranslationUnit", "src", "=", "CUtils", ".", "getTranslationUnit", "(", "cproject", ",", "file", ")", ";", "if", "(", "src", "!=", "null", ")", "{", "int", "context", "=", "getContext", "(", "commandLine", ".", "getValue", "(", "Options", ".", "CONTEXT_OPTION", ")", ",", "FIND_CONTEXT", ")", ";", "ICProject", "[", "]", "scope", "=", "new", "ICProject", "[", "]", "{", "cproject", "}", ";", "if", "(", "SCOPE_ALL", ".", "equals", "(", "commandLine", ".", "getValue", "(", "Options", ".", "SCOPE_OPTION", ")", ")", ")", "{", "IProject", "[", "]", "projects", "=", "ResourcesPlugin", ".", "getWorkspace", "(", ")", ".", "getRoot", "(", ")", ".", "getProjects", "(", ")", ";", "ArrayList", "<", "ICProject", ">", "cprojects", "=", "new", "ArrayList", "<", "ICProject", ">", "(", ")", ";", "for", "(", "IProject", "project", ":", "projects", ")", "{", "if", "(", "project", ".", "isOpen", "(", ")", "&&", "(", "project", ".", "hasNature", "(", "PluginResources", ".", "NATURE_C", ")", "||", "project", ".", "hasNature", "(", "PluginResources", ".", "NATURE_CPP", ")", ")", ")", "{", "cprojects", ".", "add", "(", "CUtils", ".", "getCProject", "(", "project", ")", ")", ";", "}", "}", "scope", "=", "cprojects", ".", "toArray", "(", "new", "ICProject", "[", "cprojects", ".", "size", "(", ")", "]", ")", ";", "}", "IIndex", "index", "=", "CCorePlugin", ".", "getIndexManager", "(", ")", ".", "getIndex", "(", "scope", ",", "IIndexManager", ".", "ADD_DEPENDENCIES", "|", "IIndexManager", ".", "ADD_DEPENDENT", ")", ";", "index", ".", "acquireReadLock", "(", ")", ";", "try", "{", "int", "offset", "=", "getOffset", "(", "commandLine", ")", ";", "int", "length", "=", "commandLine", ".", "getIntValue", "(", "Options", ".", "LENGTH_OPTION", ")", ";", "IName", "[", "]", "names", "=", "findElement", "(", "src", ",", "scope", ",", "context", ",", "offset", ",", "length", ")", ";", "for", "(", "IName", "iname", ":", "names", ")", "{", "IASTFileLocation", "loc", "=", "iname", ".", "getFileLocation", "(", ")", ";", "String", "filename", "=", "loc", ".", "getFileName", "(", ")", ".", "replace", "(", "'\\\\'", ",", "'/'", ")", ";", "results", ".", "add", "(", "Position", ".", "fromOffset", "(", "filename", ",", "null", ",", "loc", ".", "getNodeOffset", "(", ")", ",", "0", ")", ")", ";", "}", "}", "finally", "{", "index", ".", "releaseReadLock", "(", ")", ";", "}", "}", "return", "results", ";", "}", "private", "Object", "executePatternSearch", "(", "CommandLine", "commandLine", ",", "ICProject", "cproject", ")", "throws", "Exception", "{", "String", "scopeName", "=", "commandLine", ".", "getValue", "(", "Options", ".", "SCOPE_OPTION", ")", ";", "ICProject", "[", "]", "scope", "=", "getScope", "(", "scopeName", ",", "cproject", ")", ";", "String", "scopeDesc", "=", "null", ";", "if", "(", "cproject", "==", "null", "||", "SCOPE_ALL", ".", "equals", "(", "scopeName", ")", ")", "{", "scopeDesc", "=", "CSearchMessages", ".", "WorkspaceScope", ";", "}", "else", "if", "(", "SCOPE_PROJECT", ".", "equals", "(", "scopeName", ")", ")", "{", "scopeDesc", "=", "CSearchMessages", ".", "ProjectScope", ";", "}", "int", "context", "=", "getContext", "(", "commandLine", ".", "getValue", "(", "Options", ".", "CONTEXT_OPTION", ")", ")", ";", "int", "type", "=", "getType", "(", "commandLine", ".", "getValue", "(", "Options", ".", "TYPE_OPTION", ")", ")", ";", "String", "pattern", "=", "commandLine", ".", "getValue", "(", "Options", ".", "PATTERN_OPTION", ")", ";", "boolean", "caseSensitive", "=", "!", "commandLine", ".", "hasOption", "(", "Options", ".", "CASE_INSENSITIVE_OPTION", ")", ";", "CSearchQuery", "query", "=", "new", "CSearchPatternQuery", "(", "scope", ",", "scopeDesc", ",", "pattern", ",", "caseSensitive", ",", "type", "|", "context", ")", ";", "ArrayList", "<", "Position", ">", "results", "=", "new", "ArrayList", "<", "Position", ">", "(", ")", ";", "if", "(", "query", "!=", "null", ")", "{", "query", ".", "run", "(", "new", "NullProgressMonitor", "(", ")", ")", ";", "CSearchResult", "result", "=", "(", "CSearchResult", ")", "query", ".", "getSearchResult", "(", ")", ";", "for", "(", "Object", "e", ":", "result", ".", "getElements", "(", ")", ")", "{", "Method", "method", "=", "CSearchElement", ".", "class", ".", "getDeclaredMethod", "(", "\"getLocation\"", ")", ";", "method", ".", "setAccessible", "(", "true", ")", ";", "IIndexFileLocation", "location", "=", "(", "IIndexFileLocation", ")", "method", ".", "invoke", "(", "e", ")", ";", "String", "filename", "=", "location", ".", "getURI", "(", ")", ".", "getPath", "(", ")", ";", "if", "(", "Os", ".", "isFamily", "(", "\"windows\"", ")", "&&", "filename", ".", "startsWith", "(", "\"/\"", ")", ")", "{", "filename", "=", "filename", ".", "substring", "(", "1", ")", ";", "}", "for", "(", "Match", "m", ":", "result", ".", "getMatches", "(", "e", ")", ")", "{", "CSearchMatch", "match", "=", "(", "CSearchMatch", ")", "m", ";", "results", ".", "add", "(", "Position", ".", "fromOffset", "(", "filename", ",", "null", ",", "match", ".", "getOffset", "(", ")", ",", "0", ")", ")", ";", "}", "}", "}", "return", "results", ";", "}", "protected", "IName", "[", "]", "findElement", "(", "ITranslationUnit", "src", ",", "ICProject", "[", "]", "scope", ",", "int", "context", ",", "int", "offset", ",", "int", "length", ")", "throws", "Exception", "{", "LinkedHashSet", "<", "IName", ">", "names", "=", "new", "LinkedHashSet", "<", "IName", ">", "(", ")", ";", "IIndex", "index", "=", "CCorePlugin", ".", "getIndexManager", "(", ")", ".", "getIndex", "(", "scope", ",", "IIndexManager", ".", "ADD_DEPENDENCIES", "|", "IIndexManager", ".", "ADD_DEPENDENT", ")", ";", "index", ".", "acquireReadLock", "(", ")", ";", "try", "{", "IASTTranslationUnit", "ast", "=", "src", ".", "getAST", "(", "index", ",", "ITranslationUnit", ".", "AST_CONFIGURE_USING_SOURCE_CONTEXT", "|", "ITranslationUnit", ".", "AST_SKIP_INDEXED_HEADERS", ")", ";", "IASTNodeSelector", "selector", "=", "ast", ".", "getNodeSelector", "(", "null", ")", ";", "IASTName", "name", "=", "selector", ".", "findEnclosingName", "(", "offset", ",", "length", ")", ";", "if", "(", "name", "!=", "null", ")", "{", "IBinding", "binding", "=", "name", ".", "resolveBinding", "(", ")", ";", "int", "flags", "=", "IIndex", ".", "SEARCH_ACROSS_LANGUAGE_BOUNDARIES", ";", "if", "(", "context", "==", "FIND_CONTEXT", ")", "{", "if", "(", "!", "name", ".", "isDeclaration", "(", ")", "&&", "!", "name", ".", "isDefinition", "(", ")", ")", "{", "flags", "|=", "IIndex", ".", "FIND_DEFINITIONS", ";", "}", "else", "{", "flags", "|=", "(", "name", ".", "isDefinition", "(", ")", "?", "IIndex", ".", "FIND_DECLARATIONS", ":", "IIndex", ".", "FIND_DEFINITIONS", ")", ";", "}", "}", "else", "if", "(", "context", "==", "CSearchQuery", ".", "FIND_ALL_OCCURRENCES", ")", "{", "flags", "|=", "IIndex", ".", "FIND_ALL_OCCURRENCES", ";", "}", "else", "if", "(", "context", "==", "CSearchQuery", ".", "FIND_REFERENCES", ")", "{", "flags", "|=", "IIndex", ".", "FIND_REFERENCES", ";", "}", "else", "if", "(", "context", "==", "CSearchQuery", ".", "FIND_DECLARATIONS_DEFINITIONS", ")", "{", "flags", "|=", "IIndex", ".", "FIND_DECLARATIONS_DEFINITIONS", ";", "}", "else", "if", "(", "context", "==", "CSearchQuery", ".", "FIND_DECLARATIONS", ")", "{", "flags", "|=", "IIndex", ".", "FIND_DECLARATIONS", ";", "}", "else", "if", "(", "context", "==", "CSearchQuery", ".", "FIND_DEFINITIONS", ")", "{", "flags", "|=", "IIndex", ".", "FIND_DEFINITIONS", ";", "}", "CollectionUtils", ".", "addAll", "(", "names", ",", "index", ".", "findNames", "(", "binding", ",", "flags", ")", ")", ";", "if", "(", "names", ".", "size", "(", ")", "==", "0", "&&", "context", "==", "FIND_CONTEXT", "&&", "(", "flags", "&", "IIndex", ".", "FIND_DEFINITIONS", ")", "!=", "0", ")", "{", "CollectionUtils", ".", "addAll", "(", "names", ",", "index", ".", "findNames", "(", "binding", ",", "IIndex", ".", "SEARCH_ACROSS_LANGUAGE_BOUNDARIES", "|", "IIndex", ".", "FIND_DECLARATIONS", ")", ")", ";", "}", "if", "(", "names", ".", "size", "(", ")", "==", "0", ")", "{", "if", "(", "(", "flags", "&", "IIndex", ".", "FIND_DECLARATIONS", ")", "!=", "0", ")", "{", "CollectionUtils", ".", "addAll", "(", "names", ",", "ast", ".", "getDeclarations", "(", "binding", ")", ")", ";", "}", "if", "(", "(", "flags", "&", "IIndex", ".", "FIND_DEFINITIONS", ")", "!=", "0", ")", "{", "CollectionUtils", ".", "addAll", "(", "names", ",", "ast", ".", "getDefinitions", "(", "binding", ")", ")", ";", "}", "if", "(", "(", "flags", "&", "IIndex", ".", "FIND_REFERENCES", ")", "!=", "0", ")", "{", "CollectionUtils", ".", "addAll", "(", "names", ",", "ast", ".", "getReferences", "(", "binding", ")", ")", ";", "}", "}", "}", "}", "finally", "{", "index", ".", "releaseReadLock", "(", ")", ";", "}", "return", "names", ".", "toArray", "(", "new", "IName", "[", "names", ".", "size", "(", ")", "]", ")", ";", "}", "protected", "ICProject", "[", "]", "getScope", "(", "String", "scope", ",", "ICProject", "project", ")", "throws", "Exception", "{", "if", "(", "project", "==", "null", "||", "SCOPE_ALL", ".", "equals", "(", "scope", ")", ")", "{", "ArrayList", "<", "ICProject", ">", "elements", "=", "new", "ArrayList", "<", "ICProject", ">", "(", ")", ";", "IProject", "[", "]", "projects", "=", "ResourcesPlugin", ".", "getWorkspace", "(", ")", ".", "getRoot", "(", ")", ".", "getProjects", "(", ")", ";", "for", "(", "IProject", "p", ":", "projects", ")", "{", "if", "(", "p", ".", "isOpen", "(", ")", "&&", "(", "p", ".", "hasNature", "(", "CProjectNature", ".", "C_NATURE_ID", ")", "||", "p", ".", "hasNature", "(", "CCProjectNature", ".", "CC_NATURE_ID", ")", ")", ")", "{", "elements", ".", "add", "(", "CoreModel", ".", "getDefault", "(", ")", ".", "create", "(", "p", ")", ")", ";", "}", "}", "return", "elements", ".", "toArray", "(", "new", "ICProject", "[", "elements", ".", "size", "(", ")", "]", ")", ";", "}", "ArrayList", "<", "ICProject", ">", "elements", "=", "new", "ArrayList", "<", "ICProject", ">", "(", ")", ";", "elements", ".", "add", "(", "project", ")", ";", "IProject", "[", "]", "depends", "=", "project", ".", "getProject", "(", ")", ".", "getReferencedProjects", "(", ")", ";", "for", "(", "IProject", "p", ":", "depends", ")", "{", "if", "(", "!", "p", ".", "isOpen", "(", ")", ")", "{", "p", ".", "open", "(", "null", ")", ";", "}", "elements", ".", "add", "(", "CoreModel", ".", "getDefault", "(", ")", ".", "create", "(", "p", ")", ")", ";", "}", "return", "elements", ".", "toArray", "(", "new", "ICProject", "[", "elements", ".", "size", "(", ")", "]", ")", ";", "}", "protected", "int", "getContext", "(", "String", "context", ")", "{", "return", "getContext", "(", "context", ",", "CSearchQuery", ".", "FIND_DECLARATIONS_DEFINITIONS", ")", ";", "}", "protected", "int", "getContext", "(", "String", "context", ",", "int", "dflt", ")", "{", "if", "(", "context", "==", "null", ")", "{", "return", "dflt", ";", "}", "if", "(", "CONTEXT_ALL", ".", "equals", "(", "context", ")", ")", "{", "return", "CSearchQuery", ".", "FIND_ALL_OCCURRENCES", ";", "}", "else", "if", "(", "CONTEXT_CONTEXT", ".", "equals", "(", "context", ")", ")", "{", "return", "FIND_CONTEXT", ";", "}", "else", "if", "(", "CONTEXT_REFERENCES", ".", "equals", "(", "context", ")", ")", "{", "return", "CSearchQuery", ".", "FIND_REFERENCES", ";", "}", "else", "if", "(", "CONTEXT_DECLARATIONS", ".", "equals", "(", "context", ")", ")", "{", "return", "CSearchQuery", ".", "FIND_DECLARATIONS", ";", "}", "else", "if", "(", "CONTEXT_DEFINITIONS", ".", "equals", "(", "context", ")", ")", "{", "return", "CSearchQuery", ".", "FIND_DEFINITIONS", ";", "}", "return", "CSearchQuery", ".", "FIND_DECLARATIONS_DEFINITIONS", ";", "}", "protected", "int", "getType", "(", "String", "type", ")", "{", "if", "(", "TYPE_CLASS_STRUCT", ".", "equals", "(", "type", ")", ")", "{", "return", "CSearchPatternQuery", ".", "FIND_CLASS_STRUCT", ";", "}", "else", "if", "(", "TYPE_FUNCTION", ".", "equals", "(", "type", ")", ")", "{", "return", "CSearchPatternQuery", ".", "FIND_FUNCTION", ";", "}", "else", "if", "(", "TYPE_VARIABLE", ".", "equals", "(", "type", ")", ")", "{", "return", "CSearchPatternQuery", ".", "FIND_VARIABLE", ";", "}", "else", "if", "(", "TYPE_UNION", ".", "equals", "(", "type", ")", ")", "{", "return", "CSearchPatternQuery", ".", "FIND_UNION", ";", "}", "else", "if", "(", "TYPE_METHOD", ".", "equals", "(", "type", ")", ")", "{", "return", "CSearchPatternQuery", ".", "FIND_METHOD", ";", "}", "else", "if", "(", "TYPE_FIELD", ".", "equals", "(", "type", ")", ")", "{", "return", "CSearchPatternQuery", ".", "FIND_FIELD", ";", "}", "else", "if", "(", "TYPE_ENUM", ".", "equals", "(", "type", ")", ")", "{", "return", "CSearchPatternQuery", ".", "FIND_ENUM", ";", "}", "else", "if", "(", "TYPE_ENUMERATOR", ".", "equals", "(", "type", ")", ")", "{", "return", "CSearchPatternQuery", ".", "FIND_ENUMERATOR", ";", "}", "else", "if", "(", "TYPE_NAMESPACE", ".", "equals", "(", "type", ")", ")", "{", "return", "CSearchPatternQuery", ".", "FIND_NAMESPACE", ";", "}", "else", "if", "(", "TYPE_TYPEDEF", ".", "equals", "(", "type", ")", ")", "{", "return", "CSearchPatternQuery", ".", "FIND_TYPEDEF", ";", "}", "else", "if", "(", "TYPE_MACRO", ".", "equals", "(", "type", ")", ")", "{", "return", "CSearchPatternQuery", ".", "FIND_MACRO", ";", "}", "return", "CSearchPatternQuery", ".", "FIND_ALL_TYPES", ";", "}", "}", "</s>" ]
1,478
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "cdt", ";", "public", "class", "Cdt", "{", "public", "static", "final", "String", "TEST_PROJECT", "=", "\"\"", ";", "}", "</s>" ]
1,479
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "cdt", ".", "command", ".", "hierarchy", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "org", ".", "eclim", ".", "Eclim", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "cdt", ".", "Cdt", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "*", ";", "public", "class", "CallHierarchyCommandTest", "{", "private", "static", "final", "String", "TEST_FILE", "=", "\"\"", ";", "private", "static", "final", "String", "TEST_FILE_LINK", "=", "\"\"", ";", "@", "Test", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "void", "execute", "(", ")", "{", "assertTrue", "(", "\"\"", ",", "Eclim", ".", "projectExists", "(", "Cdt", ".", "TEST_PROJECT", ")", ")", ";", "Map", "<", "String", ",", "Object", ">", "result", "=", "(", "Map", "<", "String", ",", "Object", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"\"", ",", "\"-p\"", ",", "Cdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "TEST_FILE", ",", "\"-o\"", ",", "\"57\"", ",", "\"-l\"", ",", "\"4\"", ",", "\"-e\"", ",", "\"utf-8\"", "}", ")", ";", "String", "path", "=", "Eclim", ".", "getProjectPath", "(", "Cdt", ".", "TEST_PROJECT", ")", "+", "\"\"", ";", "Map", "<", "String", ",", "Object", ">", "position", "=", "(", "Map", "<", "String", ",", "Object", ">", ")", "result", ".", "get", "(", "\"position\"", ")", ";", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", "calls", "=", "(", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", ")", "result", ".", "get", "(", "\"calledBy\"", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"name\"", ")", ",", "\"fun2(int)\"", ")", ";", "assertEquals", "(", "path", "+", "\"mod2.c\"", ",", "position", ".", "get", "(", "\"filename\"", ")", ")", ";", "assertEquals", "(", "1", ",", "position", ".", "get", "(", "\"line\"", ")", ")", ";", "assertEquals", "(", "5", ",", "position", ".", "get", "(", "\"column\"", ")", ")", ";", "assertEquals", "(", "3", ",", "calls", ".", "size", "(", ")", ")", ";", "result", "=", "calls", ".", "get", "(", "0", ")", ";", "position", "=", "(", "Map", "<", "String", ",", "Object", ">", ")", "result", ".", "get", "(", "\"position\"", ")", ";", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", "nestedCalls", "=", "(", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", ")", "result", ".", "get", "(", "\"calledBy\"", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"name\"", ")", ",", "\"fun1(int)\"", ")", ";", "assertEquals", "(", "path", "+", "\"mod1.c\"", ",", "position", ".", "get", "(", "\"filename\"", ")", ")", ";", "assertEquals", "(", "5", ",", "position", ".", "get", "(", "\"line\"", ")", ")", ";", "assertEquals", "(", "10", ",", "position", ".", "get", "(", "\"column\"", ")", ")", ";", "assertEquals", "(", "2", ",", "nestedCalls", ".", "size", "(", ")", ")", ";", "result", "=", "nestedCalls", ".", "get", "(", "0", ")", ";", "position", "=", "(", "Map", "<", "String", ",", "Object", ">", ")", "result", ".", "get", "(", "\"position\"", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"name\"", ")", ",", "\"main()\"", ")", ";", "assertEquals", "(", "path", "+", "\"main.c\"", ",", "position", ".", "get", "(", "\"filename\"", ")", ")", ";", "assertEquals", "(", "6", ",", "position", ".", "get", "(", "\"line\"", ")", ")", ";", "assertEquals", "(", "28", ",", "position", ".", "get", "(", "\"column\"", ")", ")", ";", "result", "=", "nestedCalls", ".", "get", "(", "1", ")", ";", "position", "=", "(", "Map", "<", "String", ",", "Object", ">", ")", "result", ".", "get", "(", "\"position\"", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"name\"", ")", ",", "\"fun3(int)\"", ")", ";", "assertEquals", "(", "path", "+", "\"mod2.c\"", ",", "position", ".", "get", "(", "\"filename\"", ")", ")", ";", "assertEquals", "(", "7", ",", "position", ".", "get", "(", "\"line\"", ")", ")", ";", "assertEquals", "(", "10", ",", "position", ".", "get", "(", "\"column\"", ")", ")", ";", "result", "=", "calls", ".", "get", "(", "1", ")", ";", "position", "=", "(", "Map", "<", "String", ",", "Object", ">", ")", "result", ".", "get", "(", "\"position\"", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"name\"", ")", ",", "\"fun3(int)\"", ")", ";", "assertEquals", "(", "path", "+", "\"mod2.c\"", ",", "position", ".", "get", "(", "\"filename\"", ")", ")", ";", "assertEquals", "(", "6", ",", "position", ".", "get", "(", "\"line\"", ")", ")", ";", "assertEquals", "(", "3", ",", "position", ".", "get", "(", "\"column\"", ")", ")", ";", "result", "=", "calls", ".", "get", "(", "2", ")", ";", "position", "=", "(", "Map", "<", "String", ",", "Object", ">", ")", "result", ".", "get", "(", "\"position\"", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"name\"", ")", ",", "\"fun3(int)\"", ")", ";", "assertEquals", "(", "path", "+", "\"mod2.c\"", ",", "position", ".", "get", "(", "\"filename\"", ")", ")", ";", "assertEquals", "(", "7", ",", "position", ".", "get", "(", "\"line\"", ")", ")", ";", "assertEquals", "(", "20", ",", "position", ".", "get", "(", "\"column\"", ")", ")", ";", "}", "@", "Test", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "void", "executeLinked", "(", ")", "{", "assertTrue", "(", "\"\"", ",", "Eclim", ".", "projectExists", "(", "Cdt", ".", "TEST_PROJECT", ")", ")", ";", "Map", "<", "String", ",", "Object", ">", "result", "=", "(", "Map", "<", "String", ",", "Object", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"\"", ",", "\"-p\"", ",", "Cdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "TEST_FILE_LINK", ",", "\"-o\"", ",", "\"107\"", ",", "\"-l\"", ",", "\"5\"", ",", "\"-e\"", ",", "\"utf-8\"", "}", ")", ";", "String", "path", "=", "Eclim", ".", "getProjectPath", "(", "Cdt", ".", "TEST_PROJECT", ")", "+", "\"/src-link/\"", ";", "Map", "<", "String", ",", "Object", ">", "position", "=", "(", "Map", "<", "String", ",", "Object", ">", ")", "result", ".", "get", "(", "\"position\"", ")", ";", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", "calls", "=", "(", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", ")", "result", ".", "get", "(", "\"calledBy\"", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"name\"", ")", ",", "\"link1(int)\"", ")", ";", "assertEquals", "(", "path", "+", "\"link.c\"", ",", "position", ".", "get", "(", "\"filename\"", ")", ")", ";", "assertEquals", "(", "1", ",", "position", ".", "get", "(", "\"line\"", ")", ")", ";", "assertEquals", "(", "5", ",", "position", ".", "get", "(", "\"column\"", ")", ")", ";", "assertEquals", "(", "2", ",", "calls", ".", "size", "(", ")", ")", ";", "}", "}", "</s>" ]
1,480
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "cdt", ".", "command", ".", "complete", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "org", ".", "apache", ".", "tools", ".", "ant", ".", "taskdefs", ".", "condition", ".", "Os", ";", "import", "org", ".", "eclim", ".", "Eclim", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "cdt", ".", "Cdt", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "*", ";", "public", "class", "CodeCompleteCommandTest", "{", "private", "static", "final", "String", "TEST_FILE", "=", "\"\"", ";", "@", "Test", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "void", "completeAll", "(", ")", "{", "if", "(", "Os", ".", "isFamily", "(", "Os", ".", "FAMILY_WINDOWS", ")", ")", "{", "return", ";", "}", "assertTrue", "(", "\"\"", ",", "Eclim", ".", "projectExists", "(", "Cdt", ".", "TEST_PROJECT", ")", ")", ";", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", "results", "=", "(", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"c_complete\"", ",", "\"-p\"", ",", "Cdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "TEST_FILE", ",", "\"-o\"", ",", "\"140\"", ",", "\"-e\"", ",", "\"utf-8\"", ",", "\"-l\"", ",", "\"standard\"", "}", ")", ";", "Map", "<", "String", ",", "Object", ">", "result", "=", "results", ".", "get", "(", "0", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"completion\"", ")", ",", "\"test_a\"", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"menu\"", ")", ",", "\"test_a", ":", "int\"", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"info\"", ")", ",", "\"test_a", ":", "int\"", ")", ";", "result", "=", "results", ".", "get", "(", "1", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"completion\"", ")", ",", "\"test_b\"", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"menu\"", ")", ",", "\"test_b", ":", "int\"", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"info\"", ")", ",", "\"test_b", ":", "int\"", ")", ";", "}", "@", "Test", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "void", "completePrefix", "(", ")", "{", "if", "(", "Os", ".", "isFamily", "(", "Os", ".", "FAMILY_WINDOWS", ")", ")", "{", "return", ";", "}", "assertTrue", "(", "\"\"", ",", "Eclim", ".", "projectExists", "(", "Cdt", ".", "TEST_PROJECT", ")", ")", ";", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", "results", "=", "(", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"c_complete\"", ",", "\"-p\"", ",", "Cdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "TEST_FILE", ",", "\"-o\"", ",", "\"156\"", ",", "\"-e\"", ",", "\"utf-8\"", ",", "\"-l\"", ",", "\"standard\"", "}", ")", ";", "assertEquals", "(", "\"\"", ",", "2", ",", "results", ".", "size", "(", ")", ")", ";", "Map", "<", "String", ",", "Object", ">", "result", "=", "results", ".", "get", "(", "0", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"completion\"", ")", ",", "\"EXIT_FAILURE\"", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"menu\"", ")", ",", "\"EXIT_FAILURE\"", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"info\"", ")", ",", "\"\"", ")", ";", "result", "=", "results", ".", "get", "(", "1", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"completion\"", ")", ",", "\"EXIT_SUCCESS\"", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"menu\"", ")", ",", "\"EXIT_SUCCESS\"", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"info\"", ")", ",", "\"\"", ")", ";", "}", "}", "</s>" ]
1,481
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "cdt", ".", "command", ".", "search", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "org", ".", "apache", ".", "tools", ".", "ant", ".", "taskdefs", ".", "condition", ".", "Os", ";", "import", "org", ".", "eclim", ".", "Eclim", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "cdt", ".", "Cdt", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "*", ";", "public", "class", "SearchCommandTest", "{", "private", "static", "final", "String", "TEST_FILE", "=", "\"\"", ";", "private", "static", "final", "String", "TEST_FILE_C", "=", "\"src/test.c\"", ";", "private", "static", "final", "String", "TEST_FILE_H", "=", "\"src/test.h\"", ";", "@", "Test", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "void", "searchElement", "(", ")", "{", "assertTrue", "(", "\"\"", ",", "Eclim", ".", "projectExists", "(", "Cdt", ".", "TEST_PROJECT", ")", ")", ";", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", "results", "=", "(", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"c_search\"", ",", "\"-n\"", ",", "Cdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "TEST_FILE", ",", "\"-o\"", ",", "\"136\"", ",", "\"-l\"", ",", "\"12\"", ",", "\"-e\"", ",", "\"utf-8\"", ",", "\"-x\"", ",", "\"definitions\"", "}", ")", ";", "String", "file", "=", "Eclim", ".", "resolveFile", "(", "Cdt", ".", "TEST_PROJECT", ",", "TEST_FILE_C", ")", ";", "Map", "<", "String", ",", "Object", ">", "result", "=", "results", ".", "get", "(", "0", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"filename\"", ")", ",", "file", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"message\"", ")", ",", "\"\"", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"line\"", ")", ",", "1", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"column\"", ")", ",", "6", ")", ";", "results", "=", "(", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"c_search\"", ",", "\"-n\"", ",", "Cdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "TEST_FILE", ",", "\"-o\"", ",", "\"136\"", ",", "\"-l\"", ",", "\"12\"", ",", "\"-e\"", ",", "\"utf-8\"", ",", "\"-x\"", ",", "\"declarations\"", "}", ")", ";", "file", "=", "Eclim", ".", "resolveFile", "(", "Cdt", ".", "TEST_PROJECT", ",", "TEST_FILE_H", ")", ";", "result", "=", "results", ".", "get", "(", "0", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"filename\"", ")", ",", "file", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"message\"", ")", ",", "\"\"", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"line\"", ")", ",", "4", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"column\"", ")", ",", "6", ")", ";", "results", "=", "(", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"c_search\"", ",", "\"-n\"", ",", "Cdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "TEST_FILE", ",", "\"-o\"", ",", "\"136\"", ",", "\"-l\"", ",", "\"12\"", ",", "\"-e\"", ",", "\"utf-8\"", ",", "\"-x\"", ",", "\"references\"", "}", ")", ";", "assertEquals", "(", "\"\"", ",", "2", ",", "results", ".", "size", "(", ")", ")", ";", "file", "=", "Eclim", ".", "resolveFile", "(", "Cdt", ".", "TEST_PROJECT", ",", "\"\"", ")", ";", "result", "=", "results", ".", "get", "(", "0", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"filename\"", ")", ",", "file", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"message\"", ")", ",", "\"\"", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"line\"", ")", ",", "11", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"column\"", ")", ",", "3", ")", ";", "file", "=", "Eclim", ".", "resolveFile", "(", "Cdt", ".", "TEST_PROJECT", ",", "TEST_FILE", ")", ";", "result", "=", "results", ".", "get", "(", "1", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"filename\"", ")", ",", "file", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"message\"", ")", ",", "\"\"", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"line\"", ")", ",", "11", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"column\"", ")", ",", "3", ")", ";", "results", "=", "(", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"c_search\"", ",", "\"-n\"", ",", "Cdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "TEST_FILE", ",", "\"-o\"", ",", "\"136\"", ",", "\"-l\"", ",", "\"12\"", ",", "\"-e\"", ",", "\"utf-8\"", ",", "\"-x\"", ",", "\"all\"", "}", ")", ";", "assertEquals", "(", "\"\"", ",", "4", ",", "results", ".", "size", "(", ")", ")", ";", "file", "=", "Eclim", ".", "resolveFile", "(", "Cdt", ".", "TEST_PROJECT", ",", "\"\"", ")", ";", "result", "=", "results", ".", "get", "(", "2", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"filename\"", ")", ",", "file", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"message\"", ")", ",", "\"\"", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"line\"", ")", ",", "11", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"column\"", ")", ",", "3", ")", ";", "file", "=", "Eclim", ".", "resolveFile", "(", "Cdt", ".", "TEST_PROJECT", ",", "TEST_FILE", ")", ";", "result", "=", "results", ".", "get", "(", "3", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"filename\"", ")", ",", "file", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"message\"", ")", ",", "\"\"", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"line\"", ")", ",", "11", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"column\"", ")", ",", "3", ")", ";", "results", "=", "(", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"c_search\"", ",", "\"-n\"", ",", "Cdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "TEST_FILE", ",", "\"-o\"", ",", "\"186\"", ",", "\"-l\"", ",", "\"12\"", ",", "\"-e\"", ",", "\"utf-8\"", ",", "\"-x\"", ",", "\"declarations\"", "}", ")", ";", "result", "=", "results", ".", "get", "(", "0", ")", ";", "if", "(", "Os", ".", "isFamily", "(", "Os", ".", "FAMILY_WINDOWS", ")", ")", "{", "assertTrue", "(", "(", "(", "String", ")", "result", ".", "get", "(", "\"filename\"", ")", ")", ".", "endsWith", "(", "\"\"", ")", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"message\"", ")", ",", "\"\"", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"line\"", ")", ",", "33", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"column\"", ")", ",", "9", ")", ";", "}", "else", "{", "assertEquals", "(", "result", ".", "get", "(", "\"filename\"", ")", ",", "\"\"", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"message\"", ")", ",", "\"\"", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"column\"", ")", ",", "9", ")", ";", "int", "line", "=", "(", "(", "Integer", ")", "result", ".", "get", "(", "\"line\"", ")", ")", ".", "intValue", "(", ")", ";", "assertTrue", "(", "line", ">", "130", "&&", "line", "<", "140", ")", ";", "}", "}", "@", "Test", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "void", "searchFunction", "(", ")", "{", "assertTrue", "(", "\"\"", ",", "Eclim", ".", "projectExists", "(", "Cdt", ".", "TEST_PROJECT", ")", ")", ";", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", "results", "=", "(", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"c_search\"", ",", "\"-n\"", ",", "Cdt", ".", "TEST_PROJECT", ",", "\"-p\"", ",", "\"\"", ",", "\"-t\"", ",", "\"function\"", "}", ")", ";", "String", "file", "=", "Eclim", ".", "resolveFile", "(", "Cdt", ".", "TEST_PROJECT", ",", "TEST_FILE", ")", ";", "Map", "<", "String", ",", "Object", ">", "result", "=", "results", ".", "get", "(", "0", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"filename\"", ")", ",", "file", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"message\"", ")", ",", "\"\"", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"line\"", ")", ",", "16", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"column\"", ")", ",", "5", ")", ";", "}", "@", "Test", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "void", "searchConstant", "(", ")", "{", "assertTrue", "(", "\"\"", ",", "Eclim", ".", "projectExists", "(", "Cdt", ".", "TEST_PROJECT", ")", ")", ";", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", "results", "=", "(", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"c_search\"", ",", "\"-n\"", ",", "Cdt", ".", "TEST_PROJECT", ",", "\"-p\"", ",", "\"EXIT_FAILURE\"", ",", "\"-t\"", ",", "\"macro\"", "}", ")", ";", "Map", "<", "String", ",", "Object", ">", "result", "=", "results", ".", "get", "(", "0", ")", ";", "if", "(", "Os", ".", "isFamily", "(", "Os", ".", "FAMILY_WINDOWS", ")", ")", "{", "assertTrue", "(", "(", "(", "String", ")", "result", ".", "get", "(", "\"filename\"", ")", ")", ".", "endsWith", "(", "\"\"", ")", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"message\"", ")", ",", "\"\"", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"line\"", ")", ",", "34", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"column\"", ")", ",", "9", ")", ";", "}", "else", "{", "assertEquals", "(", "result", ".", "get", "(", "\"filename\"", ")", ",", "\"\"", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"message\"", ")", ",", "\"\"", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"column\"", ")", ",", "9", ")", ";", "int", "line", "=", "(", "(", "Integer", ")", "result", ".", "get", "(", "\"line\"", ")", ")", ".", "intValue", "(", ")", ";", "assertTrue", "(", "line", ">", "130", "&&", "line", "<", "140", ")", ";", "}", "}", "@", "Test", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "void", "searchStruct", "(", ")", "{", "assertTrue", "(", "\"\"", ",", "Eclim", ".", "projectExists", "(", "Cdt", ".", "TEST_PROJECT", ")", ")", ";", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", "results", "=", "(", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"c_search\"", ",", "\"-n\"", ",", "Cdt", ".", "TEST_PROJECT", ",", "\"-p\"", ",", "\"\"", ",", "\"-t\"", ",", "\"class_struct\"", "}", ")", ";", "String", "file", "=", "Eclim", ".", "resolveFile", "(", "Cdt", ".", "TEST_PROJECT", ",", "TEST_FILE", ")", ";", "Map", "<", "String", ",", "Object", ">", "result", "=", "results", ".", "get", "(", "0", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"filename\"", ")", ",", "file", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"message\"", ")", ",", "\"\"", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"line\"", ")", ",", "5", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"column\"", ")", ",", "8", ")", ";", "}", "}", "</s>" ]
1,482
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "cdt", ".", "command", ".", "src", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "org", ".", "eclim", ".", "Eclim", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "cdt", ".", "Cdt", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "*", ";", "public", "class", "SrcUpdateCommandTest", "{", "private", "static", "final", "String", "TEST_C_FILE", "=", "\"\"", ";", "private", "static", "final", "String", "TEST_CPP_FILE", "=", "\"\"", ";", "@", "Test", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "void", "validateC", "(", ")", "{", "assertTrue", "(", "\"\"", ",", "Eclim", ".", "projectExists", "(", "Cdt", ".", "TEST_PROJECT", ")", ")", ";", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", "results", "=", "(", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"c_src_update\"", ",", "\"-p\"", ",", "Cdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "TEST_C_FILE", ",", "\"-v\"", "}", ")", ";", "String", "file", "=", "Eclim", ".", "resolveFile", "(", "Cdt", ".", "TEST_PROJECT", ",", "TEST_C_FILE", ")", ";", "Map", "<", "String", ",", "Object", ">", "error", "=", "results", ".", "get", "(", "0", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"filename\"", ")", ",", "file", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"message\"", ")", ",", "\"\"", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"line\"", ")", ",", "1", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"column\"", ")", ",", "1", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"warning\"", ")", ",", "true", ")", ";", "error", "=", "results", ".", "get", "(", "1", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"filename\"", ")", ",", "file", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"message\"", ")", ",", "\"Syntax", "error\"", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"line\"", ")", ",", "5", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"column\"", ")", ",", "3", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"warning\"", ")", ",", "false", ")", ";", "}", "@", "Test", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "void", "validateCPP", "(", ")", "{", "assertTrue", "(", "\"\"", ",", "Eclim", ".", "projectExists", "(", "Cdt", ".", "TEST_PROJECT", ")", ")", ";", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", "results", "=", "(", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"c_src_update\"", ",", "\"-p\"", ",", "Cdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "TEST_CPP_FILE", ",", "\"-v\"", "}", ")", ";", "String", "file", "=", "Eclim", ".", "resolveFile", "(", "Cdt", ".", "TEST_PROJECT", ",", "TEST_CPP_FILE", ")", ";", "Map", "<", "String", ",", "Object", ">", "error", "=", "results", ".", "get", "(", "0", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"filename\"", ")", ",", "file", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"message\"", ")", ",", "\"\"", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"line\"", ")", ",", "3", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"column\"", ")", ",", "7", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"warning\"", ")", ",", "false", ")", ";", "error", "=", "results", ".", "get", "(", "1", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"filename\"", ")", ",", "file", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"message\"", ")", ",", "\"\"", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"line\"", ")", ",", "4", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"column\"", ")", ",", "3", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"warning\"", ")", ",", "false", ")", ";", "}", "}", "</s>" ]
1,483
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "pdt", ".", "command", ".", "complete", ";", "import", "java", ".", "util", ".", "regex", ".", "Matcher", ";", "import", "java", ".", "util", ".", "regex", ".", "Pattern", ";", "import", "org", ".", "eclim", ".", "annotation", ".", "Command", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "dltk", ".", "command", ".", "complete", ".", "AbstractCodeCompleteCommand", ";", "import", "org", ".", "eclipse", ".", "dltk", ".", "core", ".", "ISourceModule", ";", "import", "org", ".", "eclipse", ".", "dltk", ".", "ui", ".", "text", ".", "completion", ".", "IScriptCompletionProposal", ";", "import", "org", ".", "eclipse", ".", "dltk", ".", "ui", ".", "text", ".", "completion", ".", "ScriptCompletionProposalCollector", ";", "import", "org", ".", "eclipse", ".", "php", ".", "internal", ".", "ui", ".", "editor", ".", "contentassist", ".", "PHPCompletionProposalCollector", ";", "@", "Command", "(", "name", "=", "\"php_complete\"", ",", "options", "=", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", ")", "public", "class", "CodeCompleteCommand", "extends", "AbstractCodeCompleteCommand", "{", "private", "static", "final", "Pattern", "DISPALY_TO_COMPLETION", "=", "Pattern", ".", "compile", "(", "\"\"", ")", ";", "private", "static", "final", "Pattern", "METHOD_WITH_ARGS", "=", "Pattern", ".", "compile", "(", "\"\"", ")", ";", "private", "static", "final", "Pattern", "REMOVE_HEAD", "=", "Pattern", ".", "compile", "(", "\"\"", ",", "Pattern", ".", "MULTILINE", "|", "Pattern", ".", "DOTALL", ")", ";", "@", "Override", "protected", "ScriptCompletionProposalCollector", "getCompletionCollector", "(", "ISourceModule", "module", ")", "throws", "Exception", "{", "return", "new", "PHPCompletionProposalCollector", "(", "null", ",", "module", ",", "true", ")", ";", "}", "@", "Override", "protected", "String", "getCompletion", "(", "IScriptCompletionProposal", "proposal", ")", "{", "String", "completion", "=", "proposal", ".", "getDisplayString", "(", ")", ".", "trim", "(", ")", ";", "completion", "=", "DISPALY_TO_COMPLETION", ".", "matcher", "(", "completion", ")", ".", "replaceFirst", "(", "\"$1\"", ")", ";", "Matcher", "matcher", "=", "METHOD_WITH_ARGS", ".", "matcher", "(", "completion", ")", ";", "if", "(", "matcher", ".", "find", "(", ")", ")", "{", "completion", "=", "matcher", ".", "group", "(", "1", ")", ";", "}", "else", "if", "(", "completion", ".", "startsWith", "(", "\"$\"", ")", ")", "{", "completion", "=", "completion", ".", "substring", "(", "1", ")", ";", "}", "return", "completion", ";", "}", "@", "Override", "protected", "String", "getInfo", "(", "IScriptCompletionProposal", "proposal", ")", "{", "String", "info", "=", "super", ".", "getInfo", "(", "proposal", ")", ";", "if", "(", "info", "!=", "null", ")", "{", "info", "=", "REMOVE_HEAD", ".", "matcher", "(", "info", ")", ".", "replaceFirst", "(", "\"\"", ")", ";", "info", "=", "info", ".", "replaceAll", "(", "\"</dt>\"", ",", "\":", "\"", ")", ";", "info", "=", "info", ".", "replaceAll", "(", "\"</dd>\"", ",", "\"", "\"", ")", ";", "info", "=", "info", ".", "replaceAll", "(", "\"n\"", ",", "\"\"", ")", ";", "info", "=", "info", ".", "replaceAll", "(", "\"<dl>\"", ",", "\"n\"", ")", ";", "info", "=", "info", ".", "replaceAll", "(", "\"</?[^>]+>\"", ",", "\"\"", ")", ";", "info", "=", "info", ".", "replaceAll", "(", "\"-->\"", ",", "\"\"", ")", ";", "info", "=", "info", ".", "replaceAll", "(", "\"&nbsp;?\"", ",", "\"", "\"", ")", ";", "info", "=", "info", ".", "trim", "(", ")", ";", "}", "return", "info", ";", "}", "}", "</s>" ]
1,484
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "pdt", ".", "command", ".", "src", ";", "import", "org", ".", "eclim", ".", "annotation", ".", "Command", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "dltk", ".", "command", ".", "src", ".", "AbstractSrcUpdateCommand", ";", "import", "org", ".", "eclipse", ".", "php", ".", "internal", ".", "core", ".", "project", ".", "PHPNature", ";", "@", "Command", "(", "name", "=", "\"\"", ",", "options", "=", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", ")", "public", "class", "SrcUpdateCommand", "extends", "AbstractSrcUpdateCommand", "{", "@", "Override", "protected", "String", "getNature", "(", ")", "{", "return", "PHPNature", ".", "ID", ";", "}", "}", "</s>" ]
1,485
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "pdt", ".", "command", ".", "search", ";", "import", "org", ".", "eclim", ".", "annotation", ".", "Command", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "project", ".", "ProjectNatureFactory", ";", "import", "org", ".", "eclipse", ".", "dltk", ".", "core", ".", "IModelElement", ";", "import", "org", ".", "eclipse", ".", "dltk", ".", "core", ".", "ISourceModule", ";", "@", "Command", "(", "name", "=", "\"php_search\"", ",", "options", "=", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", ")", "public", "class", "SearchCommand", "extends", "org", ".", "eclim", ".", "plugin", ".", "dltk", ".", "command", ".", "search", ".", "SearchCommand", "{", "@", "Override", "protected", "String", "getNature", "(", ")", "{", "return", "ProjectNatureFactory", ".", "getNatureForAlias", "(", "\"php\"", ")", ";", "}", "@", "Override", "protected", "String", "getElementSeparator", "(", ")", "{", "return", "\"", "->", "\"", ";", "}", "@", "Override", "protected", "String", "getElementTypeName", "(", ")", "{", "return", "\"class\"", ";", "}", "@", "Override", "protected", "IModelElement", "[", "]", "getElements", "(", "ISourceModule", "src", ",", "int", "offset", ",", "int", "length", ")", "throws", "Exception", "{", "IModelElement", "[", "]", "elements", "=", "super", ".", "getElements", "(", "src", ",", "offset", ",", "length", ")", ";", "return", "elements", ";", "}", "}", "</s>" ]
1,486
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "pdt", ".", "project", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "dltk", ".", "project", ".", "DltkProjectManager", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "IFile", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "IProject", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "NullProgressMonitor", ";", "import", "org", ".", "eclipse", ".", "dltk", ".", "core", ".", "DLTKLanguageManager", ";", "import", "org", ".", "eclipse", ".", "dltk", ".", "core", ".", "IDLTKLanguageToolkit", ";", "import", "org", ".", "eclipse", ".", "dltk", ".", "core", ".", "ISourceModule", ";", "import", "org", ".", "eclipse", ".", "php", ".", "internal", ".", "core", ".", "project", ".", "PHPNature", ";", "import", "org", ".", "eclipse", ".", "php", ".", "internal", ".", "ui", ".", "PHPUiPlugin", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "IEditorInput", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "part", ".", "FileEditorInput", ";", "public", "class", "PhpProjectManager", "extends", "DltkProjectManager", "{", "@", "Override", "public", "IDLTKLanguageToolkit", "getLanguageToolkit", "(", ")", "{", "return", "DLTKLanguageManager", ".", "getLanguageToolkit", "(", "PHPNature", ".", "ID", ")", ";", "}", "@", "Override", "public", "void", "refresh", "(", "IProject", "project", ",", "IFile", "file", ")", "throws", "Exception", "{", "IEditorInput", "input", "=", "new", "FileEditorInput", "(", "file", ")", ";", "ISourceModule", "module", "=", "PHPUiPlugin", ".", "getEditorInputTypeRoot", "(", "input", ")", ";", "if", "(", "module", "!=", "null", ")", "{", "module", ".", "makeConsistent", "(", "new", "NullProgressMonitor", "(", ")", ")", ";", "}", "}", "}", "</s>" ]
1,487
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "pdt", ".", "preference", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "IProject", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "ProjectScope", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "preferences", ".", "IEclipsePreferences", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "preferences", ".", "IScopeContext", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "preference", ".", "IPersistentPreferenceStore", ";", "import", "org", ".", "eclipse", ".", "php", ".", "internal", ".", "core", ".", "PHPCoreConstants", ";", "import", "org", ".", "eclipse", ".", "php", ".", "internal", ".", "ui", ".", "PHPUiPlugin", ";", "public", "class", "OptionHandler", "implements", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "preference", ".", "OptionHandler", "{", "private", "static", "final", "String", "NATURE", "=", "\"\"", ";", "private", "static", "final", "String", "PREFIX", "=", "\"\"", ";", "private", "static", "final", "String", "VERSION", "=", "PREFIX", "+", "PHPCoreConstants", ".", "PHP_OPTIONS_PHP_VERSION", ";", "private", "IPersistentPreferenceStore", "store", ";", "private", "Map", "<", "String", ",", "String", ">", "options", ";", "public", "String", "getNature", "(", ")", "{", "return", "NATURE", ";", "}", "public", "Map", "<", "String", ",", "String", ">", "getValues", "(", ")", "throws", "Exception", "{", "if", "(", "options", "==", "null", ")", "{", "options", "=", "new", "HashMap", "<", "String", ",", "String", ">", "(", ")", ";", "options", ".", "put", "(", "VERSION", ",", "getPreferences", "(", ")", ".", "getString", "(", "PHPCoreConstants", ".", "PHP_OPTIONS_PHP_VERSION", ")", ")", ";", "}", "return", "options", ";", "}", "public", "Map", "<", "String", ",", "String", ">", "getValues", "(", "IProject", "project", ")", "throws", "Exception", "{", "IEclipsePreferences", "preferences", "=", "getPreferences", "(", "project", ")", ";", "Map", "<", "String", ",", "String", ">", "map", "=", "getValues", "(", ")", ";", "for", "(", "String", "key", ":", "preferences", ".", "keys", "(", ")", ")", "{", "map", ".", "put", "(", "PREFIX", "+", "key", ",", "preferences", ".", "get", "(", "key", ",", "null", ")", ")", ";", "}", "return", "map", ";", "}", "public", "void", "setOption", "(", "String", "name", ",", "String", "value", ")", "throws", "Exception", "{", "if", "(", "VERSION", ".", "equals", "(", "name", ")", ")", "{", "getValues", "(", ")", ".", "put", "(", "VERSION", ",", "value", ")", ";", "IPersistentPreferenceStore", "store", "=", "getPreferences", "(", ")", ";", "store", ".", "setValue", "(", "name", ".", "substring", "(", "PREFIX", ".", "length", "(", ")", ")", ",", "value", ")", ";", "store", ".", "save", "(", ")", ";", "}", "}", "public", "void", "setOption", "(", "IProject", "project", ",", "String", "name", ",", "String", "value", ")", "throws", "Exception", "{", "IEclipsePreferences", "preferences", "=", "getPreferences", "(", "project", ")", ";", "if", "(", "name", ".", "startsWith", "(", "PREFIX", ")", ")", "{", "name", "=", "name", ".", "substring", "(", "PREFIX", ".", "length", "(", ")", ")", ";", "}", "preferences", ".", "put", "(", "name", ",", "value", ")", ";", "preferences", ".", "flush", "(", ")", ";", "}", "private", "IPersistentPreferenceStore", "getPreferences", "(", ")", "{", "if", "(", "store", "==", "null", ")", "{", "store", "=", "(", "IPersistentPreferenceStore", ")", "PHPUiPlugin", ".", "getDefault", "(", ")", ".", "getPreferenceStore", "(", ")", ";", "}", "return", "store", ";", "}", "private", "IEclipsePreferences", "getPreferences", "(", "IProject", "project", ")", "{", "IScopeContext", "context", "=", "new", "ProjectScope", "(", "project", ")", ";", "IEclipsePreferences", "preferences", "=", "context", ".", "getNode", "(", "\"\"", ")", ";", "return", "preferences", ";", "}", "}", "</s>" ]
1,488
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "pdt", ".", "util", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "ResourcesPlugin", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "jobs", ".", "IJobManager", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "jobs", ".", "Job", ";", "public", "class", "PhpUtils", "{", "public", "static", "void", "waitOnBuild", "(", ")", "{", "IJobManager", "manager", "=", "Job", ".", "getJobManager", "(", ")", ";", "Job", "[", "]", "jobs", "=", "manager", ".", "find", "(", "ResourcesPlugin", ".", "FAMILY_AUTO_BUILD", ")", ";", "if", "(", "jobs", "!=", "null", "&&", "jobs", ".", "length", ">", "0", ")", "{", "for", "(", "Job", "job", ":", "jobs", ")", "{", "job", ".", "wakeUp", "(", ")", ";", "}", "int", "tries", "=", "0", ";", "while", "(", "tries", "<", "10", "&&", "jobs", "!=", "null", "&&", "jobs", ".", "length", ">", "0", ")", "{", "try", "{", "Thread", ".", "sleep", "(", "100", ")", ";", "}", "catch", "(", "Exception", "ignore", ")", "{", "}", "jobs", "=", "manager", ".", "find", "(", "ResourcesPlugin", ".", "FAMILY_AUTO_BUILD", ")", ";", "tries", "++", ";", "}", "}", "}", "}", "</s>" ]
1,489
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "pdt", ";", "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", ".", "pdt", ".", "preference", ".", "OptionHandler", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "pdt", ".", "project", ".", "PhpProjectManager", ";", "import", "org", ".", "eclipse", ".", "php", ".", "internal", ".", "core", ".", "PHPCorePlugin", ";", "import", "org", ".", "eclipse", ".", "php", ".", "internal", ".", "core", ".", "project", ".", "PHPNature", ";", "public", "class", "PluginResources", "extends", "AbstractPluginResources", "{", "private", "static", "final", "Logger", "logger", "=", "Logger", ".", "getLogger", "(", "PluginResources", ".", "class", ")", ";", "public", "static", "final", "String", "NAME", "=", "\"\"", ";", "@", "Override", "public", "void", "initialize", "(", "String", "name", ")", "{", "super", ".", "initialize", "(", "name", ")", ";", "ProjectNatureFactory", ".", "addNature", "(", "\"php\"", ",", "PHPNature", ".", "ID", ")", ";", "ProjectManagement", ".", "addProjectManager", "(", "PHPNature", ".", "ID", ",", "new", "PhpProjectManager", "(", ")", ")", ";", "Preferences", ".", "addOptionHandler", "(", "\"\"", ",", "new", "OptionHandler", "(", ")", ")", ";", "PreferenceFactory", ".", "addOptions", "(", "\"\"", ",", "\"\"", ")", ";", "try", "{", "PHPCorePlugin", ".", "initializeAfterLoad", "(", "null", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "logger", ".", "error", "(", "\"\"", ",", "e", ")", ";", "}", "}", "protected", "String", "getBundleBaseName", "(", ")", "{", "return", "\"\"", ";", "}", "}", "</s>" ]
1,490
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "pdt", ";", "public", "class", "Pdt", "{", "public", "static", "final", "String", "TEST_PROJECT", "=", "\"\"", ";", "}", "</s>" ]
1,491
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "pdt", ".", "command", ".", "complete", ";", "import", "java", ".", "io", ".", "FileWriter", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang", ".", "StringUtils", ";", "import", "org", ".", "eclim", ".", "Eclim", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "pdt", ".", "Pdt", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "*", ";", "public", "class", "CodeCompleteCommandTest", "{", "private", "static", "final", "String", "TEST_FILE", "=", "\"\"", ";", "private", "static", "final", "String", "TEST_FILE_ERRATIC", "=", "\"test.php\"", ";", "@", "Test", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "void", "completeAll", "(", ")", "{", "assertTrue", "(", "\"\"", ",", "Eclim", ".", "projectExists", "(", "Pdt", ".", "TEST_PROJECT", ")", ")", ";", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", "results", "=", "(", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"php_complete\"", ",", "\"-p\"", ",", "Pdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "TEST_FILE", ",", "\"-o\"", ",", "\"213\"", ",", "\"-e\"", ",", "\"utf-8\"", "}", ")", ";", "assertEquals", "(", "\"\"", ",", "3", ",", "results", ".", "size", "(", ")", ")", ";", "Map", "<", "String", ",", "Object", ">", "result", "=", "results", ".", "get", "(", "0", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"completion\"", ")", ",", "\"methodA1(\"", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"menu\"", ")", ",", "\"\"", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"info\"", ")", ",", "\"\"", ")", ";", "result", "=", "results", ".", "get", "(", "1", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"completion\"", ")", ",", "\"methodA2()\"", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"menu\"", ")", ",", "\"\"", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"info\"", ")", ",", "\"\"", ")", ";", "result", "=", "results", ".", "get", "(", "2", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"completion\"", ")", ",", "\"variable1\"", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"menu\"", ")", ",", "\"$variable1\"", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"info\"", ")", ",", "\"$variable1\"", ")", ";", "}", "@", "Test", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "void", "completePrefix", "(", ")", "{", "assertTrue", "(", "\"\"", ",", "Eclim", ".", "projectExists", "(", "Pdt", ".", "TEST_PROJECT", ")", ")", ";", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", "results", "=", "(", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"php_complete\"", ",", "\"-p\"", ",", "Pdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "TEST_FILE", ",", "\"-o\"", ",", "\"228\"", ",", "\"-e\"", ",", "\"utf-8\"", "}", ")", ";", "assertEquals", "(", "\"\"", ",", "2", ",", "results", ".", "size", "(", ")", ")", ";", "Map", "<", "String", ",", "Object", ">", "result", "=", "results", ".", "get", "(", "0", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"completion\"", ")", ",", "\"methodA1(\"", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"menu\"", ")", ",", "\"\"", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"info\"", ")", ",", "\"\"", ")", ";", "result", "=", "results", ".", "get", "(", "1", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"completion\"", ")", ",", "\"methodA2()\"", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"menu\"", ")", ",", "\"\"", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"info\"", ")", ",", "\"\"", ")", ";", "}", "@", "Test", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "void", "completeMagic", "(", ")", "{", "assertTrue", "(", "\"\"", ",", "Eclim", ".", "projectExists", "(", "Pdt", ".", "TEST_PROJECT", ")", ")", ";", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", "results", "=", "(", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"php_complete\"", ",", "\"-p\"", ",", "Pdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "TEST_FILE", ",", "\"-o\"", ",", "\"294\"", ",", "\"-e\"", ",", "\"utf-8\"", "}", ")", ";", "assertEquals", "(", "\"\"", ",", "1", ",", "results", ".", "size", "(", ")", ")", ";", "Map", "<", "String", ",", "Object", ">", "result", "=", "results", ".", "get", "(", "0", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"completion\"", ")", ",", "\"regular\"", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"menu\"", ")", ",", "\"\"", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"info\"", ")", ",", "\"\"", ")", ";", "}", "@", "Test", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "void", "completeErratic", "(", ")", "throws", "Exception", "{", "assertTrue", "(", "\"\"", ",", "Eclim", ".", "projectExists", "(", "Pdt", ".", "TEST_PROJECT", ")", ")", ";", "String", "[", "]", "contents", "=", "new", "String", "[", "]", "{", "\"<?php\"", ",", "\"\"", ",", "\"class", "Test", "{\"", ",", "\"\"", ",", "\"", "}\"", ",", "\"\"", ",", "\"", "}\"", ",", "\"}\"", ",", "\"\"", ",", "\"\"", ",", "\"$test->;\"", "}", ";", "int", "index", "=", "105", ";", "for", "(", "int", "ii", "=", "0", ";", "ii", "<", "10", ";", "ii", "++", ")", "{", "FileWriter", "out", "=", "new", "FileWriter", "(", "Eclim", ".", "resolveFile", "(", "Pdt", ".", "TEST_PROJECT", ",", "TEST_FILE_ERRATIC", ")", ")", ";", "out", ".", "write", "(", "StringUtils", ".", "join", "(", "contents", ",", "\"n\"", ")", ")", ";", "out", ".", "close", "(", ")", ";", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", "results", "=", "(", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"php_complete\"", ",", "\"-p\"", ",", "Pdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "TEST_FILE_ERRATIC", ",", "\"-o\"", ",", "String", ".", "valueOf", "(", "index", ")", ",", "\"-e\"", ",", "\"utf-8\"", "}", ")", ";", "assertEquals", "(", "\"\"", ",", "2", ",", "results", ".", "size", "(", ")", ")", ";", "Map", "<", "String", ",", "Object", ">", "result", "=", "results", ".", "get", "(", "0", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"completion\"", ")", ",", "\"getName()\"", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"menu\"", ")", ",", "\"\"", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"info\"", ")", ",", "\"\"", ")", ";", "result", "=", "results", ".", "get", "(", "1", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"completion\"", ")", ",", "\"getValue()\"", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"menu\"", ")", ",", "\"\"", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"info\"", ")", ",", "\"\"", ")", ";", "String", "[", "]", "newContents", "=", "new", "String", "[", "contents", ".", "length", "+", "1", "]", ";", "System", ".", "arraycopy", "(", "contents", ",", "0", ",", "newContents", ",", "0", ",", "contents", ".", "length", "-", "1", ")", ";", "newContents", "[", "contents", ".", "length", "-", "1", "]", "=", "\"\"", ";", "newContents", "[", "contents", ".", "length", "]", "=", "\"$test->;\"", ";", "contents", "=", "newContents", ";", "index", "+=", "18", ";", "Thread", ".", "sleep", "(", "1000", ")", ";", "}", "}", "}", "</s>" ]
1,492
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "pdt", ".", "command", ".", "src", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "org", ".", "eclim", ".", "Eclim", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "pdt", ".", "Pdt", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "*", ";", "public", "class", "SrcUpdateCommandTest", "{", "private", "static", "final", "String", "TEST_FILE", "=", "\"\"", ";", "@", "Test", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "void", "validate", "(", ")", "{", "assertTrue", "(", "\"\"", ",", "Eclim", ".", "projectExists", "(", "Pdt", ".", "TEST_PROJECT", ")", ")", ";", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", "results", "=", "(", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"\"", ",", "\"-p\"", ",", "Pdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "TEST_FILE", ",", "\"-v\"", "}", ")", ";", "String", "file", "=", "Eclim", ".", "resolveFile", "(", "Pdt", ".", "TEST_PROJECT", ",", "\"\"", ")", ";", "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\"", ")", ",", "5", ")", ";", "assertEquals", "(", "error", ".", "get", "(", "\"warning\"", ")", ",", "false", ")", ";", "}", "}", "</s>" ]
1,493
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "pdt", ".", "command", ".", "search", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "org", ".", "eclim", ".", "Eclim", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "pdt", ".", "Pdt", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "*", ";", "public", "class", "SearchCommandTest", "{", "private", "static", "final", "String", "TEST_FILE", "=", "\"\"", ";", "@", "Test", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "void", "searchElementClass", "(", ")", "{", "assertTrue", "(", "\"\"", ",", "Eclim", ".", "projectExists", "(", "Pdt", ".", "TEST_PROJECT", ")", ")", ";", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", "results", "=", "(", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"php_search\"", ",", "\"-n\"", ",", "Pdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "TEST_FILE", ",", "\"-o\"", ",", "\"45\"", ",", "\"-l\"", ",", "\"5\"", ",", "\"-e\"", ",", "\"utf-8\"", "}", ")", ";", "String", "file", "=", "Eclim", ".", "resolveFile", "(", "Pdt", ".", "TEST_PROJECT", ",", "\"\"", ")", ";", "Map", "<", "String", ",", "Object", ">", "result", "=", "results", ".", "get", "(", "0", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"filename\"", ")", ",", "file", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"message\"", ")", ",", "\"class", "TestA\"", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"line\"", ")", ",", "6", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"column\"", ")", ",", "7", ")", ";", "}", "@", "Test", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "void", "searchElementMethod", "(", ")", "{", "assertTrue", "(", "\"\"", ",", "Eclim", ".", "projectExists", "(", "Pdt", ".", "TEST_PROJECT", ")", ")", ";", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", "results", "=", "(", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"php_search\"", ",", "\"-n\"", ",", "Pdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "TEST_FILE", ",", "\"-o\"", ",", "\"62\"", ",", "\"-l\"", ",", "\"8\"", ",", "\"-e\"", ",", "\"utf-8\"", "}", ")", ";", "String", "file", "=", "Eclim", ".", "resolveFile", "(", "Pdt", ".", "TEST_PROJECT", ",", "\"\"", ")", ";", "Map", "<", "String", ",", "Object", ">", "result", "=", "results", ".", "get", "(", "0", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"filename\"", ")", ",", "file", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"message\"", ")", ",", "\"\"", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"line\"", ")", ",", "13", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"column\"", ")", ",", "19", ")", ";", "}", "@", "Test", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "void", "searchElementVariable", "(", ")", "{", "assertTrue", "(", "\"\"", ",", "Eclim", ".", "projectExists", "(", "Pdt", ".", "TEST_PROJECT", ")", ")", ";", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", "results", "=", "(", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"php_search\"", ",", "\"-n\"", ",", "Pdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "TEST_FILE", ",", "\"-o\"", ",", "\"82\"", ",", "\"-l\"", ",", "\"9\"", ",", "\"-e\"", ",", "\"utf-8\"", "}", ")", ";", "String", "file", "=", "Eclim", ".", "resolveFile", "(", "Pdt", ".", "TEST_PROJECT", ",", "\"\"", ")", ";", "Map", "<", "String", ",", "Object", ">", "result", "=", "results", ".", "get", "(", "0", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"filename\"", ")", ",", "file", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"message\"", ")", ",", "\"\"", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"line\"", ")", ",", "8", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"column\"", ")", ",", "7", ")", ";", "}", "@", "Test", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "void", "searchElementFunction", "(", ")", "{", "assertTrue", "(", "\"\"", ",", "Eclim", ".", "projectExists", "(", "Pdt", ".", "TEST_PROJECT", ")", ")", ";", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", "results", "=", "(", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"php_search\"", ",", "\"-n\"", ",", "Pdt", ".", "TEST_PROJECT", ",", "\"-f\"", ",", "TEST_FILE", ",", "\"-o\"", ",", "\"94\"", ",", "\"-l\"", ",", "\"9\"", ",", "\"-e\"", ",", "\"utf-8\"", "}", ")", ";", "String", "file", "=", "Eclim", ".", "resolveFile", "(", "Pdt", ".", "TEST_PROJECT", ",", "\"\"", ")", ";", "Map", "<", "String", ",", "Object", ">", "result", "=", "results", ".", "get", "(", "0", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"filename\"", ")", ",", "file", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"message\"", ")", ",", "\"\"", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"line\"", ")", ",", "3", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"column\"", ")", ",", "10", ")", ";", "}", "@", "Test", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "void", "searchClass", "(", ")", "{", "assertTrue", "(", "\"\"", ",", "Eclim", ".", "projectExists", "(", "Pdt", ".", "TEST_PROJECT", ")", ")", ";", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", "results", "=", "(", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"php_search\"", ",", "\"-n\"", ",", "Pdt", ".", "TEST_PROJECT", ",", "\"-p\"", ",", "\"TestA\"", ",", "\"-t\"", ",", "\"class\"", "}", ")", ";", "String", "file", "=", "Eclim", ".", "resolveFile", "(", "Pdt", ".", "TEST_PROJECT", ",", "\"\"", ")", ";", "Map", "<", "String", ",", "Object", ">", "result", "=", "results", ".", "get", "(", "0", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"filename\"", ")", ",", "file", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"message\"", ")", ",", "\"class", "TestA\"", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"line\"", ")", ",", "6", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"column\"", ")", ",", "7", ")", ";", "}", "@", "Test", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "void", "searchMethod", "(", ")", "{", "assertTrue", "(", "\"\"", ",", "Eclim", ".", "projectExists", "(", "Pdt", ".", "TEST_PROJECT", ")", ")", ";", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", "results", "=", "(", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"php_search\"", ",", "\"-n\"", ",", "Pdt", ".", "TEST_PROJECT", ",", "\"-p\"", ",", "\"methodA1\"", ",", "\"-t\"", ",", "\"function\"", "}", ")", ";", "String", "file", "=", "Eclim", ".", "resolveFile", "(", "Pdt", ".", "TEST_PROJECT", ",", "\"\"", ")", ";", "Map", "<", "String", ",", "Object", ">", "result", "=", "results", ".", "get", "(", "0", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"filename\"", ")", ",", "file", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"message\"", ")", ",", "\"\"", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"line\"", ")", ",", "9", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"column\"", ")", ",", "19", ")", ";", "}", "@", "Test", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "void", "searchFunction", "(", ")", "{", "assertTrue", "(", "\"\"", ",", "Eclim", ".", "projectExists", "(", "Pdt", ".", "TEST_PROJECT", ")", ")", ";", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", "results", "=", "(", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", ")", "Eclim", ".", "execute", "(", "new", "String", "[", "]", "{", "\"php_search\"", ",", "\"-n\"", ",", "Pdt", ".", "TEST_PROJECT", ",", "\"-p\"", ",", "\"functionA\"", ",", "\"-t\"", ",", "\"function\"", "}", ")", ";", "String", "file", "=", "Eclim", ".", "resolveFile", "(", "Pdt", ".", "TEST_PROJECT", ",", "\"\"", ")", ";", "Map", "<", "String", ",", "Object", ">", "result", "=", "results", ".", "get", "(", "0", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"filename\"", ")", ",", "file", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"message\"", ")", ",", "\"\"", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"line\"", ")", ",", "3", ")", ";", "assertEquals", "(", "result", ".", "get", "(", "\"column\"", ")", ",", "10", ")", ";", "}", "}", "</s>" ]
1,494
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "util", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "io", ".", "InputStream", ";", "import", "java", ".", "io", ".", "OutputStream", ";", "import", "java", ".", "net", ".", "URL", ";", "import", "java", ".", "net", ".", "URLConnection", ";", "import", "java", ".", "net", ".", "URLDecoder", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "regex", ".", "Pattern", ";", "import", "javax", ".", "xml", ".", "parsers", ".", "SAXParser", ";", "import", "javax", ".", "xml", ".", "parsers", ".", "SAXParserFactory", ";", "import", "javax", ".", "xml", ".", "xpath", ".", "XPath", ";", "import", "javax", ".", "xml", ".", "xpath", ".", "XPathExpression", ";", "import", "javax", ".", "xml", ".", "xpath", ".", "XPathFactory", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang", ".", "SystemUtils", ";", "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", ".", "command", ".", "Error", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "util", ".", "ProjectUtils", ";", "import", "org", ".", "eclim", ".", "util", ".", "IOUtils", ";", "import", "org", ".", "eclim", ".", "util", ".", "file", ".", "FileUtils", ";", "import", "org", ".", "w3c", ".", "dom", ".", "Element", ";", "import", "org", ".", "xml", ".", "sax", ".", "Attributes", ";", "import", "org", ".", "xml", ".", "sax", ".", "InputSource", ";", "import", "org", ".", "xml", ".", "sax", ".", "Locator", ";", "import", "org", ".", "xml", ".", "sax", ".", "SAXException", ";", "import", "org", ".", "xml", ".", "sax", ".", "SAXParseException", ";", "import", "org", ".", "xml", ".", "sax", ".", "helpers", ".", "DefaultHandler", ";", "public", "class", "XmlUtils", "{", "private", "static", "final", "Pattern", "WIN_BUG", "=", "Pattern", ".", "compile", "(", "\"\"", ")", ";", "private", "static", "XPath", "XPATH", ";", "public", "static", "XPathExpression", "createXPathExpression", "(", "String", "xpath", ")", "throws", "Exception", "{", "if", "(", "XPATH", "==", "null", ")", "{", "XPATH", "=", "XPathFactory", ".", "newInstance", "(", ")", ".", "newXPath", "(", ")", ";", "}", "return", "XPATH", ".", "compile", "(", "xpath", ")", ";", "}", "public", "static", "List", "<", "Error", ">", "validateXml", "(", "String", "project", ",", "String", "filename", ")", "throws", "Exception", "{", "return", "validateXml", "(", "project", ",", "filename", ",", "false", ",", "null", ")", ";", "}", "public", "static", "List", "<", "Error", ">", "validateXml", "(", "String", "project", ",", "String", "filename", ",", "boolean", "schema", ")", "throws", "Exception", "{", "return", "validateXml", "(", "project", ",", "filename", ",", "schema", ",", "null", ")", ";", "}", "public", "static", "List", "<", "Error", ">", "validateXml", "(", "String", "project", ",", "String", "filename", ",", "boolean", "schema", ",", "DefaultHandler", "handler", ")", "throws", "Exception", "{", "SAXParserFactory", "factory", "=", "SAXParserFactory", ".", "newInstance", "(", ")", ";", "factory", ".", "setNamespaceAware", "(", "true", ")", ";", "factory", ".", "setValidating", "(", "true", ")", ";", "if", "(", "schema", ")", "{", "factory", ".", "setFeature", "(", "\"\"", ",", "true", ")", ";", "factory", ".", "setFeature", "(", "\"\"", ",", "true", ")", ";", "}", "SAXParser", "parser", "=", "factory", ".", "newSAXParser", "(", ")", ";", "filename", "=", "ProjectUtils", ".", "getFilePath", "(", "project", ",", "filename", ")", ";", "filename", "=", "filename", ".", "replace", "(", "'\\\\'", ",", "'/'", ")", ";", "ErrorAggregator", "errorHandler", "=", "new", "ErrorAggregator", "(", "filename", ")", ";", "EntityResolver", "entityResolver", "=", "new", "EntityResolver", "(", "FileUtils", ".", "getFullPath", "(", "filename", ")", ")", ";", "try", "{", "parser", ".", "parse", "(", "new", "File", "(", "filename", ")", ",", "getHandler", "(", "handler", ",", "errorHandler", ",", "entityResolver", ")", ")", ";", "}", "catch", "(", "SAXParseException", "spe", ")", "{", "ArrayList", "<", "Error", ">", "errors", "=", "new", "ArrayList", "<", "Error", ">", "(", ")", ";", "errors", ".", "add", "(", "new", "Error", "(", "spe", ".", "getMessage", "(", ")", ",", "filename", ",", "spe", ".", "getLineNumber", "(", ")", ",", "spe", ".", "getColumnNumber", "(", ")", ",", "false", ")", ")", ";", "return", "errors", ";", "}", "return", "errorHandler", ".", "getErrors", "(", ")", ";", "}", "public", "static", "List", "<", "Error", ">", "validateXml", "(", "String", "project", ",", "String", "filename", ",", "String", "schema", ")", "throws", "Exception", "{", "SAXParserFactory", "factory", "=", "SAXParserFactory", ".", "newInstance", "(", ")", ";", "factory", ".", "setNamespaceAware", "(", "true", ")", ";", "factory", ".", "setValidating", "(", "true", ")", ";", "factory", ".", "setFeature", "(", "\"\"", ",", "true", ")", ";", "factory", ".", "setFeature", "(", "\"\"", ",", "true", ")", ";", "SAXParser", "parser", "=", "factory", ".", "newSAXParser", "(", ")", ";", "parser", ".", "setProperty", "(", "\"\"", ",", "\"\"", ")", ";", "if", "(", "!", "schema", ".", "startsWith", "(", "\"file:\"", ")", ")", "{", "schema", "=", "\"file://\"", "+", "schema", ";", "}", "parser", ".", "setProperty", "(", "\"\"", ",", "schema", ")", ";", "parser", ".", "setProperty", "(", "\"\"", ",", "schema", ".", "replace", "(", "'\\\\'", ",", "'/'", ")", ")", ";", "filename", "=", "ProjectUtils", ".", "getFilePath", "(", "project", ",", "filename", ")", ";", "filename", "=", "filename", ".", "replace", "(", "'\\\\'", ",", "'/'", ")", ";", "ErrorAggregator", "errorHandler", "=", "new", "ErrorAggregator", "(", "filename", ")", ";", "EntityResolver", "entityResolver", "=", "new", "EntityResolver", "(", "FileUtils", ".", "getFullPath", "(", "filename", ")", ")", ";", "try", "{", "parser", ".", "parse", "(", "new", "File", "(", "filename", ")", ",", "getHandler", "(", "null", ",", "errorHandler", ",", "entityResolver", ")", ")", ";", "}", "catch", "(", "SAXParseException", "spe", ")", "{", "ArrayList", "<", "Error", ">", "errors", "=", "new", "ArrayList", "<", "Error", ">", "(", ")", ";", "errors", ".", "add", "(", "new", "Error", "(", "spe", ".", "getMessage", "(", ")", ",", "filename", ",", "spe", ".", "getLineNumber", "(", ")", ",", "spe", ".", "getColumnNumber", "(", ")", ",", "false", ")", ")", ";", "return", "errors", ";", "}", "return", "errorHandler", ".", "getErrors", "(", ")", ";", "}", "public", "static", "String", "getElementValue", "(", "Element", "element", ",", "String", "name", ")", "{", "return", "(", "(", "Element", ")", "element", ".", "getElementsByTagName", "(", "name", ")", ".", "item", "(", "0", ")", ")", ".", "getFirstChild", "(", ")", ".", "getNodeValue", "(", ")", ";", "}", "private", "static", "DefaultHandler", "getHandler", "(", "DefaultHandler", "handler", ",", "DefaultHandler", "errorHandler", ",", "EntityResolver", "entityResolver", ")", "{", "DefaultHandler", "hdlr", "=", "handler", "!=", "null", "?", "handler", ":", "new", "DefaultHandler", "(", ")", ";", "return", "new", "AggregateHandler", "(", "hdlr", ",", "errorHandler", ",", "entityResolver", ")", ";", "}", "private", "static", "class", "AggregateHandler", "extends", "DefaultHandler", "{", "private", "DefaultHandler", "handler", ";", "private", "DefaultHandler", "errorHandler", ";", "private", "org", ".", "xml", ".", "sax", ".", "EntityResolver", "entityResolver", ";", "public", "AggregateHandler", "(", "DefaultHandler", "handler", ",", "DefaultHandler", "errorHandler", ",", "EntityResolver", "entityResolver", ")", "{", "this", ".", "handler", "=", "handler", ";", "this", ".", "errorHandler", "=", "errorHandler", "!=", "null", "?", "errorHandler", ":", "handler", ";", "this", ".", "entityResolver", "=", "entityResolver", "!=", "null", "?", "entityResolver", ":", "handler", ";", "}", "public", "InputSource", "resolveEntity", "(", "String", "publicId", ",", "String", "systemId", ")", "throws", "IOException", ",", "SAXException", "{", "return", "entityResolver", ".", "resolveEntity", "(", "publicId", ",", "systemId", ")", ";", "}", "public", "void", "notationDecl", "(", "String", "name", ",", "String", "publicId", ",", "String", "systemId", ")", "throws", "SAXException", "{", "handler", ".", "notationDecl", "(", "name", ",", "publicId", ",", "systemId", ")", ";", "}", "public", "void", "unparsedEntityDecl", "(", "String", "name", ",", "String", "publicId", ",", "String", "systemId", ",", "String", "notationName", ")", "throws", "SAXException", "{", "handler", ".", "unparsedEntityDecl", "(", "name", ",", "publicId", ",", "systemId", ",", "notationName", ")", ";", "}", "public", "void", "setDocumentLocator", "(", "Locator", "locator", ")", "{", "handler", ".", "setDocumentLocator", "(", "locator", ")", ";", "}", "public", "void", "startDocument", "(", ")", "throws", "SAXException", "{", "handler", ".", "startDocument", "(", ")", ";", "}", "public", "void", "endDocument", "(", ")", "throws", "SAXException", "{", "handler", ".", "endDocument", "(", ")", ";", "}", "public", "void", "startPrefixMapping", "(", "String", "prefix", ",", "String", "uri", ")", "throws", "SAXException", "{", "handler", ".", "startPrefixMapping", "(", "prefix", ",", "uri", ")", ";", "}", "public", "void", "endPrefixMapping", "(", "String", "prefix", ")", "throws", "SAXException", "{", "handler", ".", "endPrefixMapping", "(", "prefix", ")", ";", "}", "public", "void", "startElement", "(", "String", "uri", ",", "String", "localName", ",", "String", "qName", ",", "Attributes", "attributes", ")", "throws", "SAXException", "{", "handler", ".", "startElement", "(", "uri", ",", "localName", ",", "qName", ",", "attributes", ")", ";", "}", "public", "void", "endElement", "(", "String", "uri", ",", "String", "localName", ",", "String", "qName", ")", "throws", "SAXException", "{", "handler", ".", "endElement", "(", "uri", ",", "localName", ",", "qName", ")", ";", "}", "public", "void", "characters", "(", "char", "[", "]", "ch", ",", "int", "start", ",", "int", "length", ")", "throws", "SAXException", "{", "handler", ".", "characters", "(", "ch", ",", "start", ",", "length", ")", ";", "}", "public", "void", "ignorableWhitespace", "(", "char", "[", "]", "ch", ",", "int", "start", ",", "int", "length", ")", "throws", "SAXException", "{", "handler", ".", "ignorableWhitespace", "(", "ch", ",", "start", ",", "length", ")", ";", "}", "public", "void", "processingInstruction", "(", "String", "target", ",", "String", "data", ")", "throws", "SAXException", "{", "handler", ".", "processingInstruction", "(", "target", ",", "data", ")", ";", "}", "public", "void", "skippedEntity", "(", "String", "name", ")", "throws", "SAXException", "{", "handler", ".", "skippedEntity", "(", "name", ")", ";", "}", "public", "void", "warning", "(", "SAXParseException", "e", ")", "throws", "SAXException", "{", "errorHandler", ".", "warning", "(", "e", ")", ";", "}", "public", "void", "error", "(", "SAXParseException", "e", ")", "throws", "SAXException", "{", "errorHandler", ".", "error", "(", "e", ")", ";", "}", "public", "void", "fatalError", "(", "SAXParseException", "e", ")", "throws", "SAXException", "{", "errorHandler", ".", "fatalError", "(", "e", ")", ";", "}", "}", "private", "static", "class", "ErrorAggregator", "extends", "DefaultHandler", "{", "private", "ArrayList", "<", "Error", ">", "errors", "=", "new", "ArrayList", "<", "Error", ">", "(", ")", ";", "private", "String", "filename", ";", "public", "ErrorAggregator", "(", "String", "filename", ")", "{", "this", ".", "filename", "=", "filename", ";", "}", "public", "void", "warning", "(", "SAXParseException", "ex", ")", "throws", "SAXException", "{", "addError", "(", "ex", ",", "true", ")", ";", "}", "public", "void", "error", "(", "SAXParseException", "ex", ")", "throws", "SAXException", "{", "addError", "(", "ex", ",", "false", ")", ";", "}", "public", "void", "fatalError", "(", "SAXParseException", "ex", ")", "throws", "SAXException", "{", "addError", "(", "ex", ",", "false", ")", ";", "}", "private", "void", "addError", "(", "SAXParseException", "ex", ",", "boolean", "warning", ")", "{", "String", "location", "=", "ex", ".", "getSystemId", "(", ")", ";", "if", "(", "location", "!=", "null", ")", "{", "if", "(", "location", ".", "startsWith", "(", "\"file://\"", ")", ")", "{", "location", "=", "location", ".", "substring", "(", "\"file://\"", ".", "length", "(", ")", ")", ";", "}", "else", "if", "(", "location", ".", "startsWith", "(", "\"file:\"", ")", ")", "{", "location", "=", "location", ".", "substring", "(", "\"file:\"", ".", "length", "(", ")", ")", ";", "}", "}", "if", "(", "location", "!=", "null", "&&", "WIN_BUG", ".", "matcher", "(", "location", ")", ".", "matches", "(", ")", ")", "{", "location", "=", "location", ".", "substring", "(", "1", ")", ";", "}", "if", "(", "location", "==", "null", ")", "{", "location", "=", "filename", ";", "}", "try", "{", "errors", ".", "add", "(", "new", "Error", "(", "ex", ".", "getMessage", "(", ")", ",", "URLDecoder", ".", "decode", "(", "location", ",", "\"utf-8\"", ")", ",", "ex", ".", "getLineNumber", "(", ")", ",", "ex", ".", "getColumnNumber", "(", ")", ",", "warning", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "}", "public", "List", "<", "Error", ">", "getErrors", "(", ")", "{", "return", "errors", ";", "}", "}", "private", "static", "class", "EntityResolver", "implements", "org", ".", "xml", ".", "sax", ".", "EntityResolver", "{", "private", "static", "String", "TEMP_PREFIX", "=", "\"file://\"", "+", "SystemUtils", ".", "JAVA_IO_TMPDIR", ".", "replace", "(", "'\\\\'", ",", "'/'", ")", ";", "static", "{", "if", "(", "TEMP_PREFIX", ".", "endsWith", "(", "\"\\\\\"", ")", "||", "TEMP_PREFIX", ".", "endsWith", "(", "\"/\"", ")", ")", "{", "TEMP_PREFIX", "=", "TEMP_PREFIX", ".", "substring", "(", "0", ",", "TEMP_PREFIX", ".", "length", "(", ")", "-", "1", ")", ";", "}", "}", "private", "String", "path", ";", "private", "String", "lastPath", ";", "private", "HashMap", "<", "String", ",", "IOException", ">", "missingSources", "=", "new", "HashMap", "<", "String", ",", "IOException", ">", "(", ")", ";", "public", "EntityResolver", "(", "String", "path", ")", "{", "this", ".", "path", "=", "path", ";", "}", "public", "InputSource", "resolveEntity", "(", "String", "publicId", ",", "String", "systemId", ")", "throws", "SAXException", ",", "IOException", "{", "String", "location", "=", "systemId", ";", "location", "=", "location", ".", "replaceFirst", "(", "\"\"", ",", "\"file://$1:/\"", ")", ";", "if", "(", "location", ".", "startsWith", "(", "TEMP_PREFIX", ")", ")", "{", "location", "=", "location", ".", "substring", "(", "TEMP_PREFIX", ".", "length", "(", ")", ")", ";", "return", "resolveEntity", "(", "publicId", ",", "lastPath", "+", "location", ")", ";", "}", "else", "if", "(", "location", ".", "startsWith", "(", "\"http://\"", ")", ")", "{", "if", "(", "missingSources", ".", "containsKey", "(", "systemId", ")", ")", "{", "throw", "missingSources", ".", "get", "(", "systemId", ")", ";", "}", "int", "index", "=", "location", ".", "indexOf", "(", "'/'", ",", "8", ")", ";", "lastPath", "=", "location", ".", "substring", "(", "0", ",", "index", "+", "1", ")", ";", "location", "=", "location", ".", "substring", "(", "index", ")", ";", "location", "=", "TEMP_PREFIX", "+", "location", ";", "FileSystemManager", "fsManager", "=", "VFS", ".", "getManager", "(", ")", ";", "FileObject", "tempFile", "=", "fsManager", ".", "resolveFile", "(", "location", ")", ";", "if", "(", "!", "tempFile", ".", "exists", "(", ")", "||", "tempFile", ".", "getContent", "(", ")", ".", "getSize", "(", ")", "==", "0", ")", "{", "InputStream", "in", "=", "null", ";", "OutputStream", "out", "=", "null", ";", "try", "{", "if", "(", "!", "tempFile", ".", "exists", "(", ")", ")", "{", "tempFile", ".", "createFile", "(", ")", ";", "}", "URL", "remote", "=", "new", "URL", "(", "systemId", ")", ";", "URLConnection", "conn", "=", "remote", ".", "openConnection", "(", ")", ";", "conn", ".", "setConnectTimeout", "(", "5000", ")", ";", "conn", ".", "setReadTimeout", "(", "10000", ")", ";", "conn", ".", "connect", "(", ")", ";", "in", "=", "conn", ".", "getInputStream", "(", ")", ";", "out", "=", "tempFile", ".", "getContent", "(", ")", ".", "getOutputStream", "(", ")", ";", "IOUtils", ".", "copy", "(", "in", ",", "out", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "IOUtils", ".", "closeQuietly", "(", "out", ")", ";", "try", "{", "tempFile", ".", "delete", "(", ")", ";", "}", "catch", "(", "Exception", "ignore", ")", "{", "}", "IOException", "ex", "=", "new", "IOException", "(", "e", ".", "getMessage", "(", ")", ")", ";", "ex", ".", "initCause", "(", "e", ")", ";", "missingSources", ".", "put", "(", "systemId", ",", "ex", ")", ";", "throw", "ex", ";", "}", "finally", "{", "IOUtils", ".", "closeQuietly", "(", "in", ")", ";", "IOUtils", ".", "closeQuietly", "(", "out", ")", ";", "}", "}", "InputSource", "source", "=", "new", "InputSource", "(", "tempFile", ".", "getContent", "(", ")", ".", "getInputStream", "(", ")", ")", ";", "source", ".", "setSystemId", "(", "location", ")", ";", "return", "source", ";", "}", "else", "if", "(", "location", ".", "startsWith", "(", "\"file:\"", ")", ")", "{", "location", "=", "location", ".", "substring", "(", "\"file:\"", ".", "length", "(", ")", ")", ";", "if", "(", "location", ".", "startsWith", "(", "\"//\"", ")", ")", "{", "location", "=", "location", ".", "substring", "(", "2", ")", ";", "}", "if", "(", "FileUtils", ".", "getFullPath", "(", "location", ")", ".", "equals", "(", "FileUtils", ".", "getPath", "(", "location", ")", ")", ")", "{", "location", "=", "FileUtils", ".", "concat", "(", "path", ",", "location", ")", ";", "}", "if", "(", "!", "new", "File", "(", "location", ")", ".", "exists", "(", ")", ")", "{", "StringBuffer", "resource", "=", "new", "StringBuffer", "(", ")", ".", "append", "(", "\"/resources/\"", ")", ".", "append", "(", "FileUtils", ".", "getExtension", "(", "location", ")", ")", ".", "append", "(", "'/'", ")", ".", "append", "(", "FileUtils", ".", "getFileName", "(", "location", ")", ")", ".", "append", "(", "'.'", ")", ".", "append", "(", "FileUtils", ".", "getExtension", "(", "location", ")", ")", ";", "URL", "url", "=", "Services", ".", "getResource", "(", "resource", ".", "toString", "(", ")", ")", ";", "if", "(", "url", "!=", "null", ")", "{", "return", "new", "InputSource", "(", "url", ".", "toString", "(", ")", ")", ";", "}", "}", "return", "new", "InputSource", "(", "location", ")", ";", "}", "return", "new", "InputSource", "(", "systemId", ")", ";", "}", "}", "}", "</s>" ]
1,495
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "util", ";", "import", "org", ".", "eclim", ".", "util", ".", "file", ".", "FileUtils", ";", "import", "org", ".", "eclim", ".", "util", ".", "file", ".", "Position", ";", "public", "class", "VimUtils", "{", "public", "static", "final", "String", "DEFAULT_LINE_COL", "=", "\"1", "col", "1\"", ";", "public", "static", "String", "translateLineColumn", "(", "String", "filename", ",", "int", "offset", ")", "throws", "Exception", "{", "if", "(", "offset", ">=", "0", ")", "{", "int", "[", "]", "pos", "=", "FileUtils", ".", "offsetToLineColumn", "(", "filename", ",", "offset", ")", ";", "if", "(", "pos", "!=", "null", ")", "{", "return", "pos", "[", "0", "]", "+", "\"", "col", "\"", "+", "pos", "[", "1", "]", ";", "}", "}", "return", "\"1", "col", "1\"", ";", "}", "public", "static", "String", "translateLineColumn", "(", "Position", "position", ")", "throws", "Exception", "{", "if", "(", "position", ".", "getOffset", "(", ")", "!=", "-", "1", ")", "{", "int", "[", "]", "pos", "=", "FileUtils", ".", "offsetToLineColumn", "(", "position", ".", "getFilename", "(", ")", ",", "position", ".", "getOffset", "(", ")", ")", ";", "if", "(", "pos", "!=", "null", ")", "{", "return", "pos", "[", "0", "]", "+", "\"", "col", "\"", "+", "pos", "[", "1", "]", ";", "}", "}", "return", "\"1", "col", "1\"", ";", "}", "}", "</s>" ]
1,496
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "util", ";", "import", "java", ".", "io", ".", "File", ";", "import", "org", ".", "eclim", ".", "Services", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "preference", ".", "Preferences", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "project", ".", "ProjectManagement", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "project", ".", "ProjectManager", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "project", ".", "ProjectNatureFactory", ";", "import", "org", ".", "eclipse", ".", "core", ".", "filebuffers", ".", "FileBuffers", ";", "import", "org", ".", "eclipse", ".", "core", ".", "filebuffers", ".", "ITextFileBuffer", ";", "import", "org", ".", "eclipse", ".", "core", ".", "filebuffers", ".", "ITextFileBufferManager", ";", "import", "org", ".", "eclipse", ".", "core", ".", "filebuffers", ".", "LocationKind", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "IFile", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "IProject", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "IResource", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "ResourcesPlugin", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "IPath", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "NullProgressMonitor", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "Path", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "text", ".", "IDocument", ";", "public", "class", "ProjectUtils", "{", "public", "static", "String", "getPath", "(", "String", "project", ")", "throws", "Exception", "{", "return", "getPath", "(", "getProject", "(", "project", ")", ")", ";", "}", "public", "static", "String", "getPath", "(", "IProject", "project", ")", "throws", "Exception", "{", "IPath", "path", "=", "getIPath", "(", "project", ")", ";", "return", "path", "!=", "null", "?", "path", ".", "toOSString", "(", ")", ".", "replace", "(", "'\\\\'", ",", "'/'", ")", ":", "null", ";", "}", "public", "static", "IPath", "getIPath", "(", "IProject", "project", ")", "throws", "Exception", "{", "IPath", "path", "=", "project", ".", "getRawLocation", "(", ")", ";", "if", "(", "path", "==", "null", ")", "{", "String", "name", "=", "project", ".", "getName", "(", ")", ";", "path", "=", "ResourcesPlugin", ".", "getWorkspace", "(", ")", ".", "getRoot", "(", ")", ".", "getRawLocation", "(", ")", ";", "path", "=", "path", ".", "append", "(", "name", ")", ";", "}", "return", "path", ";", "}", "public", "static", "IProject", "getProject", "(", "String", "name", ")", "throws", "Exception", "{", "return", "getProject", "(", "name", ",", "false", ")", ";", "}", "public", "static", "IProject", "getProject", "(", "String", "name", ",", "boolean", "open", ")", "throws", "Exception", "{", "IProject", "project", "=", "ResourcesPlugin", ".", "getWorkspace", "(", ")", ".", "getRoot", "(", ")", ".", "getProject", "(", "name", ")", ";", "if", "(", "open", "&&", "project", ".", "exists", "(", ")", "&&", "!", "project", ".", "isOpen", "(", ")", ")", "{", "project", ".", "open", "(", "null", ")", ";", "}", "return", "project", ";", "}", "public", "static", "String", "getFilePath", "(", "String", "project", ",", "String", "file", ")", "throws", "Exception", "{", "return", "getFilePath", "(", "getProject", "(", "project", ")", ",", "file", ")", ";", "}", "public", "static", "String", "getFilePath", "(", "IProject", "project", ",", "String", "file", ")", "throws", "Exception", "{", "file", "=", "file", ".", "replace", "(", "'\\\\'", ",", "'/'", ")", ";", "if", "(", "file", ".", "startsWith", "(", "\"/\"", "+", "project", ".", "getName", "(", ")", ")", ")", "{", "if", "(", "file", ".", "startsWith", "(", "\"/\"", "+", "project", ".", "getName", "(", ")", "+", "\"/\"", ")", ")", "{", "file", "=", "file", ".", "substring", "(", "2", "+", "project", ".", "getName", "(", ")", ".", "length", "(", ")", ")", ";", "}", "else", "if", "(", "file", ".", "endsWith", "(", "\"/\"", "+", "project", ".", "getName", "(", ")", ")", ")", "{", "file", "=", "file", ".", "substring", "(", "1", "+", "project", ".", "getName", "(", ")", ".", "length", "(", ")", ")", ";", "}", "if", "(", "file", ".", "length", "(", ")", "==", "0", ")", "{", "return", "getPath", "(", "project", ")", ";", "}", "}", "else", "if", "(", "file", ".", "startsWith", "(", "\"/\"", ")", "||", "file", ".", "toLowerCase", "(", ")", ".", "startsWith", "(", "\"jar:\"", ")", "||", "file", ".", "toLowerCase", "(", ")", ".", "startsWith", "(", "\"zip:\"", ")", ")", "{", "return", "file", ";", "}", "String", "projectPath", "=", "getPath", "(", "project", ")", ";", "if", "(", "file", ".", "toLowerCase", "(", ")", ".", "startsWith", "(", "projectPath", ".", "toLowerCase", "(", ")", ")", ")", "{", "return", "file", ";", "}", "IFile", "ifile", "=", "project", ".", "getFile", "(", "file", ")", ";", "return", "ifile", ".", "getLocation", "(", ")", ".", "toOSString", "(", ")", ".", "replace", "(", "'\\\\'", ",", "'/'", ")", ";", "}", "public", "static", "IFile", "getFile", "(", "String", "project", ",", "String", "file", ")", "throws", "Exception", "{", "return", "getFile", "(", "getProject", "(", "project", ")", ",", "file", ")", ";", "}", "public", "static", "IFile", "getFile", "(", "IProject", "project", ",", "String", "file", ")", "throws", "Exception", "{", "if", "(", "!", "project", ".", "isOpen", "(", ")", ")", "{", "project", ".", "open", "(", "null", ")", ";", "}", "String", "path", "=", "getPath", "(", "project", ")", ";", "path", "=", "path", ".", "replace", "(", "'\\\\'", ",", "'/'", ")", ";", "IFile", "ifile", "=", "project", ".", "getFile", "(", "file", ")", ";", "ifile", ".", "refreshLocal", "(", "IResource", ".", "DEPTH_INFINITE", ",", "null", ")", ";", "String", "[", "]", "natures", "=", "ProjectNatureFactory", ".", "getProjectNatures", "(", "project", ")", ";", "for", "(", "String", "nature", ":", "natures", ")", "{", "ProjectManager", "manager", "=", "ProjectManagement", ".", "getProjectManager", "(", "nature", ")", ";", "if", "(", "manager", "!=", "null", ")", "{", "manager", ".", "refresh", "(", "project", ",", "ifile", ")", ";", "}", "}", "return", "ifile", ";", "}", "public", "static", "IDocument", "getDocument", "(", "String", "project", ",", "String", "file", ")", "throws", "Exception", "{", "return", "getDocument", "(", "getProject", "(", "project", ")", ",", "file", ")", ";", "}", "public", "static", "IDocument", "getDocument", "(", "IProject", "project", ",", "String", "file", ")", "throws", "Exception", "{", "File", "thefile", "=", "new", "File", "(", "getFilePath", "(", "project", ",", "file", ")", ")", ";", "if", "(", "!", "thefile", ".", "exists", "(", ")", ")", "{", "return", "null", ";", "}", "ITextFileBufferManager", "manager", "=", "FileBuffers", ".", "getTextFileBufferManager", "(", ")", ";", "IPath", "location", "=", "new", "Path", "(", "thefile", ".", "getAbsolutePath", "(", ")", ")", ";", "boolean", "connected", "=", "false", ";", "try", "{", "ITextFileBuffer", "buffer", "=", "manager", ".", "getTextFileBuffer", "(", "location", ",", "LocationKind", ".", "LOCATION", ")", ";", "if", "(", "buffer", "==", "null", ")", "{", "manager", ".", "connect", "(", "location", ",", "LocationKind", ".", "LOCATION", ",", "new", "NullProgressMonitor", "(", ")", ")", ";", "connected", "=", "true", ";", "buffer", "=", "manager", ".", "getTextFileBuffer", "(", "location", ",", "LocationKind", ".", "LOCATION", ")", ";", "if", "(", "buffer", "==", "null", ")", "{", "return", "null", ";", "}", "}", "return", "buffer", ".", "getDocument", "(", ")", ";", "}", "finally", "{", "if", "(", "connected", ")", "{", "try", "{", "manager", ".", "disconnect", "(", "location", ",", "LocationKind", ".", "LOCATION", ",", "new", "NullProgressMonitor", "(", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "}", "}", "}", "}", "public", "static", "void", "closeQuietly", "(", "IProject", "project", ")", "{", "try", "{", "if", "(", "project", "!=", "null", ")", "{", "project", ".", "close", "(", "null", ")", ";", "}", "}", "catch", "(", "Exception", "ignore", ")", "{", "}", "}", "public", "static", "void", "assertExists", "(", "IProject", "project", ")", "throws", "Exception", "{", "if", "(", "project", "==", "null", "||", "!", "project", ".", "exists", "(", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "Services", ".", "getMessage", "(", "\"\"", ",", "project", "!=", "null", "?", "project", ".", "getName", "(", ")", ":", "null", ")", ")", ";", "}", "}", "}", "</s>" ]
1,497
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "core", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "io", ".", "FilenameFilter", ";", "import", "org", ".", "eclim", ".", "Services", ";", "import", "org", ".", "eclim", ".", "eclipse", ".", "EclimDaemon", ";", "import", "org", ".", "eclim", ".", "eclipse", ".", "EclimPlugin", ";", "import", "org", ".", "eclim", ".", "logging", ".", "Logger", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "Plugin", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "IResourceChangeEvent", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "IResourceChangeListener", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "ResourcesPlugin", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "Platform", ";", "import", "org", ".", "osgi", ".", "framework", ".", "Bundle", ";", "import", "org", ".", "osgi", ".", "framework", ".", "BundleContext", ";", "import", "org", ".", "osgi", ".", "framework", ".", "BundleException", ";", "import", "org", ".", "osgi", ".", "framework", ".", "FrameworkEvent", ";", "public", "class", "CorePlugin", "extends", "Plugin", "implements", "IResourceChangeListener", "{", "private", "static", "final", "Logger", "logger", "=", "Logger", ".", "getLogger", "(", "CorePlugin", ".", "class", ")", ";", "private", "String", "[", "]", "plugins", ";", "private", "boolean", "building", ";", "private", "static", "CorePlugin", "plugin", ";", "public", "CorePlugin", "(", ")", "{", "plugin", "=", "this", ";", "}", "public", "static", "CorePlugin", "getDefault", "(", ")", "{", "return", "plugin", ";", "}", "public", "void", "activate", "(", "BundleContext", "context", ")", "{", "super", ".", "activate", "(", "context", ")", ";", "logger", ".", "info", "(", "\"\"", ")", ";", "String", "pluginsDir", "=", "System", ".", "getProperty", "(", "\"eclim.home\"", ")", "+", "File", ".", "separator", "+", "\"..\"", "+", "File", ".", "separator", ";", "String", "[", "]", "pluginDirs", "=", "new", "File", "(", "pluginsDir", ")", ".", "list", "(", "new", "FilenameFilter", "(", ")", "{", "public", "boolean", "accept", "(", "File", "dir", ",", "String", "name", ")", "{", "if", "(", "name", ".", "startsWith", "(", "\"org.eclim.\"", ")", "&&", "name", ".", "indexOf", "(", "\"core\"", ")", "==", "-", "1", "&&", "name", ".", "indexOf", "(", "\"installer\"", ")", "==", "-", "1", "&&", "name", ".", "indexOf", "(", "\"vimplugin\"", ")", "==", "-", "1", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}", "}", ")", ";", "plugins", "=", "new", "String", "[", "pluginDirs", ".", "length", "]", ";", "for", "(", "int", "ii", "=", "0", ";", "ii", "<", "pluginDirs", ".", "length", ";", "ii", "++", ")", "{", "plugins", "[", "ii", "]", "=", "pluginDirs", "[", "ii", "]", ".", "substring", "(", "0", ",", "pluginDirs", "[", "ii", "]", ".", "lastIndexOf", "(", "'_'", ")", ")", ";", "}", "for", "(", "String", "plugin", ":", "plugins", ")", "{", "logger", ".", "info", "(", "\"\"", "+", "plugin", ")", ";", "Bundle", "bundle", "=", "Platform", ".", "getBundle", "(", "plugin", ")", ";", "if", "(", "bundle", "==", "null", ")", "{", "String", "diagnosis", "=", "EclimPlugin", ".", "getDefault", "(", ")", ".", "diagnose", "(", "plugin", ")", ";", "String", "message", "=", "Services", ".", "getMessage", "(", "\"\"", ",", "plugin", ",", "diagnosis", ")", ";", "logger", ".", "error", "(", "message", ")", ";", "}", "else", "{", "try", "{", "bundle", ".", "start", "(", "Bundle", ".", "START_TRANSIENT", ")", ";", "}", "catch", "(", "BundleException", "be", ")", "{", "logger", ".", "error", "(", "\"\"", "+", "bundle", ".", "getSymbolicName", "(", ")", ",", "be", ")", ";", "}", "}", "}", "ResourcesPlugin", ".", "getWorkspace", "(", ")", ".", "addResourceChangeListener", "(", "this", ",", "IResourceChangeEvent", ".", "PRE_BUILD", "|", "IResourceChangeEvent", ".", "POST_BUILD", ")", ";", "logger", ".", "info", "(", "\"\"", ")", ";", "EclimDaemon", ".", "getInstance", "(", ")", ".", "frameworkEvent", "(", "new", "FrameworkEvent", "(", "FrameworkEvent", ".", "INFO", ",", "getBundle", "(", ")", ",", "null", ")", ")", ";", "}", "public", "void", "stop", "(", "BundleContext", "context", ")", "throws", "Exception", "{", "super", ".", "stop", "(", "context", ")", ";", "for", "(", "String", "plugin", ":", "plugins", ")", "{", "logger", ".", "info", "(", "\"\"", "+", "plugin", ")", ";", "Bundle", "bundle", "=", "Platform", ".", "getBundle", "(", "plugin", ")", ";", "if", "(", "bundle", "!=", "null", ")", "{", "bundle", ".", "stop", "(", ")", ";", "}", "}", "ResourcesPlugin", ".", "getWorkspace", "(", ")", ".", "removeResourceChangeListener", "(", "this", ")", ";", "}", "public", "void", "resourceChanged", "(", "IResourceChangeEvent", "event", ")", "{", "int", "type", "=", "event", ".", "getType", "(", ")", ";", "if", "(", "type", "==", "IResourceChangeEvent", ".", "PRE_BUILD", ")", "{", "logger", ".", "debug", "(", "\"\"", ")", ";", "building", "=", "true", ";", "}", "else", "if", "(", "type", "==", "IResourceChangeEvent", ".", "POST_BUILD", ")", "{", "logger", ".", "debug", "(", "\"\"", ")", ";", "building", "=", "false", ";", "}", "}", "public", "boolean", "isBuildRunning", "(", ")", "{", "return", "building", ";", "}", "}", "</s>" ]
1,498
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "core", ";", "import", "org", ".", "eclim", ".", "Services", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "AbstractPluginResources", ";", "import", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "preference", ".", "PreferenceFactory", ";", "public", "class", "PluginResources", "extends", "AbstractPluginResources", "{", "public", "static", "final", "String", "NAME", "=", "\"\"", ";", "@", "Override", "public", "void", "initialize", "(", "String", "name", ")", "{", "super", ".", "initialize", "(", "name", ")", ";", "PreferenceFactory", ".", "addPreferences", "(", "\"core\"", ",", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", ")", ";", "}", "protected", "String", "getBundleBaseName", "(", ")", "{", "return", "\"\"", ";", "}", "}", "</s>" ]
1,499
[ "<s>", "package", "org", ".", "eclim", ".", "plugin", ".", "core", ".", "preference", ";", "public", "class", "Preference", "extends", "Option", "{", "private", "String", "defaultValue", ";", "public", "String", "getDefaultValue", "(", ")", "{", "return", "this", ".", "defaultValue", "!=", "null", "?", "this", ".", "defaultValue", ":", "\"\"", ";", "}", "public", "void", "setDefaultValue", "(", "String", "defaultValue", ")", "{", "this", ".", "defaultValue", "=", "defaultValue", ";", "}", "}", "</s>" ]