1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-24 01:15:29 +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
*/
public interface IScannerInfoConsoleParser {
/**
* Get a utility object to be initialized
*/
public IScannerInfoConsoleParserUtility getUtility();
/**
* Optional one time initialization of a console parser.
*
* @param project
* @param util - utility functions for file and path management
* @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.

View file

@ -10,10 +10,9 @@
**********************************************************************/
package org.eclipse.cdt.make.core.scannerconfig;
import java.util.List;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.cdt.core.IMarkerGenerator;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IPath;
/**
* Common work required by the scanner info console parsers
@ -21,12 +20,5 @@ import org.eclipse.core.resources.IResource;
* @author vhirsl
*/
public interface IScannerInfoConsoleParserUtility {
// Problem marker related
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);
public void initialize(IProject project, IPath workingDirectory, IMarkerGenerator markerGenerator);
}

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.IScannerInfoCollector;
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.ScannerConfigNature;
import org.eclipse.cdt.make.internal.core.scannerconfig.util.ScannerInfoConsoleParserUtility;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
@ -51,9 +51,12 @@ public class ScannerInfoConsoleParserFactory {
// get the ESIProvider console parser
IScannerInfoConsoleParser clParser = MakeCorePlugin.getDefault().
getScannerInfoConsoleParser(scBuildInfo.getESIProviderConsoleParserId());
// initialize it with the utility
clParser.startup(currentProject, null /*new ScannerInfoConsoleParserUtility(
currentProject, null, markerGenerator)*/, collector);
// initialize the utility object
IScannerInfoConsoleParserUtility util = clParser.getUtility();
if (util != null) {
util.initialize(currentProject, currentProject.getLocation(), null);
}
clParser.startup(currentProject, collector);
// create an output stream sniffer
return new ConsoleOutputStreamSniffer(outputStream, new
IScannerInfoConsoleParser[] {clParser});
@ -93,11 +96,14 @@ public class ScannerInfoConsoleParserFactory {
// get the make builder console parser
IScannerInfoConsoleParser clParser = MakeCorePlugin.getDefault().
getScannerInfoConsoleParser(scBuildInfo.getMakeBuilderConsoleParserId());
// initialize it with the utility
clParser.startup(currentProject, new ScannerInfoConsoleParserUtility(
currentProject, workingDirectory,
scBuildInfo.isSIProblemGenerationEnabled() ? markerGenerator : null),
ScannerInfoCollector.getInstance());
// initialize the utility object
IScannerInfoConsoleParserUtility util = clParser.getUtility();
if (util != null) {
util.initialize(currentProject, workingDirectory,
scBuildInfo.isSIProblemGenerationEnabled() ?
markerGenerator : null);
}
clParser.startup(currentProject, ScannerInfoCollector.getInstance());
// create an output stream sniffer
return new ConsoleOutputStreamSniffer(outputStream, new
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.IScannerInfoConsoleParserUtility;
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 java.util.ArrayList;
@ -36,18 +37,24 @@ public class GCCScannerInfoConsoleParser implements IScannerInfoConsoleParser {
private final static String DOUBLE_QUOTE_STRING = "\""; //$NON-NLS-1$
private IProject fProject = null;
private IScannerInfoConsoleParserUtility fUtil = null;
private ScannerInfoConsoleParserUtility fUtil = new ScannerInfoConsoleParserUtility();
private IScannerInfoCollector fCollector = null;
private boolean bMultiline = false;
private String sMultiline = ""; //$NON-NLS-1$
/* (non-Javadoc)
* @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser#getUtility()
*/
public IScannerInfoConsoleParserUtility getUtility() {
return fUtil;
}
/* (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)
*/
public void startup(IProject project, IScannerInfoConsoleParserUtility util, IScannerInfoCollector collector) {
public void startup(IProject project, IScannerInfoCollector collector) {
fProject = project;
fUtil = util;
fCollector = collector;
}
@ -314,4 +321,5 @@ public class GCCScannerInfoConsoleParser implements IScannerInfoConsoleParser {
}
return num;
}
}

View file

@ -42,14 +42,20 @@ public class GCCSpecsConsoleParser implements IScannerInfoConsoleParser {
private List includes = new ArrayList();
/* (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.fUtil = util;
this.fCollector = collector;
}
/* (non-Javadoc)
* @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()
*/
public void shutdown() {
if (fUtil != null) {
fUtil.reportProblems();
}
}
}

View file

@ -52,7 +52,10 @@ public class ScannerInfoConsoleParserUtility implements IScannerInfoConsoleParse
private List fNameConflicts;
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;
fMarkerGenerator = markerGenerator;
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() {
boolean reset = false;
for (Iterator iter = fErrors.iterator(); iter.hasNext(); ) {
@ -251,7 +251,7 @@ public class ScannerInfoConsoleParserUtility implements IScannerInfoConsoleParse
return fNameConflicts.contains(path.lastSegment());
}
protected IPath getWorkingDirectory() {
public IPath getWorkingDirectory() {
if (fDirectoryStack.size() != 0) {
return (IPath) fDirectoryStack.lastElement();
}
@ -300,9 +300,6 @@ public class ScannerInfoConsoleParserUtility implements IScannerInfoConsoleParse
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) {
if (enterDir) {
/* 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) {
List translatedIncludes = new ArrayList(includes.size());
for (Iterator i = includes.iterator(); i.hasNext(); ) {
@ -376,9 +370,6 @@ public class ScannerInfoConsoleParserUtility implements IScannerInfoConsoleParse
return translatedIncludes;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.make.internal.core.scannerconfig.IScannerInfoConsoleParserUtility#normalizePath(java.lang.String)
*/
public String normalizePath(String path) {
int column = path.indexOf(':');
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.List;
import java.util.Map;
/**
* Tracebility related utility functions
@ -77,4 +78,21 @@ public class TraceUtil {
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() {
final ArrayList sumIncludes = new ArrayList();
// 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) {
sumIncludes.addAll(includes);
}
@ -120,7 +120,7 @@ public class ScannerConfigConsoleParserTests extends TestCase {
public void testParsingSymbolDefinitions() {
final ArrayList sumSymbols = new ArrayList();
// 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) {
sumSymbols.addAll(symbols);
}