-
Notifications
You must be signed in to change notification settings - Fork 117
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
fix static variable not showing #435
Conversation
so the issue is that the variable rename is returned including the "static" modifier, right? What about other modifiers? |
i tested 'register、const、mutable、volatile、static', only static variable will return a modifier. it seems only static variable will has a modifier,for emphasize the variable's life time is different from loacal vairable. like below:
static variable and 'anonymous union' variable name has a space. if dont have a space "static borth = 10" and "anonymous union" will test fail. gdb_expansion.ts
|
what about something like: const resultRegex = /\s*(static )?([a-zA-Z_\-][a-zA-Z0-9_\-]*|\[\d+\])\s*=\s*/;
parseResult = (pushToStack: boolean = false) => {
const variableMatch = resultRegex.exec(value);
if (!variableMatch)
return undefined;
value = variableMatch[1]; although from the output presented, we can drop the leading |
|
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.
Thanks for the update! some things are still unclear to me, please go on.
src/mibase.ts
Outdated
if(typeof id == "string" && id.includes("static ")) { | ||
id = id.replace("static ", ""); | ||
} |
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.
please move that to the place where that id
with type string is actually used in this function, this both the review and following the code later an easier task
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.
thanks, i moved this handle to 'typeof id == "string" ' branch
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.
Ah, I see. I suggest to just use const string name = id.replace(/^static /, "");
(replace also checks for the include) + using name instead of id in the two places below - this way you can also leave the "id" definition as is.
I'll pull that afterwards, so we can go to the next PR.
Thanks for your work on this!
f3ee5d6
to
908b51f
Compare
src/mibase.ts
Outdated
@@ -531,6 +531,7 @@ export class MI2DebugSession extends DebugSession { | |||
this.sendErrorResponse(response, 1, `Could not expand variable: ${err}`); | |||
} | |||
} else if (typeof id == "string") { | |||
id.replace(/^static /, ""); |
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.
I wasn't aware that this changes the content of the id
object and that this can be done to a const
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.
I wasn't aware that this changes the content of the
id
object and that this can be done to a const
The code is useless; const variables do not have a const modifier.
908b51f
to
6f48d86
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #435 +/- ##
==========================================
- Coverage 20.47% 19.88% -0.60%
==========================================
Files 14 14
Lines 1807 1866 +59
Branches 392 406 +14
==========================================
+ Hits 370 371 +1
- Misses 1392 1450 +58
Partials 45 45 ☔ View full report in Codecov by Sentry. |
Nice simple one in the end! We should add some automated testing for that, but I am currently not sure how that works -so I've merged it. |
ok, i will add static tests |
the static member of Class People does not show
Log
does not show:
fixed: