Skip to content

refactor(semantic): take the last segment of a qualified name through symbols.LastSegment everywhere - #1496

Open
devin-ai-integration[bot] wants to merge 2 commits into
developfrom
refactor/last-segment-helpers
Open

devin-ai-integration[bot] wants to merge 2 commits into
developfrom
refactor/last-segment-helpers

Conversation

@devin-ai-integration

Copy link
Copy Markdown
Contributor

What and why

symbols.LastSegment (internal/semantic/symbols/index.go) already returns the text after the last :: of a qualified name. Nine packages above it carried a private copy of the same function under one name or another — leafName (semantics, solve, lsp, model), lastSegment (semantics, solve, passes), simpleName (semantics, view, a solve test), lastName (view), leafOf (passes), splitLastSegment (grpc, whose one caller discarded the parent half) — plus inline strings.LastIndex(…, "::") splits in solve/pin.go, runtime/random_functions.go and replext/repository. This PR deletes every copy and routes each call site (about 60) through symbols.LastSegment.

Output is unchanged: lastSeparator scans right to left for the first :: pair, which is the index strings.LastIndex(s, "::") returns, and both forms return the input untouched when there is no separator. The three packages that did not already import symbols (frontend/grpc, ir/view, exec/runtime, replext/repository) sit above it in the layer order, so no import cycle is introduced.

Out of scope and deliberately untouched: internal/exec/runtime/signal.go lastSegment (splits on ., a different operation), tools/census/metaclassmap/analyze.go lastName and tools/referee/xpect/exported.go leafOf (the tools module).

How it was verified

No tests were deleted or weakened; the test-only simpleName in internal/exec/solve/differential_test.go now calls symbols.LastSegment directly, and the collection_test.go assertions in semantics do the same.

$ go build ./...            # clean
$ go vet ./...              # clean
$ gofmt -l .                # (nothing)
$ python3 scripts/changelog.py check   # ok
$ go test ./...

Every package passed except five that hit Go's default 10 m per-package timeout under full-suite load on this machine (cmd/sysml, internal/exec/runtime, internal/exec/smt, tests/codegen, tests/wasm: panic: test timed out after 10m0s). Re-run alone and sequentially with -count=1 -timeout 60m:

ok  	github.com/Open-MBEE/OpenSysML/cmd/sysml	414.949s
ok  	github.com/Open-MBEE/OpenSysML/internal/exec/runtime	288.399s
ok  	github.com/Open-MBEE/OpenSysML/internal/exec/smt	274.755s
ok  	github.com/Open-MBEE/OpenSysML/tests/codegen	364.489s
ok  	github.com/Open-MBEE/OpenSysML/tests/wasm	104.394s

Checklist

  • go build ./..., go vet ./..., gofmt -l . and go test ./... pass locally (see above)
  • Tests added or updated for the change (existing tests retargeted at symbols.LastSegment; no new behaviour to pin)
  • Documentation extended where it already covers the surface (none of the deleted helpers is documented)
  • Changelog entry added as changes/unreleased/last-segment-helper.changed.md
  • baselines regenerated and make docs-counts run if a gate count moved (no gate count moved)
  • No internal work-item labels in the body, docs, or changelog

Link to Devin session: https://nasa-jpl-demo.devinenterprise.com/sessions/21d49a5a84a4479cacb0cdea1b07b415
Open in Devin Desktop: https://nasa-jpl-demo.devinenterprise.com/desktop/session/21d49a5a84a4479cacb0cdea1b07b415?variant=devin
Requested by: @HuiJun

… symbols.LastSegment everywhere

Delete the private copies (leafName, lastSegment, simpleName, lastName,
leafOf, splitLastSegment and the inline strings.LastIndex splits) in the
semantics, solve, runtime, view, passes, grpc, lsp, model and REPL
repository packages and call symbols.LastSegment at every site. The
output is identical: lastSeparator finds the same index strings.LastIndex
does.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@devin-ai-integration
devin-ai-integration Bot marked this pull request as ready for review October 25, 2026 04:41

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

…ent-helpers

Co-Authored-By: jason.han <hanhuijun@gmail.com>

# Conflicts:
#	internal/semantic/semantics/filter.go

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant