MCPcopy Create free account
hub / github.com/Yuy0ung/YuC0de / parseMethod

Method parseMethod

backend/engine/java_parser.go:363–505  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

361}
362
363func (p *Parser) parseMethod() *MethodNode {
364 // Skip annotations
365 for p.peek().Value == "@" {
366 p.next() // @
367 p.next() // Name
368 if p.peek().Value == "(" {
369 p.next() // consume (
370 p.skipBalanced("(", ")")
371 }
372 }
373
374 // Skip modifiers
375 modifiers := []string{"public", "private", "protected", "abstract", "static", "final", "synchronized", "native"}
376 for contains(modifiers, p.peek().Value) {
377 p.next()
378 }
379
380 // Generic type <T>
381 if p.peek().Value == "<" {
382 p.next() // consume <
383 p.skipBalanced("<", ">")
384 }
385
386 // Return Type
387 returnType := p.next().Value
388 // Handle array return type
389 for p.peek().Value == "[" {
390 p.next()
391 p.next()
392 returnType += "[]"
393 }
394 // Handle generic return type
395 if p.peek().Value == "<" {
396 p.next()
397 gen := p.consumeBalanced("<", ">")
398 returnType += "<" + gen + ">"
399 }
400
401 // Method Name
402 methodName := p.next().Value
403
404 // Parameters
405 p.consume("(")
406 var parameters []string
407 if p.peek().Value != ")" {
408 for {
409 // Parse one parameter
410 // Capture annotations
411 var annotations string
412 for p.peek().Value == "@" {
413 p.next() // @
414 annName := p.next().Value // Annotation Name
415 annotations += "@" + annName + " "
416 if p.peek().Value == "(" {
417 p.next()
418 p.skipBalanced("(", ")")
419 }
420 }

Callers 1

parseClassBodyMethod · 0.95

Calls 7

peekMethod · 0.95
nextMethod · 0.95
skipBalancedMethod · 0.95
consumeBalancedMethod · 0.95
consumeMethod · 0.95
extractCallsMethod · 0.95
containsFunction · 0.85

Tested by

no test coverage detected