Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 84880 Details for
Bug 121641
Errors in CDT console view when hovering while debugging
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
enhancement for debug text hovering
patch_debug_text_hover.txt (text/plain), 5.93 KB, created by
Tarek Sammoud
on 2007-12-10 12:11:17 EST
(
hide
)
Description:
enhancement for debug text hovering
Filename:
MIME Type:
Creator:
Tarek Sammoud
Created:
2007-12-10 12:11:17 EST
Size:
5.93 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.cdt.debug.ui >Index: src/org/eclipse/cdt/debug/internal/ui/editors/DebugTextHover.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt/all/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/editors/DebugTextHover.java,v >retrieving revision 1.22 >diff -u -r1.22 DebugTextHover.java >--- src/org/eclipse/cdt/debug/internal/ui/editors/DebugTextHover.java 14 Jun 2007 18:49:10 -0000 1.22 >+++ src/org/eclipse/cdt/debug/internal/ui/editors/DebugTextHover.java 10 Dec 2007 16:39:25 -0000 >@@ -13,11 +13,20 @@ > import java.util.regex.Matcher; > import java.util.regex.Pattern; > >+import org.eclipse.cdt.core.CCorePlugin; >+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; >+import org.eclipse.cdt.core.model.CoreModel; >+import org.eclipse.cdt.core.model.ITranslationUnit; > import org.eclipse.cdt.debug.core.model.ICStackFrame; >+import org.eclipse.cdt.debug.internal.core.model.CDebugTarget; > import org.eclipse.cdt.debug.internal.ui.CDebugUIUtils; > import org.eclipse.cdt.debug.ui.CDebugUIPlugin; > import org.eclipse.cdt.ui.text.c.hover.ICEditorTextHover; >+import org.eclipse.core.resources.IFile; >+import org.eclipse.core.resources.IProject; >+import org.eclipse.core.runtime.CoreException; > import org.eclipse.core.runtime.IAdaptable; >+import org.eclipse.core.runtime.Path; > import org.eclipse.debug.core.DebugException; > import org.eclipse.debug.ui.IDebugUIConstants; > import org.eclipse.jface.text.BadLocationException; >@@ -147,6 +156,8 @@ > if (match_found) { > return null; > } >+ if (!isValidHoverSymbol(hoverRegion)) >+ return null; > StringBuffer buffer = new StringBuffer(); > String result = evaluateExpression(frame, expression); > if (result == null) >@@ -165,6 +176,35 @@ > } > return null; > } >+ >+ /** >+ * Checks if the hovered symbol is valid for evaluation. >+ * >+ */ >+ public boolean isValidHoverSymbol(IRegion hoverRegion){ >+ boolean isValid = false; >+ int offset = hoverRegion.getOffset(); >+ int length = hoverRegion.getLength(); >+ IProject project = ((CDebugTarget)(getFrame().getDebugTarget())).getProject(); >+ IFile inputFile = project.getFile(new Path(getFrame().getFile().substring(getFrame().getFile().indexOf('/')))); >+ DebugTextVisitor astVisitor = new DebugTextVisitor(); >+ astVisitor.shouldVisitNames = true; >+ astVisitor.shouldVisitExpressions = true; >+ >+ if (CoreModel.isTranslationUnit(inputFile)) { >+ try { >+ ITranslationUnit tu = (ITranslationUnit) CCorePlugin.getDefault().getCoreModel().create(inputFile); >+ IASTTranslationUnit ast = tu.getAST(null,ITranslationUnit.AST_SKIP_ALL_HEADERS); >+ ast.accept(astVisitor); >+ } catch (CoreException x) { >+ CDebugUIPlugin.log(x); >+ } >+ } >+ if (astVisitor.containsExpression(offset, length)){ >+ isValid = true; >+ } >+ return isValid; >+ } > > /* > * (non-Javadoc) >Index: src/org/eclipse/cdt/debug/internal/ui/editors/DebugTextVisitor.java >=================================================================== >RCS file: src/org/eclipse/cdt/debug/internal/ui/editors/DebugTextVisitor.java >diff -N src/org/eclipse/cdt/debug/internal/ui/editors/DebugTextVisitor.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/cdt/debug/internal/ui/editors/DebugTextVisitor.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,76 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 STMicroelectronics. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * STMicroelectronics - Debug text hover enhancement >+ *******************************************************************************/ >+ >+package org.eclipse.cdt.debug.internal.ui.editors; >+ >+import java.util.ArrayList; >+ >+import org.eclipse.cdt.core.dom.ast.ASTVisitor; >+import org.eclipse.cdt.core.dom.ast.IASTDeclarator; >+import org.eclipse.cdt.core.dom.ast.IASTExpression; >+import org.eclipse.cdt.core.dom.ast.IASTFileLocation; >+import org.eclipse.cdt.core.dom.ast.IASTLiteralExpression; >+import org.eclipse.cdt.core.dom.ast.IASTName; >+ >+/** >+ * Enhances text hovering for C/C++ debugger >+ * >+ */ >+public class DebugTextVisitor extends ASTVisitor { >+ >+ private ArrayList expressionList = new ArrayList(); >+ >+ class ExpressionDescription { >+ int length; >+ int offset; >+ >+ public ExpressionDescription(int offset, int length) { >+ this.offset = offset; >+ this.length = length; >+ } >+ >+ public boolean equals(Object obj) { >+ return (this.length == ((ExpressionDescription) obj).length && this.offset == ((ExpressionDescription) obj).offset) ? true >+ : false; >+ } >+ } >+ >+ public int visit(IASTExpression expression) { >+ IASTFileLocation fileLocation = expression.getFileLocation(); >+ if (fileLocation != null) { >+ ExpressionDescription exprDesc = new ExpressionDescription( >+ fileLocation.getNodeOffset(), fileLocation.getNodeLength()); >+ if (!(expression instanceof IASTLiteralExpression) >+ && !expressionList.contains(exprDesc)) { >+ expressionList.add(exprDesc); >+ } >+ } >+ return super.visit(expression); >+ >+ } >+ >+ public boolean containsExpression(int offset, int length) { >+ return (expressionList.contains(new ExpressionDescription(offset, >+ length))); >+ } >+ >+ public int visit(IASTName name) { >+ IASTFileLocation fileLocation = name.getFileLocation(); >+ if (fileLocation != null) { >+ ExpressionDescription exprDesc = new ExpressionDescription( >+ fileLocation.getNodeOffset(), fileLocation.getNodeLength()); >+ if ((name.getParent() instanceof IASTDeclarator) >+ && !expressionList.contains(exprDesc)) >+ expressionList.add(exprDesc); >+ } >+ return super.visit(name); >+ } >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 121641
: 84880