Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

A new command to jump to build errors for the current project.

This adds some code to parse_build.rb which extracts error messages and their location and stores it in a file .tm_build_errors in the project directory. When the command is invoked it attempts to find the nearest error, and then moves to the next one in the list.


git-svn-id: http://svn.textmate.org/trunk/Bundles/Xcode.tmbundle@8240 dfb7d73b-c2ec-0310-8fea-fb051d288c6d
  • Loading branch information...
commit 7b2c06f5900e149bc513f9b9e92b45f364270959 1 parent e223acc
@ciaran ciaran authored
View
57 Commands/Jump to Next Error.tmCommand
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>beforeRunningCommand</key>
+ <string>nop</string>
+ <key>command</key>
+ <string>#!/usr/bin/env ruby -wKU
+
+require ENV['TM_SUPPORT_PATH'] + '/lib/textmate'
+
+LogFile = ENV['TM_PROJECT_DIRECTORY'] + '/.tm_build_errors'
+
+abort "No errors found" unless File.exists?(LogFile)
+
+errors = []
+File.readlines(LogFile).map do |error|
+ file, line, error = error.split('|')
+ if existing_error = errors.find { |e| e[:file] == file and e[:line] == line }
+ existing_error[:error] &lt;&lt; error
+ else
+ errors &lt;&lt; {:file =&gt; file, :line =&gt; line, :error =&gt; error}
+ end
+end
+
+abort "No errors found" if errors.empty?
+
+current_error = nil
+
+errors.each_with_index do |error, index|
+ if error[:file] == ENV['TM_FILEPATH'] and error[:line] == ENV['TM_LINE_NUMBER']
+ current_error = index
+ break
+ end
+end
+
+if current_error
+ current_error += 1
+ current_error = 0 if current_error &gt; errors.size - 1
+else
+ current_error = 0
+end
+
+TextMate.go_to :file =&gt; errors[current_error][:file], :line =&gt; errors[current_error][:line]
+print errors[current_error][:error]</string>
+ <key>input</key>
+ <string>none</string>
+ <key>keyEquivalent</key>
+ <string>@=</string>
+ <key>name</key>
+ <string>Jump to Next Error</string>
+ <key>output</key>
+ <string>showAsTooltip</string>
+ <key>uuid</key>
+ <string>BA7499F1-F44C-43BC-9D81-AA1E889B35F7</string>
+</dict>
+</plist>
View
5 Support/bin/parse_build.rb
@@ -96,6 +96,8 @@ def tokenize
last_line = ""
#seen_first_line = false
+error_log = File.open(ENV['TM_PROJECT_DIRECTORY'] + '/.tm_build_errors', 'w')
+
formatter.start
#
@@ -144,6 +146,8 @@ def tokenize
path = $1
line_number = $2
error_desc = $3
+
+ error_log << [$1, $2, $3].join('|') + "\n"
# if the file doesn't exist, we probably snagged something that's not an error
if File.exist?(path)
@@ -186,6 +190,7 @@ def tokenize
end
end
+error_log.close
# report success/failure
success = /\*\* ((BUILD|CLEAN) SUCCEEDED) \*\*/.match(last_line)
View
4 info.plist
@@ -10,6 +10,10 @@
<string>This bundle is primarily to support building &lt;a href="http://developer.apple.com/tools/xcode/"&gt;Xcode&lt;/a&gt; project files, running the target, and related actions.</string>
<key>mainMenu</key>
<dict>
+ <key>excludedItems</key>
+ <array>
+ <string>BA7499F1-F44C-43BC-9D81-AA1E889B35F7</string>
+ </array>
<key>items</key>
<array>
<string>B0254A99-7750-4A06-937A-9A453ECE3A6C</string>
Please sign in to comment.
Something went wrong with that request. Please try again.