mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-03 15:15:25 +02:00
[refactoring] 153273: move shell output parsing classes to rse.services.shells
This commit is contained in:
parent
87e522ed9f
commit
051b166e76
16 changed files with 34 additions and 605 deletions
|
@ -3,7 +3,6 @@ bin.includes = META-INF/,\
|
|||
about.properties,\
|
||||
plugin.properties,\
|
||||
.,\
|
||||
patterns.dat,\
|
||||
about.ini,\
|
||||
about.mappings,\
|
||||
eclipse32.png
|
||||
|
|
|
@ -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*<DIR>\s*([\w,.,/,\\,\s,\-,\+,\d]*).*
|
||||
directory file pattern=.*<DIR>\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*<DIR>\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:
|
||||
# <obj-name> <match-info> "pattern="<reg-ex>
|
||||
#
|
||||
# where:
|
||||
# <obj-name>: The type of object that will be created in the Output View if
|
||||
# a line of output matches this pattern.
|
||||
#
|
||||
# <match-info>: 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).
|
||||
#
|
||||
# <reg-ex>: 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
|
||||
|
||||
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -4,7 +4,6 @@ bin.includes = META-INF/,\
|
|||
about.ini,\
|
||||
about.mappings,\
|
||||
about.properties,\
|
||||
patterns.dat,\
|
||||
plugin.properties,\
|
||||
readme.txt,\
|
||||
eclipse32.png
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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/
|
||||
|
|
|
@ -279,5 +279,3 @@ command: ./configure.*
|
|||
#
|
||||
# space:
|
||||
# The space character
|
||||
|
||||
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
|
@ -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;
|
|
@ -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
|
|
@ -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;
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue