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

Various improvements to the import system #2020

Merged
merged 1 commit into from
Feb 10, 2025
Merged

Conversation

oxisto
Copy link
Member

@oxisto oxisto commented Feb 2, 2025

Unfortunately this PR is beginning to grow into something too big, so we probably want to merge it soon, but the problem is that things in the import / scope system are really tightly coupled. Hopefully a few things are now more de-coupled.

  • Instead of caching importedSymbols statically once (or twice), instead we resolve the import declaration back to the namespace (declaration) and update the symbol on-chance. This still not the perfect solution that I want, but it's a step into the right direction.
  • This also speeds up the ResolveMemberExpressionAmbiguityPass.
  • Rework resolveParentAlias to take scope information into account

Copy link

codecov bot commented Feb 3, 2025

Codecov Report

Attention: Patch coverage is 78.51852% with 29 lines in your changes missing coverage. Please review.

Project coverage is 78.22%. Comparing base (541dea1) to head (1de14ed).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...ain/kotlin/de/fraunhofer/aisec/cpg/ScopeManager.kt 72.72% 0 Missing and 6 partials ⚠️
...n/de/fraunhofer/aisec/cpg/passes/ImportResolver.kt 76.92% 2 Missing and 4 partials ⚠️
...ofer/aisec/cpg/frontends/cxx/DeclarationHandler.kt 58.33% 5 Missing ⚠️
...sec/cpg/graph/declarations/ParameterDeclaration.kt 50.00% 3 Missing and 1 partial ⚠️
.../fraunhofer/aisec/cpg/graph/edges/scopes/Import.kt 75.00% 3 Missing and 1 partial ⚠️
...ec/cpg/graph/edges/collections/UnwrappedEdgeSet.kt 33.33% 2 Missing ⚠️
...kotlin/de/fraunhofer/aisec/cpg/graph/Extensions.kt 0.00% 1 Missing ⚠️
...raunhofer/aisec/cpg/graph/scopes/NamespaceScope.kt 85.71% 0 Missing and 1 partial ⚠️
Additional details and impacted files
Files with missing lines Coverage Δ
...e/fraunhofer/aisec/cpg/graph/DeclarationBuilder.kt 94.59% <100.00%> (-0.04%) ⬇️
...isec/cpg/graph/declarations/FunctionDeclaration.kt 77.10% <100.00%> (-0.28%) ⬇️
.../aisec/cpg/graph/declarations/ImportDeclaration.kt 100.00% <100.00%> (ø)
.../de/fraunhofer/aisec/cpg/graph/edges/Extensions.kt 89.47% <100.00%> (+1.97%) ⬆️
...tlin/de/fraunhofer/aisec/cpg/graph/scopes/Scope.kt 82.66% <100.00%> (+0.97%) ⬆️
...isec/cpg/graph/scopes/StructureDeclarationScope.kt 68.75% <ø> (ø)
...er/aisec/cpg/graph/scopes/ValueDeclarationScope.kt 50.00% <ø> (ø)
...cpg/passes/ResolveMemberExpressionAmbiguityPass.kt 96.15% <100.00%> (-0.63%) ⬇️
...lin/de/fraunhofer/aisec/cpg/passes/TypeResolver.kt 95.45% <ø> (-0.11%) ⬇️
...fer/aisec/cpg/frontends/cxx/CXXLanguageFrontend.kt 77.65% <ø> (-0.07%) ⬇️
... and 12 more

... and 3 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@oxisto oxisto changed the title Re-design of ImportDeclaration::importedSymbols More dynamic caching of ImportDeclaration::importedSymbols Feb 3, 2025
@oxisto oxisto force-pushed the revamped-imported-symbols branch 3 times, most recently from 6d7ad11 to e5acb25 Compare February 5, 2025 22:47
@oxisto oxisto marked this pull request as ready for review February 6, 2025 12:29
@oxisto oxisto force-pushed the revamped-imported-symbols branch 3 times, most recently from faf7f9e to 43565b3 Compare February 6, 2025 20:22
@oxisto oxisto force-pushed the revamped-imported-symbols branch from 43565b3 to 8380b24 Compare February 10, 2025 14:11
@oxisto oxisto changed the title More dynamic caching of ImportDeclaration::importedSymbols Various improvements to the import system Feb 10, 2025
@oxisto oxisto force-pushed the revamped-imported-symbols branch from 8380b24 to e588a24 Compare February 10, 2025 14:16
Copy link
Collaborator

@konradweiss konradweiss left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@lshala lshala left a comment

Choose a reason for hiding this comment

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

Besides the minor point, it LGTM

…d we resolve the import declaration back to the namespace (declaration) and update the symbol on-chance.

Adding an 'import' edge
@oxisto oxisto force-pushed the revamped-imported-symbols branch from 03a114d to 1de14ed Compare February 10, 2025 15:24
@oxisto oxisto enabled auto-merge (squash) February 10, 2025 15:25
@oxisto oxisto merged commit 7962b3c into main Feb 10, 2025
2 checks passed
@oxisto oxisto deleted the revamped-imported-symbols branch February 10, 2025 15:28
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.

3 participants