-
Notifications
You must be signed in to change notification settings - Fork 675
[DYN-8997] CBN output port to show the name of the variable #16300
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
786411b
e134e5b
3c13bd2
a59d41b
f045f56
e61b95d
6267fb8
cce5976
4281703
6bfc2e6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,7 @@ | |
| using System.Linq; | ||
| using System.Text.RegularExpressions; | ||
| using Dynamo.Configuration; | ||
| using ProtoCore.AST.AssociativeAST; | ||
|
|
||
| namespace Dynamo.Graph.Nodes | ||
| { | ||
|
|
@@ -265,6 +266,72 @@ internal static IOrderedEnumerable<KeyValuePair<string, int>> GetDefinitionLineI | |
|
|
||
| return locationMap.OrderBy(p => p.Value); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Extracts cleaned individual code expressions as tooltip strings from a full code block. | ||
| /// </summary> | ||
| internal static List<string> GetCleanedCodeExpressionsForTooltips(string code) | ||
| { | ||
| if (string.IsNullOrWhiteSpace(code)) | ||
| return new List<string>(); | ||
|
|
||
| // Filter out full-line comments and remove inline comments | ||
| var cleanedCode = string.Join(" ", | ||
| code.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries) | ||
| .Where(line => !line.TrimStart().StartsWith("//")) | ||
| .Select(line => | ||
| { | ||
| var idx = line.IndexOf("//"); | ||
| return idx >= 0 ? line.Substring(0, idx) : line; | ||
| })); | ||
|
|
||
| // Split by semicolon and return trimmed expressions | ||
| return cleanedCode | ||
| .Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries) | ||
| .Select(expr => expr.Trim()) | ||
| .Where(expr => !string.IsNullOrEmpty(expr)) | ||
| .Select(expr => expr + ";") | ||
| .ToList(); | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm afraid this function needs to be entirely rewritten, as it shouldn't be using custom string manipulation when we have a full-fledged parser for DesignScript code and syntax. Will send another PR to clean this up. |
||
|
|
||
| /// <summary> | ||
| /// Infers a human-readable static type label (e.g., [int], [string]) from an associative AST node. | ||
| /// </summary> | ||
| internal static string InferStaticTypeFromNode(AssociativeNode node) | ||
| { | ||
| if (node == null) return null; | ||
|
|
||
| switch (node) | ||
| { | ||
| case IntNode: | ||
| return "[int]"; | ||
| case DoubleNode: | ||
| return "[double]"; | ||
| case BooleanNode: | ||
| return "[bool]"; | ||
| case StringNode: | ||
| return "[string]"; | ||
| case NullNode: | ||
| return "[null]"; | ||
| case CharNode: | ||
| return "[char]"; | ||
| case ExprListNode: | ||
| case ArrayNode: | ||
| return "[list]"; | ||
| case RangeExprNode: | ||
| return "[range]"; | ||
| case IdentifierNode idNode: | ||
| return idNode.Value; | ||
| case IdentifierListNode: | ||
| return "[identifier list]"; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't believe this is a user-friendly description. I'm confident that many users will not understand this technical wording.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. makes sense, what will be your suggestion in this case?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's no straightforward answer, unfortunately. An |
||
| case FunctionCallNode: | ||
| return "[function]"; | ||
| case InlineConditionalNode: | ||
| return "[conditional]"; | ||
| default: | ||
| return "[unknown]"; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about imperative language blocks? |
||
| } | ||
| } | ||
| } | ||
|
|
||
| /// <summary> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a finite loop. It runs for each
definallDefs. Why are you breaking out of it in between?