Skip to content

Conversation

@ventusfortis
Copy link

@ventusfortis ventusfortis commented Dec 24, 2025

This commit adds a runOnPart method for python imports, which enriches import nodes with missing data about location (#5651 and also fixes the code property to be exact in output

@ventusfortis ventusfortis changed the title Enrich Python import nodes with location metadata and exact code in the code property (#5651) [pysrc2cpg] Enrich Python import nodes with location metadata and exact code in the code property (#5651) Dec 24, 2025
}
}

override def runOnPart(diffGraph: DiffGraphBuilder, part: (Call, Assignment)): Unit = {
Copy link
Contributor

Choose a reason for hiding this comment

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

please change the base implementation of XImportsPass.runOnPart (and/or Imports.createImportNodeAndLink which it calls) so that your improvement applies for all frontends making use of it, not just for python.

}
}

private def importCodeFromCall(call: Call): String = {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a very welcome change, but this logic doesn't belong in the imports pass.

I believe the call for the import statement is emitted here, so that's where the code field should be set to a more appropriate value:

createCall(createIdentifierNode("import", Load, lineAndCol), "import", lineAndCol, arguments, Nil, None)

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.

2 participants