1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00

Commit for Vlad (PR 63471 and PR 68019)

This commit is contained in:
Sean Evoy 2004-06-26 20:08:14 +00:00
parent 39fd1475ba
commit c7fd6b490a
10 changed files with 114 additions and 18 deletions

View file

@ -43,4 +43,7 @@ public interface IScannerConfigBuilderInfo {
boolean isMakeBuilderConsoleParserEnabled();
void setMakeBuilderConsoleParserEnabled(boolean enabled) throws CoreException;
boolean isSIProblemGenerationEnabled();
void setSIProblemGenerationEnabled(boolean enabled) throws CoreException;
}

View file

@ -43,4 +43,9 @@ DiscoveredPathManager.File_Error_Message=Error accessing scanner config file for
GCCScannerConfigUtil.Error_Message=Error creating specs file
ConsoleParser.Filename_Missing_Error_Message=CDT Path Discovery is unable to determine source file name in build command:
ConsoleParser.Ambiguous_Filepath_Error_Message=CDT Path Discovery is unable to resolve ambiguous file path:
ConsoleParser.Working_Directory_Error_Message=CDT Path Discovery is unable to determine working directory of the build command
ConsoleParser.Nonexistent_Include_Path_Error_Message=CDT Path Discovery has discovered and will ignore a non-existent include path:
DiscoveredContainer.description=Discovered Paths

View file

@ -55,6 +55,7 @@ public class PreferenceInitializer extends AbstractPreferenceInitializer {
scInfo.setESIProviderArguments("-E -P -v ${plugin_state_location}/${specs_file}"); //$NON-NLS-1$
scInfo.setESIProviderConsoleParserId(MakeCorePlugin.GCC_SPECS_CONSOLE_PARSER_ID);
scInfo.setMakeBuilderConsoleParserId(MakeCorePlugin.GCC_SCANNER_INFO_CONSOLE_PARSER_ID);
scInfo.setSIProblemGenerationEnabled(true);
} catch (CoreException e) {
}
}

View file

@ -46,6 +46,7 @@ public class ScannerConfigInfoFactory {
static final String ESI_PROVIDER_COMMAND = PREFIX + ".esiProviderCommand"; //$NON-NLS-1$
static final String ESI_PROVIDER_ARGUMENTS = PREFIX + ".esiProviderArguments"; //$NON-NLS-1$
static final String ESI_PROVIDER_PARSER_ID = PREFIX + ".esiProviderParserId"; //$NON-NLS-1$
static final String SI_PROBLEM_GENERATION_ENABLED = PREFIX + ".siProblemGenerationEnabled"; //$NON-NLS-1$
/**
*
@ -203,6 +204,24 @@ public class ScannerConfigInfoFactory {
putString(ESI_PROVIDER_PARSER_ID, parserId);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo#isSIProblemGenerationEnabled()
*/
public boolean isSIProblemGenerationEnabled() {
if (getString(SI_PROBLEM_GENERATION_ENABLED) == null ||
getString(SI_PROBLEM_GENERATION_ENABLED).length() == 0) { // if no property then default to true
return true;
}
return getBoolean(SI_PROBLEM_GENERATION_ENABLED);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo#setSIProblemGenerationEnabled(boolean)
*/
public void setSIProblemGenerationEnabled(boolean enabled) throws CoreException {
putString(SI_PROBLEM_GENERATION_ENABLED, Boolean.toString(enabled));
}
protected boolean getBoolean(String property) {
return Boolean.valueOf(getString(property)).booleanValue();
}

View file

@ -95,7 +95,9 @@ public class ScannerInfoConsoleParserFactory {
getScannerInfoConsoleParser(scBuildInfo.getMakeBuilderConsoleParserId());
// initialize it with the utility
clParser.startup(currentProject, new ScannerInfoConsoleParserUtility(
currentProject, workingDirectory, markerGenerator), ScannerInfoCollector.getInstance());
currentProject, workingDirectory,
scBuildInfo.isSIProblemGenerationEnabled() ? markerGenerator : null),
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.core.scannerconfig.ScannerConfigUtil;
import org.eclipse.cdt.make.internal.core.MakeMessages;
import org.eclipse.cdt.make.internal.core.scannerconfig.util.TraceUtil;
import java.util.ArrayList;
@ -149,7 +150,9 @@ public class GCCScannerInfoConsoleParser implements IScannerInfoConsoleParser {
possibleFileName.endsWith(".c") || //$NON-NLS-1$
possibleFileName.endsWith(".cpp") || //$NON-NLS-1$
possibleFileName.endsWith(".cc") || //$NON-NLS-1$
possibleFileName.endsWith(".cxx")) { //$NON-NLS-1$
possibleFileName.endsWith(".cxx") || //$NON-NLS-1$
possibleFileName.endsWith(".C") || //$NON-NLS-1$
possibleFileName.endsWith(".CC")) { //$NON-NLS-1$
fileName = token;
}
@ -168,9 +171,13 @@ public class GCCScannerInfoConsoleParser implements IScannerInfoConsoleParser {
}
}
else {
TraceUtil.outputError("Unable to find file name: ", line); //$NON-NLS-1$
fUtil.generateMarker(fProject, -1, "Unable to find file name: " + line, //$NON-NLS-1$
IMarkerGenerator.SEVERITY_ERROR_RESOURCE, null);
final String error = MakeMessages.getString("ConsoleParser.Filename_Missing_Error_Message"); //$NON-NLS-1$
TraceUtil.outputError(error, line);
fUtil.generateMarker(fProject, -1, error + line, IMarkerGenerator.SEVERITY_WARNING, null);
}
if (file == null) {
// remove include paths since there was no chance to translate them
translatedIncludes.clear();
}
}
// Contribute discovered includes and symbols to the ScannerInfoCollector

View file

@ -22,6 +22,7 @@ import java.util.Vector;
import org.eclipse.cdt.core.IMarkerGenerator;
import org.eclipse.cdt.make.core.MakeCorePlugin;
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParserUtility;
import org.eclipse.cdt.make.internal.core.MakeMessages;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
@ -126,8 +127,11 @@ public class ScannerInfoConsoleParserUtility implements IScannerInfoConsoleParse
* Called by the console line parsers to generate a problem marker.
*/
public void generateMarker(IResource file, int lineNumber, String desc, int severity, String varName) {
Problem problem = new Problem(file, lineNumber, desc, severity, varName);
fErrors.add(problem);
// No need to collect markers if marker generator is not present
if (fMarkerGenerator != null) {
Problem problem = new Problem(file, lineNumber, desc, severity, varName);
fErrors.add(problem);
}
}
/**
@ -146,9 +150,9 @@ public class ScannerInfoConsoleParserUtility implements IScannerInfoConsoleParse
file = null;
// Create a problem marker
TraceUtil.outputError("Ambiguous file path: ", fileName); //$NON-NLS-1$
generateMarker(fProject, -1, "Ambiguous file path: "+fileName, //$NON-NLS-1$
IMarkerGenerator.SEVERITY_ERROR_RESOURCE, null);
final String error = MakeMessages.getString("ConsoleParser.Ambiguous_Filepath_Error_Message"); //$NON-NLS-1$
TraceUtil.outputError(error, fileName);
generateMarker(fProject, -1, error+fileName, IMarkerGenerator.SEVERITY_WARNING, null);
}
}
}
@ -265,6 +269,7 @@ public class ScannerInfoConsoleParserUtility implements IScannerInfoConsoleParse
// check if it is a cygpath
if (dir.toString().startsWith("/cygdrive/")) { //$NON-NLS-1$
char driveLetter = dir.toString().charAt(10);
driveLetter = (Character.isLowerCase(driveLetter)) ? Character.toUpperCase(driveLetter) : driveLetter;
StringBuffer buf = new StringBuffer();
buf.append(driveLetter);
buf.append(':');
@ -336,9 +341,9 @@ public class ScannerInfoConsoleParserUtility implements IScannerInfoConsoleParse
// check if file name starts with ".."
if (fileName.startsWith("..")) { //$NON-NLS-1$
// probably multiple choices for cwd, hopeless
TraceUtil.outputError("Unable to determine working directory for ", fileName); //$NON-NLS-1$
generateMarker(file, -1, "Unable to determine working directory for", //$NON-NLS-1$
IMarkerGenerator.SEVERITY_WARNING, fileName);
final String error = MakeMessages.getString("ConsoleParser.Working_Directory_Error_Message"); //$NON-NLS-1$
TraceUtil.outputError(error, fileName); //$NON-NLS-1$
generateMarker(file, -1, error, IMarkerGenerator.SEVERITY_WARNING, fileName);
break;
}
else {
@ -360,9 +365,9 @@ public class ScannerInfoConsoleParserUtility implements IScannerInfoConsoleParse
File dir = candidatePath.toFile();
include = candidatePath.toString();
if (!dir.exists()) {
TraceUtil.outputError("Nonexistent include path: ", include); //$NON-NLS-1$
generateMarker(file, -1, "Nonexistent include path: "+include, //$NON-NLS-1$
IMarkerGenerator.SEVERITY_WARNING, fileName);
final String error = MakeMessages.getString("ConsoleParser.Nonexistent_Include_Path_Error_Message"); //$NON-NLS-1$
TraceUtil.outputError(error, include);
// generateMarker(file, -1, error+include, IMarkerGenerator.SEVERITY_WARNING, fileName);
}
}
// TODO VMIR for now add unresolved paths as well
@ -375,8 +380,21 @@ public class ScannerInfoConsoleParserUtility implements IScannerInfoConsoleParse
* @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) {
char driveLetter = path.charAt(column - 1);
if (Character.isLowerCase(driveLetter)) {
StringBuffer sb = new StringBuffer();
if (column - 1 > 0) {
sb.append(path.substring(0, column-1));
}
sb.append(Character.toUpperCase(driveLetter));
sb.append(path.substring(column));
path = sb.toString();
}
}
if (path.indexOf('.') == -1 || path.equals(".")) { //$NON-NLS-1$
return path;
return (new Path(path)).toString(); // convert separators to '/'
}
// lose "./" segments since they confuse the Path normalization
StringBuffer buf = new StringBuffer(path);

View file

@ -248,6 +248,8 @@ ScannerConfigOptionsDialog.siProvider.cmd.use_default=Use default
ScannerConfigOptionsDialog.siProvider.cmd.label=Generate scanner info command:
ScannerConfigOptionsDialog.siProvider.parser.label=Command output parser:
ScannerConfigOptionsDialog.siProvider.cmd.error_message=Must enter a 'generate scanner info' command
ScannerConfigOptionsDialog.siProblem.group.label=Discovery problem reporting
ScannerConfigOptionsDialog.siProblem.generation.enable.label=Report path detection problems
# --- DiscoveredScannerConfigurationContainerPage ---
DiscoveredScannerConfigurationContainerPage.title=Edit container

View file

@ -85,6 +85,8 @@ public class DiscoveryOptionsBlock extends AbstractCOptionPage {
private static final String SI_PROVIDER_CMD_LABEL = PREFIX + ".siProvider.cmd.label"; //$NON-NLS-1$
private static final String SI_PROVIDER_PARSER_LABEL = PREFIX + ".siProvider.parser.label"; //$NON-NLS-1$
private static final String SI_PROVIDER_CMD_ERROR_MESSAGE = PREFIX + ".siProvider.cmd.error_message"; //$NON-NLS-1$
private static final String SI_PROBLEM_GROUP = PREFIX + ".siProblem.group.label"; //$NON-NLS-1$
private static final String ENABLE_SI_PROBLEM_GENERATION = PREFIX + ".siProblem.generation.enable.label"; //$NON-NLS-1$
private Button scEnabledButton;
private boolean needsSCNature = false;
@ -95,6 +97,7 @@ public class DiscoveryOptionsBlock extends AbstractCOptionPage {
private Combo makeBuilderSIParserComboBox;
private Button enableProviderCommandButton;
private Combo esiProviderParserComboBox;
private Button enableProblemGenerationButton;
private Preferences fPrefs;
private IScannerConfigBuilderInfo fBuildInfo;
@ -186,6 +189,7 @@ public class DiscoveryOptionsBlock extends AbstractCOptionPage {
}
buildInfo.setESIProviderConsoleParserId((String)providerParsers.get(esiProviderParserComboBox.getText()));
}
buildInfo.setSIProblemGenerationEnabled(isProblemGenerationEnabled());
}
}
};
@ -276,6 +280,7 @@ public class DiscoveryOptionsBlock extends AbstractCOptionPage {
if (createScannerConfigControls(composite, tabColumns)) {
createBuildOutputParserControls(composite);
createAfterBuildCmdControls(composite);
createProblemGenerationControls(composite);
// enable controls depending on the state of auto discovery
enableAllControls();
}
@ -454,7 +459,28 @@ public class DiscoveryOptionsBlock extends AbstractCOptionPage {
}
/**
*
* @param composite
*/
private void createProblemGenerationControls(Composite parent) {
Group problemGroup = ControlFactory.createGroup(parent, MakeUIPlugin.getResourceString(SI_PROBLEM_GROUP), 2);
((GridData)problemGroup.getLayoutData()).horizontalSpan = 2;
enableProblemGenerationButton = ControlFactory.createCheckBox(problemGroup,
MakeUIPlugin.getResourceString(ENABLE_SI_PROBLEM_GENERATION));
((GridData)enableProblemGenerationButton.getLayoutData()).horizontalSpan = 2;
((GridData)enableProblemGenerationButton.getLayoutData()).horizontalAlignment = GridData.FILL_HORIZONTAL;
boolean enabledProblemGeneration = fBuildInfo.isSIProblemGenerationEnabled();
enableProblemGenerationButton.setSelection(enabledProblemGeneration);
enableProblemGenerationButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
getContainer().updateContainer();
}
});
}
/**
* @param buildInfo
*/
private void setESIProviderCommandFrom(IScannerConfigBuilderInfo buildInfo) {
IPath sCommand = buildInfo.getESIProviderCommand();
@ -498,6 +524,10 @@ public class DiscoveryOptionsBlock extends AbstractCOptionPage {
return enableProviderCommandButton.getSelection();
}
private boolean isProblemGenerationEnabled() {
return enableProblemGenerationButton.getSelection();
}
/**
* Retrieves the state of scanner config discovery
*

View file

@ -98,6 +98,7 @@ public class ScannerConfigOptionsDialog extends Dialog {
private IPath fESIProviderCommand;
private String fESIProviderArguments;
private String fESIProviderConsoleParserId;
private boolean fSIParserGenerationEnabled;
public LocalStore(IScannerConfigBuilderInfo info) {
try {
@ -109,6 +110,7 @@ public class ScannerConfigOptionsDialog extends Dialog {
setESIProviderCommand(info.getESIProviderCommand());
setESIProviderArguments(info.getESIProviderArguments());
setESIProviderConsoleParserId(info.getESIProviderConsoleParserId());
setSIProblemGenerationEnabled(info.isSIProblemGenerationEnabled());
} catch (CoreException e) {
}
}
@ -169,6 +171,13 @@ public class ScannerConfigOptionsDialog extends Dialog {
public void setESIProviderConsoleParserId(String parserId) throws CoreException {
fESIProviderConsoleParserId = new String(parserId);
}
public boolean isSIProblemGenerationEnabled() {
return fSIParserGenerationEnabled;
}
public void setSIProblemGenerationEnabled(boolean enabled) throws CoreException {
fSIParserGenerationEnabled = enabled;
}
}
/**