mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Content Assist Work : Adding logging capabilities
This commit is contained in:
parent
c209012141
commit
ed90c66221
9 changed files with 225 additions and 9 deletions
|
@ -6,6 +6,9 @@ org.eclipse.cdt.core/debug/model=false
|
|||
# Reports parser activity
|
||||
org.eclipse.cdt.core/debug/parser=false
|
||||
|
||||
# Reports contentAssist activity
|
||||
org.eclipse.cdt.core/debug/contentassist=false
|
||||
|
||||
# Reports background indexer activity: indexing, saving index file, index queries
|
||||
org.eclipse.cdt.core/debug/indexmanager=false
|
||||
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
2004-01-08 Hoda Amer
|
||||
Added Content assist log capabilities
|
||||
|
||||
2004-01-06 Alain Magloire
|
||||
|
||||
Simple draft implementation of stabs debug format parsing.
|
||||
|
|
|
@ -23,5 +23,6 @@ public interface IDebugLogConstants {
|
|||
|
||||
public static final DebugLogConstant PARSER = new DebugLogConstant( 1 );
|
||||
public static final DebugLogConstant MODEL = new DebugLogConstant ( 2 );
|
||||
|
||||
public static final DebugLogConstant CONTENTASSIST = new DebugLogConstant ( 3 );
|
||||
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ public class Util implements ICLogConstants {
|
|||
|
||||
public static boolean VERBOSE_PARSER = false;
|
||||
public static boolean VERBOSE_MODEL = false;
|
||||
public static boolean VERBOSE_CONTENTASSIST = false;
|
||||
|
||||
private Util() {
|
||||
}
|
||||
|
@ -183,12 +184,16 @@ public class Util implements ICLogConstants {
|
|||
Util.log(status, logType);
|
||||
}
|
||||
|
||||
|
||||
public static void debugLog(String message, DebugLogConstant client) {
|
||||
Util.debugLog(message, client, true);
|
||||
}
|
||||
|
||||
public static void debugLog(String message, DebugLogConstant client, boolean addTimeStamp) {
|
||||
if( CCorePlugin.getDefault() == null ) return;
|
||||
if ( CCorePlugin.getDefault().isDebugging() && isActive(client)) {
|
||||
// Time stamp
|
||||
message = MessageFormat.format( "[{0}] {1}", new Object[] { new Long( System.currentTimeMillis() ), message } );
|
||||
if(addTimeStamp)
|
||||
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);
|
||||
|
@ -206,13 +211,16 @@ public class Util implements ICLogConstants {
|
|||
* @param client
|
||||
* @return
|
||||
*/
|
||||
private static boolean isActive(DebugLogConstant client) {
|
||||
public static boolean isActive(DebugLogConstant client) {
|
||||
if (client.equals(IDebugLogConstants.PARSER)){
|
||||
return VERBOSE_PARSER;
|
||||
}
|
||||
else if (client.equals(IDebugLogConstants.MODEL)){
|
||||
return VERBOSE_MODEL;
|
||||
}
|
||||
else if (client.equals(IDebugLogConstants.CONTENTASSIST)){
|
||||
return VERBOSE_CONTENTASSIST;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -719,6 +719,7 @@ public class CCorePlugin extends Plugin {
|
|||
private static final String MATCH_LOCATOR = CCorePlugin.PLUGIN_ID + "/debug/matchlocator" ; //$NON-NLS-1$
|
||||
private static final String PARSER = CCorePlugin.PLUGIN_ID + "/debug/parser" ; //$NON-NLS-1$
|
||||
private static final String DELTA = CCorePlugin.PLUGIN_ID + "/debug/deltaprocessor" ;
|
||||
private static final String CONTENTASSIST = CCorePlugin.PLUGIN_ID + "/debug/contentassist" ; //$NON-NLS-1$
|
||||
/**
|
||||
* Configure the plugin with respect to option settings defined in ".options" file
|
||||
*/
|
||||
|
@ -731,6 +732,9 @@ public class CCorePlugin extends Plugin {
|
|||
option = Platform.getDebugOption(MODEL);
|
||||
if(option != null) Util.VERBOSE_MODEL = option.equalsIgnoreCase("true") ; //$NON-NLS-1$
|
||||
|
||||
option = Platform.getDebugOption(CONTENTASSIST);
|
||||
if(option != null) Util.VERBOSE_CONTENTASSIST = option.equalsIgnoreCase("true") ; //$NON-NLS-1$
|
||||
|
||||
boolean indexFlag = false;
|
||||
option = Platform.getDebugOption(INDEX_MANAGER);
|
||||
if(option != null) {
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
2004-01-08 Hoda Amer
|
||||
Added Content assist log cpabilities
|
||||
|
||||
2004-01-07 Alain Magloire
|
||||
|
||||
Fix for bug 49595
|
||||
|
|
|
@ -17,6 +17,7 @@ import java.util.Iterator;
|
|||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.ICLogConstants;
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.parser.IParser;
|
||||
|
@ -33,6 +34,7 @@ import org.eclipse.cdt.core.parser.ScannerInfo;
|
|||
import org.eclipse.cdt.core.parser.ast.ASTClassKind;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTCodeScope;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTEnumerator;
|
||||
|
@ -49,7 +51,9 @@ import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind;
|
|||
import org.eclipse.cdt.core.parser.ast.IASTNode.LookupKind;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTNode.LookupResult;
|
||||
import org.eclipse.cdt.internal.core.CharOperation;
|
||||
import org.eclipse.cdt.internal.core.model.IDebugLogConstants;
|
||||
import org.eclipse.cdt.internal.core.model.IWorkingCopy;
|
||||
import org.eclipse.cdt.internal.core.model.Util;
|
||||
import org.eclipse.cdt.internal.core.parser.util.ASTUtil;
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
|
@ -384,6 +388,7 @@ public class CompletionEngine implements RelevanceConstants{
|
|||
|
||||
private LookupResult lookup(IASTScope searchNode, String prefix, LookupKind[] kinds, IASTNode context){
|
||||
try {
|
||||
logLookups (kinds);
|
||||
LookupResult result = searchNode.lookup (prefix, kinds, context);
|
||||
return result ;
|
||||
} catch (IASTNode.LookupException ilk ){
|
||||
|
@ -552,8 +557,16 @@ public class CompletionEngine implements RelevanceConstants{
|
|||
// 1- Parse the translation unit
|
||||
IASTCompletionNode completionNode = parse(sourceUnit, completionOffset);
|
||||
|
||||
if (completionNode == null)
|
||||
log("");
|
||||
|
||||
if (completionNode == null){
|
||||
log("Null Completion Node Error");
|
||||
return null;
|
||||
}
|
||||
|
||||
logNode("Scope = " , completionNode.getCompletionScope());
|
||||
logNode("Context = " , completionNode.getCompletionContext());
|
||||
logKind("Kind = ", completionNode.getCompletionKind().getEnumValue());
|
||||
|
||||
// set the completionStart and the completionLength
|
||||
completionStart = completionOffset - completionNode.getCompletionPrefix().length();
|
||||
|
@ -622,5 +635,185 @@ public class CompletionEngine implements RelevanceConstants{
|
|||
return completionNode;
|
||||
|
||||
}
|
||||
private void logKind(String message, int kindEnum){
|
||||
if (! CCorePlugin.getDefault().isDebugging() && Util.isActive(IDebugLogConstants.CONTENTASSIST) )
|
||||
return;
|
||||
|
||||
String kindStr = "";
|
||||
switch (kindEnum){
|
||||
case 0:
|
||||
kindStr = "MEMBER_REFERENCE";
|
||||
break;
|
||||
|
||||
case 1:
|
||||
kindStr = "SCOPED_REFERENCE";
|
||||
break;
|
||||
|
||||
case 2:
|
||||
kindStr = "FIELD_TYPE";
|
||||
break;
|
||||
|
||||
case 3:
|
||||
kindStr = "VARIABLE_TYPE";
|
||||
break;
|
||||
|
||||
case 4:
|
||||
kindStr = "ARGUMENT_TYPE";
|
||||
break;
|
||||
|
||||
case 5:
|
||||
kindStr = "SINGLE_NAME_REFERENCE";
|
||||
break;
|
||||
|
||||
case 6:
|
||||
kindStr = "TYPE_REFERENCE";
|
||||
break;
|
||||
|
||||
case 7:
|
||||
kindStr = "CLASS_REFERENCE";
|
||||
break;
|
||||
|
||||
case 8:
|
||||
kindStr = "NAMESPACE_REFERENCE";
|
||||
break;
|
||||
|
||||
case 9:
|
||||
kindStr = "EXCEPTION_REFERENCE";
|
||||
break;
|
||||
|
||||
case 10:
|
||||
kindStr = "MACRO_REFERENCE";
|
||||
break;
|
||||
|
||||
case 11:
|
||||
kindStr = "FUNCTION_REFERENCE";
|
||||
break;
|
||||
|
||||
case 12:
|
||||
kindStr = "CONSTRUCTOR_REFERENCE";
|
||||
break;
|
||||
|
||||
case 13:
|
||||
kindStr = "KEYWORD";
|
||||
break;
|
||||
|
||||
case 14:
|
||||
kindStr = "PREPROCESSOR_DIRECTIVE";
|
||||
break;
|
||||
|
||||
case 15:
|
||||
kindStr = "USER_SPECIFIED_NAME";
|
||||
break;
|
||||
|
||||
case 200:
|
||||
kindStr = "NO_SUCH_KIND";
|
||||
break;
|
||||
}
|
||||
log (message + kindStr);
|
||||
}
|
||||
private void logNode(String message, IASTNode node){
|
||||
if (! CCorePlugin.getDefault().isDebugging() && Util.isActive(IDebugLogConstants.CONTENTASSIST))
|
||||
return;
|
||||
|
||||
if(node == null){
|
||||
log(message + "null");
|
||||
return;
|
||||
}
|
||||
if(node instanceof IASTMethod){
|
||||
String name = "Method: ";
|
||||
name += ((IASTMethod)node).getName();
|
||||
log(message + name);
|
||||
return;
|
||||
}
|
||||
if(node instanceof IASTFunction){
|
||||
String name = "Function: ";
|
||||
name += ((IASTFunction)node).getName();
|
||||
log(message + name);
|
||||
return;
|
||||
}
|
||||
if(node instanceof IASTClassSpecifier){
|
||||
String name = "Class: ";
|
||||
name += ((IASTClassSpecifier)node).getName();
|
||||
log(message + name);
|
||||
return;
|
||||
}
|
||||
if(node instanceof IASTCompilationUnit){
|
||||
String name = "Global";
|
||||
log(message + name);
|
||||
return;
|
||||
}
|
||||
|
||||
log(message + node.toString());
|
||||
return;
|
||||
|
||||
}
|
||||
private void logLookups(LookupKind[] kinds){
|
||||
if (! CCorePlugin.getDefault().isDebugging() && Util.isActive(IDebugLogConstants.CONTENTASSIST))
|
||||
return;
|
||||
|
||||
StringBuffer kindName = new StringBuffer("Looking For ");
|
||||
for(int i = 0; i<kinds.length; i++){
|
||||
LookupKind kind = (LookupKind) kinds[i];
|
||||
switch (kind.getEnumValue()){
|
||||
case 0:
|
||||
kindName.append("ALL");
|
||||
break;
|
||||
case 1:
|
||||
kindName.append("STRUCTURES");
|
||||
break;
|
||||
case 2:
|
||||
kindName.append("STRUCS");
|
||||
break;
|
||||
case 3:
|
||||
kindName.append("UNIONS");
|
||||
break;
|
||||
case 4:
|
||||
kindName.append("CLASSES");
|
||||
break;
|
||||
case 5:
|
||||
kindName.append("FUNCTIONS");
|
||||
break;
|
||||
case 6:
|
||||
kindName.append("VARIABLES");
|
||||
break;
|
||||
case 7:
|
||||
kindName.append("LOCAL_VARIABLES");
|
||||
break;
|
||||
case 8:
|
||||
kindName.append("MEMBERS");
|
||||
break;
|
||||
case 9:
|
||||
kindName.append("METHODS");
|
||||
break;
|
||||
case 10:
|
||||
kindName.append("FIELDS");
|
||||
break;
|
||||
case 11:
|
||||
kindName.append("CONSTRUCTORS");
|
||||
break;
|
||||
case 12:
|
||||
kindName.append("NAMESPACES");
|
||||
break;
|
||||
case 13:
|
||||
kindName.append("MACROS");
|
||||
break;
|
||||
case 14:
|
||||
kindName.append("ENUMERATIONS");
|
||||
break;
|
||||
case 15:
|
||||
kindName.append("ENUMERATORS");
|
||||
break;
|
||||
case 16:
|
||||
kindName.append("THIS");
|
||||
break;
|
||||
}
|
||||
kindName.append(", ");
|
||||
}
|
||||
log (kindName.toString());
|
||||
}
|
||||
private void log(String message){
|
||||
if (! CCorePlugin.getDefault().isDebugging() && Util.isActive(IDebugLogConstants.CONTENTASSIST))
|
||||
return;
|
||||
Util.debugLog(message, IDebugLogConstants.CONTENTASSIST, false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -265,7 +265,7 @@ public class ResultCollector extends CompletionRequestorAdaptor {
|
|||
displayString = name;
|
||||
String functionPrototype = returnType + " " + name;
|
||||
if(parameterString != null){
|
||||
if ((parameterString.indexOf("(") != -1) && (parameterString.indexOf(")") != -1))
|
||||
if ((parameterString.indexOf("(") == -1) && (parameterString.indexOf(")") == -1))
|
||||
{
|
||||
functionPrototype += "(" + parameterString + ")";
|
||||
}
|
||||
|
|
|
@ -78,9 +78,9 @@ public class CUIPlugin extends AbstractUIPlugin {
|
|||
private static CUIPlugin fgCPlugin;
|
||||
private static ResourceBundle fgResourceBundle;
|
||||
private ImageDescriptorRegistry fImageDescriptorRegistry;
|
||||
|
||||
|
||||
static String SEPARATOR = System.getProperty("file.separator");
|
||||
|
||||
|
||||
// -------- static methods --------
|
||||
|
||||
static {
|
||||
|
@ -213,7 +213,7 @@ public class CUIPlugin extends AbstractUIPlugin {
|
|||
fDocumentProvider = null;
|
||||
fTextTools = null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the used document provider
|
||||
*/
|
||||
|
@ -308,6 +308,7 @@ public class CUIPlugin extends AbstractUIPlugin {
|
|||
*/
|
||||
public void startup() throws CoreException {
|
||||
super.startup();
|
||||
|
||||
runUI(new Runnable() {
|
||||
public void run() {
|
||||
registerAdapters();
|
||||
|
|
Loading…
Add table
Reference in a new issue