MCPcopy Index your code
hub / github.com/bytebase/bytebase / ParsePLSQLOmni

Function ParsePLSQLOmni

backend/plugin/parser/plsql/omni.go:33–60  ·  view source on GitHub ↗

ParsePLSQLOmni parses SQL using omni's parser and returns an ast.List. This is the recommended entry point for new Oracle code that needs omni AST nodes.

(sql string)

Source from the content-addressed store, hash-verified

31// ParsePLSQLOmni parses SQL using omni's parser and returns an ast.List.
32// This is the recommended entry point for new Oracle code that needs omni AST nodes.
33func ParsePLSQLOmni(sql string) (*ast.List, error) {
34 statements, err := SplitSQL(sql)
35 if err != nil {
36 return nil, err
37 }
38
39 list := &ast.List{}
40 for _, statement := range statements {
41 if statement.Empty {
42 continue
43 }
44 parsed, err := oracleparser.Parse(statement.Text)
45 if err != nil {
46 if statement.Range != nil {
47 return nil, offsetOracleParseError(err, int(statement.Range.Start))
48 }
49 return nil, err
50 }
51 if parsed == nil {
52 continue
53 }
54 if statement.Range != nil {
55 offsetOmniLocs(parsed, int(statement.Range.Start))
56 }
57 list.Items = append(list.Items, parsed.Items...)
58 }
59 return list, nil
60}
61
62func offsetOracleParseError(err error, offset int) error {
63 var parseErr *oracleparser.ParseError

Calls 3

offsetOracleParseErrorFunction · 0.85
offsetOmniLocsFunction · 0.85
SplitSQLFunction · 0.70