Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-patch] fix for [Bug 36912] Unwanted prints from the new parser, for cdt_ 1_1

Title: Applied [ HEAD & 1_1 ] Parser bugfixes

 Logging debug messages of the parser and the C model builder only if CCorePlugin.debug is set to true.

 

Thanks,

Hoda

Index: model/org/eclipse/cdt/internal/core/model/Util.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Util.java,v
retrieving revision 1.3
diff -u -r1.3 Util.java
--- model/org/eclipse/cdt/internal/core/model/Util.java	26 Mar 2003 16:03:03 -0000	1.3
+++ model/org/eclipse/cdt/internal/core/model/Util.java	25 Apr 2003 19:04:05 -0000
@@ -10,6 +10,7 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
+import java.text.MessageFormat;
 
 import org.eclipse.cdt.core.CCorePlugin;
 import org.eclipse.cdt.core.model.CModelException;
@@ -156,9 +157,42 @@
 			IStatus.ERROR, 
 			message, 
 			e); 
-			
-		CCorePlugin.getDefault().getLog().log(status);
+		Util.log(status);			
 	}	
+	
+	public static void log(IStatus status){
+		CCorePlugin.getDefault().getLog().log(status);
+	}
+	
+	public static void log(String message){
+		IStatus status = new Status(IStatus.INFO, 
+		CCorePlugin.getDefault().getDescriptor().getUniqueIdentifier(), 
+		IStatus.INFO,
+		message,
+		null);
+		Util.log(status);
+	}
+	
+	public static void debugLog(String message) {
+		if (CCorePlugin.getDefault().isDebugging()) {			
+			// Time stamp
+			message = MessageFormat.format( "[{0}] {1}", new Object[] { new Long( System.currentTimeMillis() ), message } );
+			while (message.length() > 100) {
+				String partial = message.substring(0, 100);
+				message = message.substring(100);
+				System.out.println(partial + "\\");
+			}
+			if (message.endsWith("\n")) {
+				System.err.print(message);
+			} else {
+				System.out.println(message);
+			}
+		}
+	}
+	
+	public static void setDebugging(boolean value){
+		CCorePlugin.getDefault().setDebugging(value);
+	}
 	
 	/**
 	 * Combines two hash codes to make a new one.
Index: parser/org/eclipse/cdt/internal/core/model/CModelBuilder.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/model/CModelBuilder.java,v
retrieving revision 1.20
diff -u -r1.20 CModelBuilder.java
--- parser/org/eclipse/cdt/internal/core/model/CModelBuilder.java	25 Apr 2003 15:58:44 -0000	1.20
+++ parser/org/eclipse/cdt/internal/core/model/CModelBuilder.java	25 Apr 2003 19:04:05 -0000
@@ -95,7 +95,11 @@
 			System.out.println( "NullPointer exception generating CModel");
 			npe.printStackTrace();
 		}
-		System.out.println("CModel build: "+ ( System.currentTimeMillis() - startTime ) + "ms" );
+		 
+		// For the debuglog to take place, you have to call
+		// Util.setDebugging(true);
+		// Or set debug to true in the core plugin preference 
+		Util.debugLog("CModel build: "+ ( System.currentTimeMillis() - startTime ) + "ms");
 		return this.newElements;
 	}
 	
Index: parser/org/eclipse/cdt/internal/core/parser/Parser.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java,v
retrieving revision 1.39
diff -u -r1.39 Parser.java
--- parser/org/eclipse/cdt/internal/core/parser/Parser.java	25 Apr 2003 16:13:17 -0000	1.39
+++ parser/org/eclipse/cdt/internal/core/parser/Parser.java	25 Apr 2003 19:04:06 -0000
@@ -17,6 +17,8 @@
 import java.util.HashMap;
 import java.util.Map;
 
+import org.eclipse.cdt.internal.core.model.Util;
+
 public class Parser implements IParser {
 
 	private static int DEFAULT_OFFSET = -1; 
@@ -79,7 +81,10 @@
 	public boolean parse() throws Backtrack {
 		long startTime = System.currentTimeMillis();
 		translationUnit();
-		System.out.println("Parse " + (++parseCount) + ": "
+		// For the debuglog to take place, you have to call
+		// Util.setDebugging(true);
+		// Or set debug to true in the core plugin preference 
+		Util.debugLog( "Parse " + (++parseCount) + ": "
 			+ ( System.currentTimeMillis() - startTime ) + "ms"
 			+ ( parsePassed ? "" : " - parse failure" ));
 			

Back to the top