Skip to content

Java method extraction (signature + body) #16825

Answered by jketema
alibrahimzada asked this question in Q&A
Discussion options

You must be logged in to vote

I attempted to do this a few days back. However, there are a lot of patterns to consider a stopping criteria:

  1. Stop search backwards when there is a } for end of an earlier method
  2. Stop search backwards where this is a /* for comments

In my limited understanding of Java there should just be three cases: (1) you encounter a {, a }, or a ;. Comments you probably want to handle in a special way, because they can occur in awkward places, for example:

public /* ... */ static /* ... */ <V, WE, G extends Graph<V, WE>>
         SpanningWeightedEdgeMapperBuilder<V, WE> minimumSpanningTree(G graph) {

I was wondering if you can help with a query to generate text of a method from AST stored in DBs.

Replies: 1 comment 10 replies

Comment options

You must be logged in to vote
10 replies
@alibrahimzada
Comment options

@jketema
Comment options

@alibrahimzada
Comment options

@jketema
Comment options

Answer selected by alibrahimzada
@alibrahimzada
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants