1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
/**********************************************************************
* Copyright (c) 2004 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM - Initial API and implementation
**********************************************************************/
package org.eclipse.cdt.make.internal.core.scannerconfig;
import java.io.OutputStream;
import org.eclipse.cdt.core.IMarkerGenerator;
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.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
/**
* A factory that creates a ConsoleOutputStreamSniffer,
* ScannerInfoConsoleParser and optionally a ScannerInfoConsoleParserUtility.
*
* @author vhirsl
*/
public class ScannerInfoConsoleParserFactory {
/**
* Creates a ConsoleOutputStreamSniffer, make builder scanner info console parser
* and a utility.
*
* @param outputStream
* @param currentProject
* @param markerGenerator
* @param scBuildInfo
* @param collector - scanner info collector
* @return OutputStream
*/
public static OutputStream getESIProviderOutputSniffer(OutputStream outputStream,
IProject currentProject,
IScannerConfigBuilderInfo scBuildInfo,
IScannerInfoCollector collector) {
if (scBuildInfo.isESIProviderCommandEnabled()) {
// get the ESIProvider console parser
IScannerInfoConsoleParser clParser = MakeCorePlugin.getDefault().
getScannerInfoConsoleParser(scBuildInfo.getESIProviderConsoleParserId());
// 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});
}
return outputStream;
}
/**
* Creates a ConsoleOutputStreamSniffer, ESI provider scanner info console parser
* and a utility.
*
* @param outputStream
* @param currentProject
* @param workingDirectory
* @param markerGenerator
* @return OutputStream
*/
public static OutputStream getMakeBuilderOutputSniffer(OutputStream outputStream,
IProject currentProject,
IPath workingDirectory,
IMarkerGenerator markerGenerator) {
try {
// get the SC builder settings
if (currentProject.hasNature(ScannerConfigNature.NATURE_ID)) {
IScannerConfigBuilderInfo scBuildInfo;
try {
scBuildInfo = MakeCorePlugin.
createScannerConfigBuildInfo(currentProject, ScannerConfigBuilder.BUILDER_ID);
}
catch (CoreException e) {
// builder not installed or disabled
scBuildInfo = null;
}
if (scBuildInfo != null &&
scBuildInfo.isAutoDiscoveryEnabled() &&
scBuildInfo.isMakeBuilderConsoleParserEnabled()) {
// get the make builder console parser
IScannerInfoConsoleParser clParser = MakeCorePlugin.getDefault().
getScannerInfoConsoleParser(scBuildInfo.getMakeBuilderConsoleParserId());
// 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});
}
}
}
catch (CoreException e) {
MakeCorePlugin.log(e.getStatus());
}
return outputStream;
}
}
|