Daniele Varrazzo committed f9abff7

Parse the language of a PostgreSQL function also when prefix

This is the way pg_dump saves it.

Comments (0)

Files changed (2)


     rules deepcopy fails in this case.
     l = None
-    # TODO: the language can also be before the string
-    m = language_re.match(lexer.text[match.end():])
+    m = language_re.match(lexer.text[match.end():match.end()+100])
     if m is not None:
         l = lexer._get_lexer(
+    else:
+        m = list(language_re.finditer(
+            lexer.text[max(0, match.start()-100):match.start()]))
+        if m:
+            l = lexer._get_lexer(m[-1].group(1))
     if l:
         yield (match.start(1), String,


 LANGUAGE plpgsql;
+-- As returned by pg_dump
+CREATE FUNCTION test_function() RETURNS integer
+    AS $$
+    return 42;
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.