mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Patch for Hoda Amer.
Logging debug messages of the parser and the C model builder only if CCorePlugin.debug is set to true.
This commit is contained in:
parent
2417cd02cb
commit
4d93d6c4df
3 changed files with 47 additions and 4 deletions
|
@ -10,6 +10,7 @@ import java.io.ByteArrayInputStream;
|
|||
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,10 +157,43 @@ public class Util {
|
|||
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() != null && 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.
|
||||
*/
|
||||
|
|
|
@ -95,7 +95,11 @@ public class CModelBuilder {
|
|||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,8 @@ import java.io.StringReader;
|
|||
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 @@ c, quick);
|
|||
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" ));
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue