Skip to content
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

feat(smcache): Expose token name via Python bindings #703

Merged
merged 1 commit into from
Oct 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Unreleased

**Features**:

- Add `name` to `SourceMapCacheToken` Python bindings ([#703](https://github.com/getsentry/symbolic/pull/703))

## 10.0.0

**Features**:
Expand Down
1 change: 1 addition & 0 deletions py/symbolic/sourcemapcache.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def _from_objptr(cls, tm):
rv.line = tm.line
rv.col = tm.col
rv.src = decode_str(tm.src, free=False) or None
rv.name = decode_str(tm.name, free=False) or None
rv.function_name = decode_str(tm.function_name, free=False) or None

rv.context_line = decode_str(tm.context_line, free=False) or None
Expand Down
3 changes: 3 additions & 0 deletions symbolic-cabi/src/sourcemapcache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ pub struct SymbolicSmTokenMatch {
pub col: u32,
/// The path to the original source.
pub src: SymbolicStr,
/// The name of the source location as it is defined in the SourceMap.
pub name: SymbolicStr,
/// The name of the function containing the token.
pub function_name: SymbolicStr,

Expand Down Expand Up @@ -156,6 +158,7 @@ fn make_token_match(token: SourceLocation, context_lines: u32) -> *mut SymbolicS
line: token.line() + 1,
col: token.column() + 1,
src: SymbolicStr::new(token.file_name().unwrap_or_default()),
name: SymbolicStr::new(token.name().unwrap_or_default()),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The unwrap_or_default means we will return an empty string in case there is no name. is that really what we want?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, because decode_str will then return '', which then will fallback to None in sourcemapcache.py

function_name: SymbolicStr::new(function_name),

pre_context,
Expand Down