From 051b166e76b8076ba10fdba73726406f1d8718ce Mon Sep 17 00:00:00 2001 From: Martin Oberhuber < martin.oberhuber@windriver.com> Date: Wed, 16 Aug 2006 12:05:37 +0000 Subject: [PATCH] [refactoring] 153273: move shell output parsing classes to rse.services.shells --- .../build.properties | 1 - .../patterns.dat | 268 ------------------ .../services/local/shells/OutputPattern.java | 98 ------- .../services/local/shells/Patterns.java | 120 -------- .../build.properties | 1 - .../services/ssh/shell/CommandPattern.java | 60 ---- .../rse/services/ssh/shell/ParsedOutput.java | 38 --- .../org.eclipse.rse.services/build.properties | 3 +- .../patterns.dat | 2 - .../org/eclipse/rse/services/Activator.java | 25 +- .../rse/services}/shells/CommandPattern.java | 2 +- .../rse/services/shells}/OutputPattern.java | 4 +- .../rse/services}/shells/ParsedOutput.java | 2 +- .../rse/services/shells}/Patterns.java | 7 +- .../local/model/LocalServiceCommandShell.java | 4 +- .../shells/ssh/SshServiceCommandShell.java | 4 +- 16 files changed, 34 insertions(+), 605 deletions(-) delete mode 100644 rse/plugins/org.eclipse.rse.services.local/patterns.dat delete mode 100644 rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/shells/OutputPattern.java delete mode 100644 rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/shells/Patterns.java delete mode 100644 rse/plugins/org.eclipse.rse.services.ssh/src/org/eclipse/rse/services/ssh/shell/CommandPattern.java delete mode 100644 rse/plugins/org.eclipse.rse.services.ssh/src/org/eclipse/rse/services/ssh/shell/ParsedOutput.java rename rse/plugins/{org.eclipse.rse.services.ssh => org.eclipse.rse.services}/patterns.dat (99%) rename rse/plugins/{org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local => org.eclipse.rse.services/src/org/eclipse/rse/services}/shells/CommandPattern.java (96%) rename rse/plugins/{org.eclipse.rse.services.ssh/src/org/eclipse/rse/services/ssh/shell => org.eclipse.rse.services/src/org/eclipse/rse/services/shells}/OutputPattern.java (96%) rename rse/plugins/{org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local => org.eclipse.rse.services/src/org/eclipse/rse/services}/shells/ParsedOutput.java (95%) rename rse/plugins/{org.eclipse.rse.services.ssh/src/org/eclipse/rse/services/ssh/shell => org.eclipse.rse.services/src/org/eclipse/rse/services/shells}/Patterns.java (96%) diff --git a/rse/plugins/org.eclipse.rse.services.local/build.properties b/rse/plugins/org.eclipse.rse.services.local/build.properties index fb306416172..1a2db36eb34 100644 --- a/rse/plugins/org.eclipse.rse.services.local/build.properties +++ b/rse/plugins/org.eclipse.rse.services.local/build.properties @@ -3,7 +3,6 @@ bin.includes = META-INF/,\ about.properties,\ plugin.properties,\ .,\ - patterns.dat,\ about.ini,\ about.mappings,\ eclipse32.png diff --git a/rse/plugins/org.eclipse.rse.services.local/patterns.dat b/rse/plugins/org.eclipse.rse.services.local/patterns.dat deleted file mode 100644 index 06ddc16388e..00000000000 --- a/rse/plugins/org.eclipse.rse.services.local/patterns.dat +++ /dev/null @@ -1,268 +0,0 @@ -# -# parse command line output. -# -# CLICK THIS LINE TO EDIT THIS FILE (PATTERNS.DAT). (When viewing from the Output view) - -command: grep -n.* - grep file line pattern =([\w,.,/,(,),\\,\-,\+,\d]*):(\d*):.* - -command: grep -.*n.* - grep file line pattern =([\w,.,/,(,),\\,\-,\+,\d]*):(\d*):.* - -command: grep .* - grep file pattern =([\w,.,/,(,)\\,\-,\+,\d]*):.* - - -command: pwd - directory file pattern=([\w,.,/,(,),\\,\-,\+,\d,:]*) - -command: nmake.* - error pattern=NMAKE : .* - error file line pattern =([\w,.,\-,\+,(,),\\,:]*)\((\d*):(\d*)\) : error EDC.* - error file pattern =[\w,.,\-,\+,(,),\\,:]*\(([\w,.,/,\\]*)\) : error LNK.* - error file line pattern=([\w,.,/,\-,\+,(,),\\]*):(\d*):\d*\) : error .* - warning file line pattern=([\w,.,/,\-,\+,(,),\\]*)\((\d*):\d*\) : warning .* - informational file line pattern=([\w,.,/,\-,\+,(,),\\]*)\((\d*):\d*\) : informational .* - -command: make.* - error file line pattern=\"([\w,.,/,(,),\-,\+,\\]*)\", line (\d*)\.\d*: \d*-\d* \(S\).* - error file line pattern=\"([\w,.,/,(,),\-,\+,\\]*)\",, line (\d*)\.\d*: \d*-\d* \(E\).* - warning file line pattern=\"([\w,.,/,(,),\-,\+,\\]*)\", line (\d*)\.\d*: \d*-\d* \(W\).* - informational file line pattern=\"([\w,.,/,(,),\-,\+,\\]*)\", line (\d*)\.\d*: \d*-\d* \(I\).* - warning file line pattern =([\w,.,/,(,),\-,\+,\\]*):(\d*): warning: .* - warning file line pattern =([\w,.,/,\\,\-,\+,(,)]*):(\d*):\d*: warning: .* - error file line pattern =([\w,.,/,\\,\-,\+,(,)]*):(\d*):.* - informational file pattern =([\w,.,/,\\,\-,\+,(,)]*):.* - informational file line pattern =In file included from ([\w,.,/,\\,\-,\+,(,)]*):(\d*): - #iseries c compiler - error file line pattern=[\w,.,/,\\]* Line \d* \"([\w,.,/,\\]*)\", line (\d*)\.\d*: .* - error file line pattern=([\w,.,/,\\]*) Line (\d*)\s.* - #makefile errors - error file line pattern=\"([\w,\.,/,(,),\-,\+,\\]*)\", line (\d*): make:.* - #xlc Options warnings - warning pattern=\(W\) Option .* - #c89 errors - error file line pattern=ERROR CBC\d* ([\w,.,/,\\,\-,\+,(,)]*):(\d*) .* - warning file line pattern=WARNING CBC\d* ([\w,.,/,\\,\-,\+,(,)]*):(\d*) .* - informational pattern=CBC\d*\(I\) .* - -command: gmake.* - error file line pattern=\"([\w,.,/,(,),\-,\+,\\]*)\", line (\d*)\.\d*: \d*-\d* \(S\).* - warning file line pattern=\"([\w,.,/,(,),\-,\+,\\]*)\", line (\d*)\.\d*: \d*-\d* \(W\).* - informational file line pattern=\"([\w,.,/,(,),\-,\+,\\]*)\", line (\d*)\.\d*: \d*-\d* \(I\).* - warning file line pattern =([\w,.,/,(,),\-,\+,\\]*):(\d*): warning: .* - warning file line pattern =([\w,.,/,\\,\-,\+,(,)]*):(\d*):\d*: warning: .* - informational file line pattern =In file included from ([\w,.,/,\\,\-,\+,(,)]*):(\d*): - # ixlc compiler - error file line pattern=[\w,.,/,\\]* Line \d* \"([\w,.,/,\\]*)\", line (\d*)\.\d*: .* - error file line pattern=([\w,.,/,\\]*) Line (\d*)\s.* - # icc compiler - error file line pattern =([\w,.,/,\\,\-,\+,(,)]*),\s(\d*)\.\d*:\s.* - error file line pattern =\"([\w,.,/,\\,\-,\+,(,)]*)\",\sline\s(\d*)\.\d*:\s.* - #generic - error file line pattern =([\w,.,/,\\,\-,\+,(,)]*):(\d*):.* - -command: gcc\s.* - error file line pattern=\"([\w,.,/,\\,\-,\+,(,)]*)\", line (\d*)\.\d*: \d*-\d* \(S\).* - warning file line pattern=\"([\w,.,/,\\,\-,\+,(,)]*)\", line (\d*)\.\d*: \d*-\d* \(W\).* - informational file line pattern=\"([\w,.,/,\\,\-,\+,(,)]*)\", line (\d*)\.\d*: \d*-\d* \(I\).* - warning file line pattern =([\w,.,/,\\,\-,\+,(,)]*):(\d*): warning: .* - warning file line pattern =([\w,.,/,\\,\-,\+,(,)]*):(\d*):\d*: warning: .* - error file line pattern =([\w,.,/,\\,\-,\+,(,)]*):(\d*):.* - informational file pattern =([\w,.,/,\\,\-,\+,(,)]*):.* - informational file line pattern =In file included from ([\w,.,/,\\,\-,\+,(,)]*):(\d*): - -command: cc\s.* - error file line pattern =([\w,.,/,\\,\-,\+,(,)]*):(\d*):.* - -command: CC\s.* - error file line pattern =([\w,.,/,\\,\-,\+,(,)]*):(\d*):.* - -command: c89.* - error file line pattern=ERROR CBC\d* ([\w,.,/,\\,\-,\+,(,)]*):(\d*) .* - warning file line pattern=WARNING CBC\d* ([\w,.,/,\\,\-,\+,(,)]*):(\d*) .* - informational pattern=CBC\d*\(I\) .* - -command: icc.* - error file line pattern =([\w,.,/,\\,\-,\+,(,)]*),\s(\d*)\.\d*:\s.* - error file line pattern =\"([\w,.,/,\\,\-,\+,(,)]*)\",\sline\s(\d*)\.\d*:\s.* - -command: javac.* - warning file line pattern=([\w,.,/,\\,\-,\+,(,),:]*):(\d*): warning.* - error file line pattern=([\w,.,/,\\,\-,\+,(,),:]*):(\d*):.* - -command: .*bat\s.* - error file line pattern=\[javac\]\s([\w,.,/,\\,:]*):(\d*):.* - error file line pattern=file:([\w,.,/,\\,:]*):(\d*):.* - -command: dir.* - directory file pattern=\d{2}/\d{2}/\d*\s*\d{2}:\d{2}\s[a,p,AM,PM]+\s*\s*([\w,.,/,\\,\s,\-,\+,\d]*).* - directory file pattern=.*\s*([\w,.,/,\\,\s,\-,\+,\d]*).* - file file pattern=\d{2}/\d{2}/\d*\s*\d{2}:\d{2}\s[a,p,AM,PM]+\s*[\d,,]*\s*([\w,.,/,\\,\s,\-,\+,\d]*).* - directory file pattern=[\d,/,\\,.,-]+.\s*\d{2}[:,.]\d{2}.\s*\s*([\w,.,/,\\,\s,\-,\+,\d]*) - file file pattern=[\d,/,\\,.,-]+.\s*\d{2}[:,.]\d{2}.\s*[\d,,,.]*\s*([\w,.,/,\\,\s,\-,\+,\d]*) - -command: ls -l.* - file file pattern=-[-,r,w,x]+\s.*\s[\d{4},\d{2}:\d{2}]+,\s([\w,.,/,(,),\\,\-,\+\s,\d]*) - file file pattern=l[-,r,w,x]+\s.*\s[\d{4},\d{2}:\d{2}]+,\s([\w,.,/,(,),\\,\-,\+\s,\d]*)\s->\s[\w,.,/,(,),\\,\-,\+\s,\d]* - file file pattern=-.*\d{2}:\d{2} ([\w,.,/,(,),\\,\-,\+,\s,\d]*) - file file pattern=-.* \d{4} ([\w,.,/,(,),\\,\-,\+,\s,\d]*) - file file pattern=l.*\d{2}:\d{2} ([\w,.,/,(,),\\,\-,\+,\s,\d]*)\s->\s[\w,.,/,(,),\\,\-,\+\s,\d]* - file file pattern=l.* \d{4} ([\w,.,/,(,),\\,\-,\+,\s,\d]*)\s->\s[\w,.,/,(,),\\,\-,\+\s,\d]* - directory file pattern=d.*\d{2}:\d{2} ([\w,.,/,(,),\\,\-,\+\s,\d]*) - directory file pattern=d.*\d{4} ([\w,.,/,(,),\\,\-,\+,\s,\d]*) - -command: ls -a.* - file file pattern=-.*\d{2}:\d{2} ([\w,.,/,(,),\\,\-,\+\s,\d]*) - file file pattern=-.* \d{4} ([\w,.,/,(,),\\,\-,\+\s,\d]*) - directory file pattern=d.*\d{2}:\d{2} ([\w,.,/,(,),\\,\-,\+\s,\d]*) - directory file pattern=d.*\d{4} ([\w,.,/,(,),\\,\-,\+\s,\d]*) - -command: ls - file file pattern=([\w,\d,.,(,),\-,\+\s]+) - -command: ls\s.* - file file pattern=([\w,\d,.,(,),\-,\+\s]+) - -command: .* - prompt file pattern=([\w,.,/,(,),\\,\-,\+,\d,:,\s]*)>.* - -command: find .* - file file pattern=([\w,.,/,\\,(,),\-]+) - -command: env - pathenvvar file pattern=PATH\=(.*) - libpathenvvar file pattern=LIBPATH\=(.*) - libpathenvvar file pattern=LIB\=(.*) - envvar pattern=[\w\d]+\=.* - -command: ps - process pattern=[\s]*[\d]+\s.* - -command: ps .* - process pattern=[\s]*[\d]+\s.* - -command: xl[C,c].* - error file line pattern=\"([\w,.,/,(,),\-,\+,\\]*)\",, line (\d*)\.\d*: \d*-\d* \(S\).* - error file line pattern=\"([\w,.,/,(,),\-,\+,\\]*)\", line (\d*)\.\d*: \d*-\d* \(E\).* - warning file line pattern=\"([\w,.,/,(,),\-,\+,\\]*)\", line (\d*)\.\d*: \d*-\d* \(W\).* - informational file line pattern=\"([\w,.,/,(,),\-,\+,\\]*)\", line (\d*)\.\d*: \d*-\d* \(I\).* - -command: ixlc.* - error file line pattern=([\w,.,/,\\]*) Line (\d*)\s.* - error file line pattern=[\w,.,/,\\]* Line \d* \"([\w,.,/,\\]*)\", line (\d*)\.\d*: .* - -command: cat.*patterns.* - warning file pattern=# .*(PATTERNS.DAT).* - Output pattern=command: .* - #statement pattern=#.* - statement pattern=.* pattern.*=.* - -# special for autoconf -command: ./bootstrap.sc.* - error file line pattern=aclocal: ([\w,.,/,\\]*): (\d*):.* - warning file line pattern=([\w,.,/,\\]*):(\d*):.* - -command: ./configure.* - error file line pattern=./(configure): line (\d*): .* - -# How Patterns Work -# ----------------- -# -# Patterns are used by the Output View to allow lines that contain file names and -# perhaps line numbers to be clicked to cause the file location to be opened in an Editor. -# A line in this file can be 1 of 3 things: -# 1. An empty line or a comment line (denoted by a # in column 1) -# 2. The start of a command description (denoted by a 'command:' at the beginning of the line) -# 3. A pattern description. -# A formal description of the syntax of this file is included at the bottom of this file. -# -# -# Command Descriptions -# -------------------- -# -# A Command Description consists of 2 things: A regular expression that describes the -# command invocation, and a list of Pattern Descriptions. The regular expression -# is used to determine what set of Pattern Descriptons to use when parsing command output. -# For example, if you type the command 'gmake clean', the Command Descriptions are checked and -# .*make.* would match that command. Therefore the Pattern Descriptions for .*make.* would -# be used to parse the output of the 'gmake clean'. -# Note: The first Command Description that is found to match the command is used, so make -# sure you put the most specific patterns first. For example, if the nmake.* Command -# Description appeared after .*make.*, then 'nmake install' would be matched by the .*make.* -# Command Descripton, which is probably not what was intended. -# -# -# Pattern Descriptions -# -------------------- -# -# A Pattern Description has the following form: -# "pattern=" -# -# where: -# : The type of object that will be created in the Output View if -# a line of output matches this pattern. -# -# : This is some combination of the words "file" and "line" or nothing -# at all. This is used to define how the backreferences in the -# regular expression are to be interpreted. So "file line" means -# that the first back-reference is a file, and the second is a -# line number. This may seem unnecessary, but we added this capability -# in the event that future releases support other types of information -# that may be useful, such as column info (once we support it). -# -# : A regular expression that describes a line of output. Backreferences -# are used to store (instead of just match) the filename and line -# number. To store a filename use the backreference ([\w,.,/,\\]*), and -# to store a line number, use (\d*) -# -# -# Note: The patterns are checked against command output and only exact matches are dealt with -# So as an example, if you forget the .* (match everything) at the end of a pattern, -# the match will fail if there are trailing characters in the output not accounted for by -# the pattern -# -# -# Pattern File Syntax -# ------------------- -# -# The pattern file syntax should be easy to grasp by looking at the ones -# above, but for those of you who like formal grammars, here it is: -# -# patterns-file: -# commands -# -# commands: -# command -# commands new-line command -# -# command: -# "command:" reg-ex new-line patterns -# -# patterns: -# pattern -# patterns new-line pattern -# -# pattern: -# command-name match-list "pattern=" reg-ex -# -# command-name: -# String that denotes what type of object will be created if some output matches this pattern -# -# match-list: -# file-or-line -# match-list space file-or-line -# -# file-or-line: -# "file" | "line" -# -# reg-ex: -# A regular expression -# -# new-line: -# The new-line character \n -# -# space: -# The space character - - diff --git a/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/shells/OutputPattern.java b/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/shells/OutputPattern.java deleted file mode 100644 index d81bf728937..00000000000 --- a/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/shells/OutputPattern.java +++ /dev/null @@ -1,98 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2001, 2006 IBM Corporation and International Business Machines Corporation. All rights reserved. - * This program and the accompanying materials are made available under the terms - * of the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * {Name} (company) - description of contribution. - ********************************************************************************/ - -package org.eclipse.rse.internal.services.local.shells; - -import java.util.ArrayList; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -public class OutputPattern -{ - - - private Pattern _pattern; - private String _objType; - private ArrayList _matchOrder; - - public OutputPattern(String objType, String matchOrder, Pattern thePattern) - { - _objType = objType; - _pattern = thePattern; - - _matchOrder = new ArrayList(); - //Here we add a dummy first element to the ArrayList, to mimick how the PatternMatcher stores it's - //matches (starting with group 1). - _matchOrder.add(null); - - int index = 0; - int nextSpace = 0; - //Walk the matchOrder string parsing out words and adding them to _matchOrder...Could use StringTokenizer - //but this seem much simpler. - while ((nextSpace = matchOrder.indexOf(" ", index)) > 0) - { - _matchOrder.add(matchOrder.substring(index, nextSpace).toLowerCase()); - index = nextSpace; - while ((index < matchOrder.length()) && (matchOrder.charAt(index) == ' ')) - index++; - } - _matchOrder.add(matchOrder.substring(index, matchOrder.length()).toLowerCase()); - - } - - public ParsedOutput matchLine(String theLine) - { - Matcher matcher = null; - try - { - matcher = _pattern.matcher(theLine); - if (!matcher.matches()) - return null; - } - catch (StringIndexOutOfBoundsException e) - { - //Getting an exception here, when theLine is an empty line for some patterns..should probably investigate, - //but for now we'll just handle it... - return null; - } - - String fileString = ""; - String lineString = ""; - //Groups start at 1 (group 0 is the entire match). - for (int i = 1; i < _matchOrder.size(); i++) - { - String mStr = (String)_matchOrder.get(i); - if (mStr.equals("file")) - fileString = matcher.group(i); - else if (mStr.equals("line")) - lineString = matcher.group(i); - } - int line = 1; - if (lineString.length() > 0) - { - try - { - line = Integer.parseInt(lineString); - } - catch (NumberFormatException e) - { - } - } - - return new ParsedOutput(_objType, theLine, fileString, line, 1); - } - -} \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/shells/Patterns.java b/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/shells/Patterns.java deleted file mode 100644 index 86acec876b9..00000000000 --- a/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/shells/Patterns.java +++ /dev/null @@ -1,120 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2002, 2006 IBM Corporation. All rights reserved. - * This program and the accompanying materials are made available under the terms - * of the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * {Name} (company) - description of contribution. - ********************************************************************************/ -package org.eclipse.rse.internal.services.local.shells; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.URL; -import java.util.ArrayList; -import java.util.regex.Pattern; - -import org.eclipse.rse.services.local.Activator; -import org.osgi.framework.Bundle; - -public class Patterns { - private ArrayList _theCommands; - private String _currentCommand; - - public Patterns() { - _theCommands = new ArrayList(); - parsePatterns(); - } - - private void parsePatterns() { - Bundle bundle = Activator.getDefault().getBundle(); - URL patterns = bundle.getEntry("/patterns.dat"); - if (patterns != null) { - try { - InputStream in = patterns.openStream(); - BufferedReader reader = new BufferedReader(new InputStreamReader(in)); - _theCommands.clear(); - String curLine; - CommandPattern curCommand = null; - while ((curLine = reader.readLine()) != null) { - curLine = curLine.trim(); - // Skip the current line if it is empty or starts with a # - if ((curLine.length() == 0) || (curLine.charAt(0) == '#')) { - continue; - } - // Check if this line is the start of a new command section - if (curLine.startsWith("command")) { - int colon = curLine.indexOf(":"); - // Check that there is something after the colon - if (colon == (curLine.length() - 1)) { - continue; - } - Pattern thePattern = Pattern.compile(curLine.substring(colon + 1, curLine.length()).trim()); - curCommand = new CommandPattern(thePattern); - _theCommands.add(curCommand); - } - // If we get here, the line must be an output pattern - else { - int firstSpace = curLine.indexOf(" "); - int patternWord = curLine.indexOf("pattern"); - int firstEquals = curLine.indexOf("="); - if ((firstEquals == -1) || (firstEquals == (curLine.length() - 1))) { - continue; - } - String objType = curLine.substring(0, firstSpace); - String matchOrder = curLine.substring(firstSpace + 1, patternWord).trim(); - String patternString = curLine.substring(firstEquals + 1, curLine.length()); - Pattern thePattern = Pattern.compile(patternString.trim()); - if (curCommand != null) { - curCommand.addOutputPattern(new OutputPattern(objType, matchOrder, thePattern)); - } - } - } - in.close(); - } catch (IOException e) { - Activator.getDefault().logException(e); - } - } - } - - public void refresh(String theCommand) { - _currentCommand = theCommand; - parsePatterns(); - } - - public void update(String theCommand) { - _currentCommand = theCommand; - } - - public ParsedOutput matchLine(String theLine) { - CommandPattern curCommand; - ParsedOutput matchedOutput = null; - int commands = _theCommands.size(); - if (_currentCommand != null) - { - - for (int i = 0; i < commands; i++) - { - curCommand = (CommandPattern) _theCommands.get(i); - if (curCommand.matchCommand(_currentCommand)) - { - matchedOutput = curCommand.matchLine(theLine); - } - if (matchedOutput != null) - { - return matchedOutput; - } - } - } - return null; - } -} \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.services.ssh/build.properties b/rse/plugins/org.eclipse.rse.services.ssh/build.properties index 1d891040fed..af039aff2e1 100644 --- a/rse/plugins/org.eclipse.rse.services.ssh/build.properties +++ b/rse/plugins/org.eclipse.rse.services.ssh/build.properties @@ -4,7 +4,6 @@ bin.includes = META-INF/,\ about.ini,\ about.mappings,\ about.properties,\ - patterns.dat,\ plugin.properties,\ readme.txt,\ eclipse32.png diff --git a/rse/plugins/org.eclipse.rse.services.ssh/src/org/eclipse/rse/services/ssh/shell/CommandPattern.java b/rse/plugins/org.eclipse.rse.services.ssh/src/org/eclipse/rse/services/ssh/shell/CommandPattern.java deleted file mode 100644 index 73dafd03404..00000000000 --- a/rse/plugins/org.eclipse.rse.services.ssh/src/org/eclipse/rse/services/ssh/shell/CommandPattern.java +++ /dev/null @@ -1,60 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2001, 2006 IBM Corporation and International Business Machines Corporation. All rights reserved. - * This program and the accompanying materials are made available under the terms - * of the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * Martin Oberhuber (WindRiver) - adapted from services.local - ********************************************************************************/ - -package org.eclipse.rse.services.ssh.shell; - -import java.util.ArrayList; -import java.util.regex.Pattern; - -public class CommandPattern -{ - - - private Pattern _pattern; - private ArrayList _outputPatterns; - - public CommandPattern(Pattern theCommandPattern) - { - _pattern = theCommandPattern; - _outputPatterns = new ArrayList(); - } - - public void addOutputPattern(OutputPattern op) - { - _outputPatterns.add(op); - } - - public boolean matchCommand(String theLine) - { - return _pattern.matcher(theLine).matches(); - } - - public ParsedOutput matchLine(String theLine) - { - int patterns = _outputPatterns.size(); - ParsedOutput matchedOutput; - OutputPattern curPattern; - for (int i = 0; i < patterns; i++) - { - curPattern = (OutputPattern) _outputPatterns.get(i); - matchedOutput = curPattern.matchLine(theLine); - if (matchedOutput != null) - return matchedOutput; - } - return null; - } - -} \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.services.ssh/src/org/eclipse/rse/services/ssh/shell/ParsedOutput.java b/rse/plugins/org.eclipse.rse.services.ssh/src/org/eclipse/rse/services/ssh/shell/ParsedOutput.java deleted file mode 100644 index 5ec2ccb706a..00000000000 --- a/rse/plugins/org.eclipse.rse.services.ssh/src/org/eclipse/rse/services/ssh/shell/ParsedOutput.java +++ /dev/null @@ -1,38 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2002, 2006 IBM Corporation. All rights reserved. - * This program and the accompanying materials are made available under the terms - * of the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * Martin Oberhuber (WindRiver) - adapted from services.local - ********************************************************************************/ - -package org.eclipse.rse.services.ssh.shell; - -//This is just a convenience object for storing information parsed out of a line of output. -public class ParsedOutput -{ - - - public String type; - public String text; - public String file; - public int line; - public int col; - - public ParsedOutput (String theType, String theText, String theFile, int theLine, int theColumn) - { - type = theType; - text = theText; - file = theFile; - line = theLine; - col = theColumn; - } -} \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.services/build.properties b/rse/plugins/org.eclipse.rse.services/build.properties index edb8010fe7d..c9751d41381 100644 --- a/rse/plugins/org.eclipse.rse.services/build.properties +++ b/rse/plugins/org.eclipse.rse.services/build.properties @@ -1,7 +1,8 @@ bin.includes = META-INF/,\ about.html,\ - plugin.properties,\ clientserver.jar,\ + patterns.dat,\ + plugin.properties,\ . jars.compile.order = clientserver.jar,. source.clientserver.jar = clientserver/ diff --git a/rse/plugins/org.eclipse.rse.services.ssh/patterns.dat b/rse/plugins/org.eclipse.rse.services/patterns.dat similarity index 99% rename from rse/plugins/org.eclipse.rse.services.ssh/patterns.dat rename to rse/plugins/org.eclipse.rse.services/patterns.dat index d469576fc9b..f10681f82c0 100644 --- a/rse/plugins/org.eclipse.rse.services.ssh/patterns.dat +++ b/rse/plugins/org.eclipse.rse.services/patterns.dat @@ -279,5 +279,3 @@ command: ./configure.* # # space: # The space character - - diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/Activator.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/Activator.java index 0fc8b32846f..cd1f00da69f 100644 --- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/Activator.java +++ b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/Activator.java @@ -16,7 +16,10 @@ package org.eclipse.rse.services; +import org.eclipse.core.runtime.ILog; +import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Plugin; +import org.eclipse.core.runtime.Status; import org.osgi.framework.BundleContext; /** @@ -34,15 +37,17 @@ public class Activator extends Plugin { plugin = this; } - /** - * This method is called upon plug-in activation + /* + * (non-Javadoc) + * @see org.eclipse.core.runtime.Plugin#start(org.osgi.framework.BundleContext) */ public void start(BundleContext context) throws Exception { super.start(context); } - /** - * This method is called when the plug-in is stopped + /* + * (non-Javadoc) + * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext) */ public void stop(BundleContext context) throws Exception { super.stop(context); @@ -51,9 +56,21 @@ public class Activator extends Plugin { /** * Returns the shared instance. + * @return the shared instance */ public static Activator getDefault() { return plugin; } + /** + * Logs an throwable to the log for this plugin. + * @param t the Throwable to be logged. + */ + public void logException(Throwable t) { + ILog log = getLog(); + String id = getBundle().getSymbolicName(); + IStatus status = new Status(IStatus.ERROR, id, 0, "Unexpected exception", t); + log.log(status); + } + } \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/shells/CommandPattern.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/CommandPattern.java similarity index 96% rename from rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/shells/CommandPattern.java rename to rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/CommandPattern.java index b07f6b3e60f..b0fe42fd436 100644 --- a/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/shells/CommandPattern.java +++ b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/CommandPattern.java @@ -14,7 +14,7 @@ * {Name} (company) - description of contribution. ********************************************************************************/ -package org.eclipse.rse.internal.services.local.shells; +package org.eclipse.rse.services.shells; import java.util.ArrayList; import java.util.regex.Pattern; diff --git a/rse/plugins/org.eclipse.rse.services.ssh/src/org/eclipse/rse/services/ssh/shell/OutputPattern.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/OutputPattern.java similarity index 96% rename from rse/plugins/org.eclipse.rse.services.ssh/src/org/eclipse/rse/services/ssh/shell/OutputPattern.java rename to rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/OutputPattern.java index bb86d09fa76..1974f221653 100644 --- a/rse/plugins/org.eclipse.rse.services.ssh/src/org/eclipse/rse/services/ssh/shell/OutputPattern.java +++ b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/OutputPattern.java @@ -11,10 +11,10 @@ * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. * * Contributors: - * Martin Oberhuber (WindRiver) - adapted from services.local + * {Name} (company) - description of contribution. ********************************************************************************/ -package org.eclipse.rse.services.ssh.shell; +package org.eclipse.rse.services.shells; import java.util.ArrayList; import java.util.regex.Matcher; diff --git a/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/shells/ParsedOutput.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/ParsedOutput.java similarity index 95% rename from rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/shells/ParsedOutput.java rename to rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/ParsedOutput.java index 70b06325512..82e37851bb9 100644 --- a/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/shells/ParsedOutput.java +++ b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/ParsedOutput.java @@ -14,7 +14,7 @@ * {Name} (company) - description of contribution. ********************************************************************************/ -package org.eclipse.rse.internal.services.local.shells; +package org.eclipse.rse.services.shells; //This is just a convenience object for storing information parsed out of a line of output. public class ParsedOutput diff --git a/rse/plugins/org.eclipse.rse.services.ssh/src/org/eclipse/rse/services/ssh/shell/Patterns.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/Patterns.java similarity index 96% rename from rse/plugins/org.eclipse.rse.services.ssh/src/org/eclipse/rse/services/ssh/shell/Patterns.java rename to rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/Patterns.java index d8ff2dfa19e..ab53981ed56 100644 --- a/rse/plugins/org.eclipse.rse.services.ssh/src/org/eclipse/rse/services/ssh/shell/Patterns.java +++ b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/Patterns.java @@ -11,9 +11,9 @@ * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. * * Contributors: - * Martin Oberhuber (WindRiver) - adapted from services.local + * {Name} (company) - description of contribution. ********************************************************************************/ -package org.eclipse.rse.services.ssh.shell; +package org.eclipse.rse.services.shells; import java.io.BufferedReader; import java.io.IOException; @@ -23,10 +23,9 @@ import java.net.URL; import java.util.ArrayList; import java.util.regex.Pattern; +import org.eclipse.rse.services.Activator; import org.osgi.framework.Bundle; -import org.eclipse.rse.services.ssh.Activator; - public class Patterns { private ArrayList _theCommands; private String _currentCommand; diff --git a/rse/plugins/org.eclipse.rse.subsystems.shells.local/src/org/eclipse/rse/subsystems/shells/local/model/LocalServiceCommandShell.java b/rse/plugins/org.eclipse.rse.subsystems.shells.local/src/org/eclipse/rse/subsystems/shells/local/model/LocalServiceCommandShell.java index 1217fcdf502..560ce0ac375 100644 --- a/rse/plugins/org.eclipse.rse.subsystems.shells.local/src/org/eclipse/rse/subsystems/shells/local/model/LocalServiceCommandShell.java +++ b/rse/plugins/org.eclipse.rse.subsystems.shells.local/src/org/eclipse/rse/subsystems/shells/local/model/LocalServiceCommandShell.java @@ -4,13 +4,13 @@ package org.eclipse.rse.subsystems.shells.local.model; import java.io.File; import org.eclipse.rse.core.subsystems.ISubSystem; -import org.eclipse.rse.internal.services.local.shells.ParsedOutput; -import org.eclipse.rse.internal.services.local.shells.Patterns; import org.eclipse.rse.internal.subsystems.shells.servicesubsystem.OutputRefreshJob; import org.eclipse.rse.internal.subsystems.shells.subsystems.RemoteError; import org.eclipse.rse.internal.subsystems.shells.subsystems.RemoteOutput; import org.eclipse.rse.services.shells.IHostShell; import org.eclipse.rse.services.shells.IHostShellChangeEvent; +import org.eclipse.rse.services.shells.ParsedOutput; +import org.eclipse.rse.services.shells.Patterns; import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem; import org.eclipse.rse.subsystems.shells.core.subsystems.IRemoteCmdSubSystem; import org.eclipse.rse.subsystems.shells.core.subsystems.IRemoteOutput; diff --git a/rse/plugins/org.eclipse.rse.subsystems.shells.ssh/src/org/eclipse/rse/subsystems/shells/ssh/SshServiceCommandShell.java b/rse/plugins/org.eclipse.rse.subsystems.shells.ssh/src/org/eclipse/rse/subsystems/shells/ssh/SshServiceCommandShell.java index 48386c80aae..3511fdb53bf 100644 --- a/rse/plugins/org.eclipse.rse.subsystems.shells.ssh/src/org/eclipse/rse/subsystems/shells/ssh/SshServiceCommandShell.java +++ b/rse/plugins/org.eclipse.rse.subsystems.shells.ssh/src/org/eclipse/rse/subsystems/shells/ssh/SshServiceCommandShell.java @@ -27,8 +27,8 @@ import org.eclipse.rse.internal.subsystems.shells.subsystems.RemoteError; import org.eclipse.rse.internal.subsystems.shells.subsystems.RemoteOutput; import org.eclipse.rse.services.shells.IHostShell; import org.eclipse.rse.services.shells.IHostShellChangeEvent; -import org.eclipse.rse.services.ssh.shell.ParsedOutput; -import org.eclipse.rse.services.ssh.shell.Patterns; +import org.eclipse.rse.services.shells.ParsedOutput; +import org.eclipse.rse.services.shells.Patterns; import org.eclipse.rse.services.ssh.shell.SshHostShell; import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem; import org.eclipse.rse.subsystems.shells.core.model.ISystemOutputRemoteTypes;