1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-12 10:45:37 +02:00

Changes in the parser and utility interaction.

Ready for the first test.
This commit is contained in:
Vladimir Hirsl 2004-10-19 21:08:25 +00:00
parent 22aaaf84bc
commit 5fd1105acd
8 changed files with 71 additions and 49 deletions

View file

@ -18,14 +18,18 @@ import org.eclipse.core.resources.IProject;
* @author vhirsl * @author vhirsl
*/ */
public interface IScannerInfoConsoleParser { public interface IScannerInfoConsoleParser {
/**
* Get a utility object to be initialized
*/
public IScannerInfoConsoleParserUtility getUtility();
/** /**
* Optional one time initialization of a console parser. * Optional one time initialization of a console parser.
* *
* @param project * @param project
* @param util - utility functions for file and path management
* @param collector - scanner info collector * @param collector - scanner info collector
*/ */
public void startup(IProject project, IScannerInfoConsoleParserUtility util, IScannerInfoCollector collector); public void startup(IProject project, IScannerInfoCollector collector);
/** /**
* Parse one line of output. * Parse one line of output.

View file

@ -10,10 +10,9 @@
**********************************************************************/ **********************************************************************/
package org.eclipse.cdt.make.core.scannerconfig; package org.eclipse.cdt.make.core.scannerconfig;
import java.util.List; import org.eclipse.cdt.core.IMarkerGenerator;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.IPath;
import org.eclipse.core.resources.IResource;
/** /**
* Common work required by the scanner info console parsers * Common work required by the scanner info console parsers
@ -21,12 +20,5 @@ import org.eclipse.core.resources.IResource;
* @author vhirsl * @author vhirsl
*/ */
public interface IScannerInfoConsoleParserUtility { public interface IScannerInfoConsoleParserUtility {
// Problem marker related public void initialize(IProject project, IPath workingDirectory, IMarkerGenerator markerGenerator);
public void generateMarker(IResource file, int lineNumber, String desc, int severity, String varName);
public boolean reportProblems();
// File path management
public void changeMakeDirectory(String dir, int dirLevel, boolean enterDir);
public IFile findFile(String fileName);
public List translateRelativePaths(IFile file, String fileName, List includes);
public String normalizePath(String path);
} }

View file

@ -17,9 +17,9 @@ import org.eclipse.cdt.make.core.MakeCorePlugin;
import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo; import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo;
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector; import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector;
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser; import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser;
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParserUtility;
import org.eclipse.cdt.make.core.scannerconfig.ScannerConfigBuilder; import org.eclipse.cdt.make.core.scannerconfig.ScannerConfigBuilder;
import org.eclipse.cdt.make.core.scannerconfig.ScannerConfigNature; import org.eclipse.cdt.make.core.scannerconfig.ScannerConfigNature;
import org.eclipse.cdt.make.internal.core.scannerconfig.util.ScannerInfoConsoleParserUtility;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
@ -51,9 +51,12 @@ public class ScannerInfoConsoleParserFactory {
// get the ESIProvider console parser // get the ESIProvider console parser
IScannerInfoConsoleParser clParser = MakeCorePlugin.getDefault(). IScannerInfoConsoleParser clParser = MakeCorePlugin.getDefault().
getScannerInfoConsoleParser(scBuildInfo.getESIProviderConsoleParserId()); getScannerInfoConsoleParser(scBuildInfo.getESIProviderConsoleParserId());
// initialize it with the utility // initialize the utility object
clParser.startup(currentProject, null /*new ScannerInfoConsoleParserUtility( IScannerInfoConsoleParserUtility util = clParser.getUtility();
currentProject, null, markerGenerator)*/, collector); if (util != null) {
util.initialize(currentProject, currentProject.getLocation(), null);
}
clParser.startup(currentProject, collector);
// create an output stream sniffer // create an output stream sniffer
return new ConsoleOutputStreamSniffer(outputStream, new return new ConsoleOutputStreamSniffer(outputStream, new
IScannerInfoConsoleParser[] {clParser}); IScannerInfoConsoleParser[] {clParser});
@ -93,11 +96,14 @@ public class ScannerInfoConsoleParserFactory {
// get the make builder console parser // get the make builder console parser
IScannerInfoConsoleParser clParser = MakeCorePlugin.getDefault(). IScannerInfoConsoleParser clParser = MakeCorePlugin.getDefault().
getScannerInfoConsoleParser(scBuildInfo.getMakeBuilderConsoleParserId()); getScannerInfoConsoleParser(scBuildInfo.getMakeBuilderConsoleParserId());
// initialize it with the utility // initialize the utility object
clParser.startup(currentProject, new ScannerInfoConsoleParserUtility( IScannerInfoConsoleParserUtility util = clParser.getUtility();
currentProject, workingDirectory, if (util != null) {
scBuildInfo.isSIProblemGenerationEnabled() ? markerGenerator : null), util.initialize(currentProject, workingDirectory,
ScannerInfoCollector.getInstance()); scBuildInfo.isSIProblemGenerationEnabled() ?
markerGenerator : null);
}
clParser.startup(currentProject, ScannerInfoCollector.getInstance());
// create an output stream sniffer // create an output stream sniffer
return new ConsoleOutputStreamSniffer(outputStream, new return new ConsoleOutputStreamSniffer(outputStream, new
IScannerInfoConsoleParser[] {clParser}); IScannerInfoConsoleParser[] {clParser});

View file

@ -17,6 +17,7 @@ import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector;
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser; import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser;
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParserUtility; import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParserUtility;
import org.eclipse.cdt.make.internal.core.MakeMessages; import org.eclipse.cdt.make.internal.core.MakeMessages;
import org.eclipse.cdt.make.internal.core.scannerconfig.util.ScannerInfoConsoleParserUtility;
import org.eclipse.cdt.make.internal.core.scannerconfig.util.TraceUtil; import org.eclipse.cdt.make.internal.core.scannerconfig.util.TraceUtil;
import java.util.ArrayList; import java.util.ArrayList;
@ -36,18 +37,24 @@ public class GCCScannerInfoConsoleParser implements IScannerInfoConsoleParser {
private final static String DOUBLE_QUOTE_STRING = "\""; //$NON-NLS-1$ private final static String DOUBLE_QUOTE_STRING = "\""; //$NON-NLS-1$
private IProject fProject = null; private IProject fProject = null;
private IScannerInfoConsoleParserUtility fUtil = null; private ScannerInfoConsoleParserUtility fUtil = new ScannerInfoConsoleParserUtility();
private IScannerInfoCollector fCollector = null; private IScannerInfoCollector fCollector = null;
private boolean bMultiline = false; private boolean bMultiline = false;
private String sMultiline = ""; //$NON-NLS-1$ private String sMultiline = ""; //$NON-NLS-1$
/* (non-Javadoc)
* @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser#getUtility()
*/
public IScannerInfoConsoleParserUtility getUtility() {
return fUtil;
}
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser#startup(org.eclipse.core.resources.IProject, org.eclipse.cdt.make.internal.core.scannerconfig.IScannerInfoConsoleParserUtility, org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector) * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser#startup(org.eclipse.core.resources.IProject, org.eclipse.cdt.make.internal.core.scannerconfig.IScannerInfoConsoleParserUtility, org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector)
*/ */
public void startup(IProject project, IScannerInfoConsoleParserUtility util, IScannerInfoCollector collector) { public void startup(IProject project, IScannerInfoCollector collector) {
fProject = project; fProject = project;
fUtil = util;
fCollector = collector; fCollector = collector;
} }
@ -314,4 +321,5 @@ public class GCCScannerInfoConsoleParser implements IScannerInfoConsoleParser {
} }
return num; return num;
} }
} }

View file

@ -42,14 +42,20 @@ public class GCCSpecsConsoleParser implements IScannerInfoConsoleParser {
private List includes = new ArrayList(); private List includes = new ArrayList();
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser#startup(org.eclipse.core.resources.IProject, org.eclipse.cdt.make.internal.core.scannerconfig.IScannerInfoConsoleParserUtility, org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector) * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser#getUtility()
*/ */
public void startup(IProject project, IScannerInfoConsoleParserUtility util, IScannerInfoCollector collector) { public IScannerInfoConsoleParserUtility getUtility() {
return null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser#startup(org.eclipse.core.resources.IProject, org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector)
*/
public void startup(IProject project, IScannerInfoCollector collector) {
this.fProject = project; this.fProject = project;
this.fUtil = util;
this.fCollector = collector; this.fCollector = collector;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.make.internal.core.scannerconfig.IScannerInfoConsoleParser#processLine(java.lang.String) * @see org.eclipse.cdt.make.internal.core.scannerconfig.IScannerInfoConsoleParser#processLine(java.lang.String)
*/ */
@ -109,8 +115,5 @@ public class GCCSpecsConsoleParser implements IScannerInfoConsoleParser {
* @see org.eclipse.cdt.make.internal.core.scannerconfig.IScannerInfoConsoleParser#shutdown() * @see org.eclipse.cdt.make.internal.core.scannerconfig.IScannerInfoConsoleParser#shutdown()
*/ */
public void shutdown() { public void shutdown() {
if (fUtil != null) {
fUtil.reportProblems();
}
} }
} }

View file

@ -52,7 +52,10 @@ public class ScannerInfoConsoleParserUtility implements IScannerInfoConsoleParse
private List fNameConflicts; private List fNameConflicts;
private Vector fDirectoryStack; private Vector fDirectoryStack;
public ScannerInfoConsoleParserUtility(IProject project, IPath workingDirectory, IMarkerGenerator markerGenerator) { /* (non-Javadoc)
* @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParserUtility#initialize(org.eclipse.core.resources.IProject, org.eclipse.core.runtime.IPath, org.eclipse.cdt.core.IMarkerGenerator)
*/
public void initialize(IProject project, IPath workingDirectory, IMarkerGenerator markerGenerator) {
fProject = project; fProject = project;
fMarkerGenerator = markerGenerator; fMarkerGenerator = markerGenerator;
fBaseDirectory = fProject.getLocation(); fBaseDirectory = fProject.getLocation();
@ -77,9 +80,6 @@ public class ScannerInfoConsoleParserUtility implements IScannerInfoConsoleParse
} }
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.make.internal.core.scannerconfig.IScannerInfoConsoleParserUtility#reportProblems()
*/
public boolean reportProblems() { public boolean reportProblems() {
boolean reset = false; boolean reset = false;
for (Iterator iter = fErrors.iterator(); iter.hasNext(); ) { for (Iterator iter = fErrors.iterator(); iter.hasNext(); ) {
@ -251,7 +251,7 @@ public class ScannerInfoConsoleParserUtility implements IScannerInfoConsoleParse
return fNameConflicts.contains(path.lastSegment()); return fNameConflicts.contains(path.lastSegment());
} }
protected IPath getWorkingDirectory() { public IPath getWorkingDirectory() {
if (fDirectoryStack.size() != 0) { if (fDirectoryStack.size() != 0) {
return (IPath) fDirectoryStack.lastElement(); return (IPath) fDirectoryStack.lastElement();
} }
@ -300,9 +300,6 @@ public class ScannerInfoConsoleParserUtility implements IScannerInfoConsoleParse
return fDirectoryStack.size(); return fDirectoryStack.size();
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.make.internal.core.scannerconfig.IScannerInfoConsoleParserUtility#changeMakeDirectory(java.lang.String, int, boolean)
*/
public void changeMakeDirectory(String dir, int dirLevel, boolean enterDir) { public void changeMakeDirectory(String dir, int dirLevel, boolean enterDir) {
if (enterDir) { if (enterDir) {
/* Sometimes make screws up the output, so /* Sometimes make screws up the output, so
@ -319,9 +316,6 @@ public class ScannerInfoConsoleParserUtility implements IScannerInfoConsoleParse
} }
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.make.internal.core.scannerconfig.IScannerInfoConsoleParserUtility#translateRelativePaths(org.eclipse.core.resources.IFile, java.lang.String, java.util.List)
*/
public List translateRelativePaths(IFile file, String fileName, List includes) { public List translateRelativePaths(IFile file, String fileName, List includes) {
List translatedIncludes = new ArrayList(includes.size()); List translatedIncludes = new ArrayList(includes.size());
for (Iterator i = includes.iterator(); i.hasNext(); ) { for (Iterator i = includes.iterator(); i.hasNext(); ) {
@ -376,9 +370,6 @@ public class ScannerInfoConsoleParserUtility implements IScannerInfoConsoleParse
return translatedIncludes; return translatedIncludes;
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.make.internal.core.scannerconfig.IScannerInfoConsoleParserUtility#normalizePath(java.lang.String)
*/
public String normalizePath(String path) { public String normalizePath(String path) {
int column = path.indexOf(':'); int column = path.indexOf(':');
if (column > 0) { if (column > 0) {

View file

@ -12,6 +12,7 @@ package org.eclipse.cdt.make.internal.core.scannerconfig.util;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* Tracebility related utility functions * Tracebility related utility functions
@ -77,4 +78,21 @@ public class TraceUtil {
System.out.println("Error: " + string + line); //$NON-NLS-1$ System.out.println("Error: " + string + line); //$NON-NLS-1$
} }
} }
/**
* @param string
* @param string2
* @param string3
* @param map - map of
*/
public static void metricsTrace(String title, String subtitlePrefix, String subtitlePostfix, Map map) {
System.out.println();
System.out.println(title);
for (Iterator i = map.keySet().iterator(); i.hasNext(); ) {
String dir = (String) i.next();
System.out.println(subtitlePrefix + dir + subtitlePostfix);
List directoryCommandList = (List) map.get(dir);
}
}
} }

View file

@ -71,7 +71,7 @@ public class ScannerConfigConsoleParserTests extends TestCase {
public void testParsingIncludePaths() { public void testParsingIncludePaths() {
final ArrayList sumIncludes = new ArrayList(); final ArrayList sumIncludes = new ArrayList();
// initialize it with the utility // initialize it with the utility
clParser.startup(null, null, new IScannerInfoCollector() { clParser.startup(null, new IScannerInfoCollector() {
public void contributeToScannerConfig(IResource resource, List includes, List symbols, Map extraInfo) { public void contributeToScannerConfig(IResource resource, List includes, List symbols, Map extraInfo) {
sumIncludes.addAll(includes); sumIncludes.addAll(includes);
} }
@ -120,7 +120,7 @@ public class ScannerConfigConsoleParserTests extends TestCase {
public void testParsingSymbolDefinitions() { public void testParsingSymbolDefinitions() {
final ArrayList sumSymbols = new ArrayList(); final ArrayList sumSymbols = new ArrayList();
// initialize it with the utility // initialize it with the utility
clParser.startup(null, null, new IScannerInfoCollector() { clParser.startup(null, new IScannerInfoCollector() {
public void contributeToScannerConfig(IResource resource, List includes, List symbols, Map extraInfo) { public void contributeToScannerConfig(IResource resource, List includes, List symbols, Map extraInfo) {
sumSymbols.addAll(symbols); sumSymbols.addAll(symbols);
} }