/
Create Package Declaration.tmCommand
53 lines (50 loc) · 1.57 KB
/
Create Package Declaration.tmCommand
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//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 ruby18 -w
# Generates a package statement based on conventions for the name of the source directory.
# If the root source folder name isn't matched either log a bug to get it added to the
# default list or define an environment variable named TM_JAVA_SOURCE_FOLDER_REGEX with
# a value of the regex to use to match folder names.
#
require ENV['TM_SUPPORT_PATH'] + '/lib/textmate'
package = []
package_regex = /^(src|tst)$/ # common source folder names
package_regex = /^(#{ENV['TM_JAVA_SOURCE_FOLDER_REGEX']})$/ if ENV['TM_JAVA_SOURCE_FOLDER_REGEX']
dir = ENV['TM_DIRECTORY'] || Dir.getwd
dir.split(File::SEPARATOR).reverse.each do |folder|
if folder !~ package_regex
package << folder
else
break
end
end
if !package.empty?
puts "package #{package.reverse.join('.')};"
end</string>
<key>input</key>
<string>none</string>
<key>inputFormat</key>
<string>text</string>
<key>name</key>
<string>Create Package Declaration</string>
<key>outputCaret</key>
<string>afterOutput</string>
<key>outputFormat</key>
<string>text</string>
<key>outputLocation</key>
<string>atCaret</string>
<key>scope</key>
<string>source.java</string>
<key>tabTrigger</key>
<string>pa</string>
<key>uuid</key>
<string>CBFE854E-917E-4ED5-BDBC-950C6B25B816</string>
<key>version</key>
<integer>2</integer>
</dict>
</plist>