[TxMt] Ant bundle patch

William Uther willu.mailingLists at cse.unsw.edu.au
Fri Jan 23 05:31:17 UTC 2009


Hi all,

   Below is a patch for the Ant bundle.  It fixes up the htmlization  
of the Ant output (escapes the output correctly so that, for example,  
generics display correctly).  It also turns htmlization back on, so  
that you can click on error messages to jump to the appropriate line  
again.  Finally, it adds source.java to the scope of the build command  
so you can build from a source file, not just from the build file.

   I haven't turned column parsing back on... yet.

Be well,

Will     :-}

Index: Commands/Build.tmCommand
===================================================================
--- Commands/Build.tmCommand	(revision 11139)
+++ Commands/Build.tmCommand	(working copy)
@@ -13,7 +13,7 @@

  TM_PROJECT_DIR=`dirname "$TM_PROJECT_FILEPATH"`;

-#TM_ANT_BUILD_PARSER=htmlize_ant.py
+TM_ANT_BUILD_PARSER=htmlize_ant.py

  if [[ "$TM_ANT_BUILD_PARSER" == "" ]]; then
  	TM_ANT_BUILD_PARSER=pre
@@ -42,7 +42,7 @@
  	<key>output</key>
  	<string>showAsHTML</string>
  	<key>scope</key>
-	<string>text.xml.ant</string>
+	<string>source.java, text.xml.ant</string>
  	<key>uuid</key>
  	<string>C7888301-C304-4EF2-A15F-5681A7D6D13C</string>
  </dict>
Index: Support/bin/htmlize_ant.py
===================================================================
--- Support/bin/htmlize_ant.py	(revision 11139)
+++ Support/bin/htmlize_ant.py	(working copy)
@@ -1,6 +1,6 @@
  #!/usr/bin/python

-import sys, os.path, re, os
+import sys, os.path, re, os, cgi

  matcher = re.compile(
      r'(/.*?):(\d+):\s*(.*)$'
@@ -20,6 +20,8 @@

  sys.stdout.flush()

+print "<pre>"
+
  ## read all data from stdin
  lastLine = None
  line = sys.stdin.readline()
@@ -33,15 +35,13 @@

      match = matcher.search(line)

-    print "<pre>"
-
      if not match:
-        print line
+        print cgi.escape(line)
      else:
          fn = match.group(1)

          if proj_dir and fn.startswith(proj_dir):
-            short_name = fn[len(proj_dir):]
+            short_name = '/.../' + fn[len(proj_dir):]
          else:
              short_name = fn

@@ -56,19 +56,21 @@
          ##             # print lastLine[(brktInd + 2):], colInd


-        print line[:match.start()].rstrip(),
-        print '<a href="txmt://open?url=file://%s&line=%s&column=%d"> 
%s:%s: %s</a>' % (
-            fn, match.group(2), colInd, short_name, match.group(2),  
match.group(3)
+        print cgi.escape(line[:match.start()].rstrip()),
+        print '<a href="txmt://open?url=file://%s&line=%s&column=%d"> 
%s:%s</a>: %s' % (
+            cgi.escape(fn), match.group(2), colInd,  
cgi.escape(short_name),
+            match.group(2), cgi.escape(match.group(3))
          ),
-        print line[match.end():]
+        print cgi.escape(line[match.end():])

-    print "</pre>"
      sys.stdout.flush()

      ## read next line
      lastLine = line
      line = sys.stdin.readline()

+print "</pre>"
+
  print """
      </body>
  </html>




More information about the textmate mailing list