Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-patch] Scanner config discovery - fixes for PRs 63471 & 68019

This patch fixes:
PR 63471: [Scanner Config] Better messages - new messages are introduced, 
internationalized, severity dropped to warning. Also there is an option in 
Discovery options block to disable generation of these messages.
PR 68019: [Scanner Config] Drive letters should be case insensitive - They 
are all now capital letters. Also only '/' separators are used in 
discovered paths.

Thanks,
Vmir

P.S. It would be great if this patch could make it in HEAD before 
candidate build (Monday morning).

Index: src/org/eclipse/cdt/make/core/scannerconfig/IScannerConfigBuilderInfo.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt-build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/scannerconfig/IScannerConfigBuilderInfo.java,v
retrieving revision 1.1
diff -u -r1.1 IScannerConfigBuilderInfo.java
--- src/org/eclipse/cdt/make/core/scannerconfig/IScannerConfigBuilderInfo.java	16 Mar 2004 20:35:25 -0000	1.1
+++ src/org/eclipse/cdt/make/core/scannerconfig/IScannerConfigBuilderInfo.java	25 Jun 2004 20:47:06 -0000
@@ -43,4 +43,7 @@
 
 	boolean isMakeBuilderConsoleParserEnabled();
 	void setMakeBuilderConsoleParserEnabled(boolean enabled) throws CoreException;
+
+	boolean isSIProblemGenerationEnabled();
+	void setSIProblemGenerationEnabled(boolean enabled) throws CoreException;
 }
Index: src/org/eclipse/cdt/make/internal/core/MakeMessages.properties
===================================================================
RCS file: /home/tools/org.eclipse.cdt-build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/MakeMessages.properties,v
retrieving revision 1.5
diff -u -r1.5 MakeMessages.properties
--- src/org/eclipse/cdt/make/internal/core/MakeMessages.properties	24 Jun 2004 19:55:36 -0000	1.5
+++ src/org/eclipse/cdt/make/internal/core/MakeMessages.properties	25 Jun 2004 20:47:06 -0000
@@ -43,4 +43,9 @@
 
 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
Index: src/org/eclipse/cdt/make/internal/core/PreferenceInitializer.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt-build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/PreferenceInitializer.java,v
retrieving revision 1.1
diff -u -r1.1 PreferenceInitializer.java
--- src/org/eclipse/cdt/make/internal/core/PreferenceInitializer.java	3 Jun 2004 14:37:42 -0000	1.1
+++ src/org/eclipse/cdt/make/internal/core/PreferenceInitializer.java	25 Jun 2004 20:47:06 -0000
@@ -55,6 +55,7 @@
 			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) {
 		}
 	}
Index: src/org/eclipse/cdt/make/internal/core/scannerconfig/ScannerConfigInfoFactory.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt-build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/ScannerConfigInfoFactory.java,v
retrieving revision 1.7
diff -u -r1.7 ScannerConfigInfoFactory.java
--- src/org/eclipse/cdt/make/internal/core/scannerconfig/ScannerConfigInfoFactory.java	7 Jun 2004 15:53:30 -0000	1.7
+++ src/org/eclipse/cdt/make/internal/core/scannerconfig/ScannerConfigInfoFactory.java	25 Jun 2004 20:47:06 -0000
@@ -46,6 +46,7 @@
 	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 @@
 			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();
 		}
Index: src/org/eclipse/cdt/make/internal/core/scannerconfig/ScannerInfoConsoleParserFactory.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt-build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/ScannerInfoConsoleParserFactory.java,v
retrieving revision 1.5
diff -u -r1.5 ScannerInfoConsoleParserFactory.java
--- src/org/eclipse/cdt/make/internal/core/scannerconfig/ScannerInfoConsoleParserFactory.java	5 May 2004 18:29:42 -0000	1.5
+++ src/org/eclipse/cdt/make/internal/core/scannerconfig/ScannerInfoConsoleParserFactory.java	25 Jun 2004 20:47:06 -0000
@@ -95,7 +95,9 @@
 						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});
Index: src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCScannerInfoConsoleParser.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt-build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCScannerInfoConsoleParser.java,v
retrieving revision 1.10
diff -u -r1.10 GCCScannerInfoConsoleParser.java
--- src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCScannerInfoConsoleParser.java	22 Jun 2004 13:19:49 -0000	1.10
+++ src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCScannerInfoConsoleParser.java	25 Jun 2004 20:47:06 -0000
@@ -17,6 +17,7 @@
 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 @@
 						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 @@
 					}
 				}
 				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
Index: src/org/eclipse/cdt/make/internal/core/scannerconfig/util/ScannerInfoConsoleParserUtility.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt-build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/ScannerInfoConsoleParserUtility.java,v
retrieving revision 1.8
diff -u -r1.8 ScannerInfoConsoleParserUtility.java
--- src/org/eclipse/cdt/make/internal/core/scannerconfig/util/ScannerInfoConsoleParserUtility.java	22 Jun 2004 13:19:49 -0000	1.8
+++ src/org/eclipse/cdt/make/internal/core/scannerconfig/util/ScannerInfoConsoleParserUtility.java	25 Jun 2004 20:47:06 -0000
@@ -22,6 +22,7 @@
 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 @@
 	 * 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 @@
 					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 @@
 				// 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 @@
 					// 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 @@
 				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 @@
 	 * @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);
Index: src/org/eclipse/cdt/make/internal/ui/MakeResources.properties
===================================================================
RCS file: /home/tools/org.eclipse.cdt-build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/MakeResources.properties,v
retrieving revision 1.27
diff -u -r1.27 MakeResources.properties
--- src/org/eclipse/cdt/make/internal/ui/MakeResources.properties	24 Jun 2004 19:55:34 -0000	1.27
+++ src/org/eclipse/cdt/make/internal/ui/MakeResources.properties	25 Jun 2004 20:47:19 -0000
@@ -248,6 +248,8 @@
 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
Index: src/org/eclipse/cdt/make/ui/dialogs/DiscoveryOptionsBlock.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt-build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/DiscoveryOptionsBlock.java,v
retrieving revision 1.9
diff -u -r1.9 DiscoveryOptionsBlock.java
--- src/org/eclipse/cdt/make/ui/dialogs/DiscoveryOptionsBlock.java	22 Jun 2004 12:43:49 -0000	1.9
+++ src/org/eclipse/cdt/make/ui/dialogs/DiscoveryOptionsBlock.java	25 Jun 2004 20:47:19 -0000
@@ -85,6 +85,8 @@
 	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 @@
 	private Combo makeBuilderSIParserComboBox;
 	private Button enableProviderCommandButton;
 	private Combo esiProviderParserComboBox;
+	private Button enableProblemGenerationButton;
 
 	private Preferences fPrefs;
 	private IScannerConfigBuilderInfo fBuildInfo;
@@ -186,6 +189,7 @@
 						}
 						buildInfo.setESIProviderConsoleParserId((String)providerParsers.get(esiProviderParserComboBox.getText()));
 					}
+					buildInfo.setSIProblemGenerationEnabled(isProblemGenerationEnabled());
 				}
 			}
 		};
@@ -276,6 +280,7 @@
 		if (createScannerConfigControls(composite, tabColumns)) {
 			createBuildOutputParserControls(composite);
 			createAfterBuildCmdControls(composite);
+			createProblemGenerationControls(composite);
 			// enable controls depending on the state of auto discovery
 			enableAllControls();
 		}
@@ -454,7 +459,28 @@
 	}
 
 	/**
-	 *  
+	 * @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();
@@ -496,6 +522,10 @@
 
 	private boolean isProviderCommandEnabled() {
 		return enableProviderCommandButton.getSelection();
+	}
+
+	private boolean isProblemGenerationEnabled() {
+		return enableProblemGenerationButton.getSelection();
 	}
 
 	/**
Index: src/org/eclipse/cdt/make/ui/dialogs/ScannerConfigOptionsDialog.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt-build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/ScannerConfigOptionsDialog.java,v
retrieving revision 1.3
diff -u -r1.3 ScannerConfigOptionsDialog.java
--- src/org/eclipse/cdt/make/ui/dialogs/ScannerConfigOptionsDialog.java	10 Jun 2004 15:17:06 -0000	1.3
+++ src/org/eclipse/cdt/make/ui/dialogs/ScannerConfigOptionsDialog.java	25 Jun 2004 20:47:20 -0000
@@ -98,6 +98,7 @@
 		private IPath fESIProviderCommand;
 		private String fESIProviderArguments;
 		private String fESIProviderConsoleParserId;
+		private boolean fSIParserGenerationEnabled;
 
 		public LocalStore(IScannerConfigBuilderInfo info) {
 			try {
@@ -109,6 +110,7 @@
 				setESIProviderCommand(info.getESIProviderCommand());
 				setESIProviderArguments(info.getESIProviderArguments());
 				setESIProviderConsoleParserId(info.getESIProviderConsoleParserId());
+				setSIProblemGenerationEnabled(info.isSIProblemGenerationEnabled());
 			} catch (CoreException e) {
 			}
 		}
@@ -168,6 +170,13 @@
 		}
 		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;
 		}
 	}
 

Back to the top