-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsublime_cakephp_find.py
executable file
·812 lines (728 loc) · 27.5 KB
/
sublime_cakephp_find.py
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
# -*- coding: utf-8 -*-
import sublime, sublime_plugin
import threading
import functools
if sublime.version().startswith('3'):
from .sublime_cakephp_find_path import Path
from .sublime_cakephp_find_text import Text
from .sublime_cakephp_find_inflector import Inflector
#from .dump import Dump
elif sublime.version().startswith('2'):
from sublime_cakephp_find_path import Path
from sublime_cakephp_find_text import Text
from sublime_cakephp_find_inflector import Inflector
#from dump import Dump
class FindParentThread(threading.Thread):
def __init__(self, parent, find_type, find_name, new_list = [], count = 0):
# delete duplicate
list = []
for name in new_list:
new_name = name
if not new_name in list:
list.append(new_name)
self.parent = parent
self.find_type = find_type
self.find_name = find_name
self.list = list
self.count = count + 1
threading.Thread.__init__(self)
def run(self):
# search list class
class_name = self.list.pop(0)
file_path = self.parent.path.search_class_file_all_dir(class_name)
if file_path == False:
return
# read class file
if sublime.version().startswith('3'):
f = open(file_path, 'r', encoding='utf-8')
elif sublime.version().startswith('2'):
f = open(file_path)
file_content = f.read()
f.close()
# search method or variable
if self.find_type == "function":
move_point = Text().search_point_function(self.find_name, file_content)
elif self.find_type == "variable":
move_point = Text().search_point_variable(self.find_name, file_content)
elif self.find_type == "class_head":
move_point = Text().search_point_class_head(file_content)
if move_point != -1:
sublime.set_timeout(functools.partial(self.parent.find_parent_open_file,
file_path), 0)
return
# search parent class
(extend, interfaces) = Text().match_extend_implement(file_content)
if extend:
self.list.append(extend)
traits = Text().match_use_trait(file_content)
if traits:
self.list += traits
actsas = Text().match_model_actsas(file_content)
if actsas:
self.list += actsas
# stop roop if bug
if self.count > 100:
return
if len(self.list) == 0:
return
# call next
sublime.set_timeout(functools.partial(self.parent.find_parent_call_next,
self.list,
self.count), 0)
class SublimeCakephpFind(sublime_plugin.TextCommand):
def set_app_path(self):
self.path = Path()
self.current_file_type = None
self.action_name = None
self.plural_name = None
self.singular_name = None
self.lower_camelized_action_name = None
self.select_word = None
self.select_class_name = None
self.select_sub_name = None
self.select_sub_type = None
self.user_settings = self.view.settings().get('sublime_cakephp_find')
if not self.path.set_app(self.view, self.user_settings):
return False
return True
def is_file(self):
if (self.is_controller_file() or
self.is_model_file() or
self.is_view_file() or
self.is_component_file() or
self.is_behavior_file() or
self.is_helper_file() or
self.is_layout_file() or
self.is_css_file() or
self.is_plugin_file() or
self.is_core_list_file() or
self.is_app_file()):
return True
else:
return False
def is_controller_file(self):
match = self.path.match_controller_file(self.view)
if not match:
return False
self.plural_name = match
self.action_name = Text().find_action_name_this_place(self.view)
if self.action_name is not None:
# private function
if self.action_name[0] == '_' or self.action_name[-1] == '_':
self.action_name = None
else:
self.lower_camelized_action_name = Inflector().variablize(self.action_name)
self.snake_action_name = Inflector().underscore(self.action_name)
self.singular_name = Inflector().singularize(self.plural_name)
self.camelize_name = Inflector().camelize(Inflector().underscore(self.singular_name))
self.current_file_type = "controller"
return True
def is_model_file(self):
match = self.path.match_model_file(self.view)
if not match:
return False
self.singular_name = match
self.plural_name = Inflector().pluralize(self.singular_name)
self.camelize_name = Inflector().camelize(Inflector().underscore(self.singular_name))
self.current_file_type = "model"
return True
# Theme view is not supported.
def is_view_file(self):
(self.plural_name, self.action_name, view_extension) = self.path.match_view_file(self.view)
if self.plural_name is None:
return False
self.path.set_view_extension(view_extension)
self.lower_camelized_action_name = Inflector().variablize(self.action_name)
self.singular_name = Inflector().singularize(self.plural_name)
self.current_file_type = "view"
return True
def is_component_file(self):
match = self.path.match_component_file(self.view)
if not match:
return False
self.singular_name = match
self.current_file_type = "component"
return True
def is_behavior_file(self):
match = self.path.match_behavior_file(self.view)
if not match:
return False
self.singular_name = match
self.current_file_type = "behavior"
return True
def is_helper_file(self):
match = self.path.match_helper_file(self.view)
if not match:
return False
self.singular_name = match
self.current_file_type = "helper"
return True
def is_layout_file(self):
match = self.path.match_layout_file(self.view)
if not match:
return False
self.current_file_type = "layout"
return True
def is_css_file(self):
match = self.path.match_css_file(self.view)
if not match:
return False
self.current_file_type = "css"
return True
def is_plugin_file(self):
match = self.path.match_plugin_file(self.view)
if not match:
return False
self.current_file_type = "plugin"
return True
def is_core_list_file(self):
match = self.path.match_core_list_file(self.view)
if not match:
return False
self.current_file_type = "core"
return True
def is_app_file(self):
match = self.path.match_app_file(self.view)
if not match:
return False
self.current_file_type = "app"
return True
def is_word_only_controller(self):
return (self.is_render_function() or
self.is_redirect_function() or
self.is_layout_variable())
def is_word_only_view(self):
return (self.is_element_function() or
self.is_javascript_function() or
self.is_css_function() or
self.is_tag_id_class() or
self.is_image_function())
def is_word_only_helper(self):
return self.is_image_function()
def is_word_only_layout(self):
return (self.is_element_function() or
self.is_javascript_function() or
self.is_css_function() or
self.is_tag_id_class() or
self.is_image_function())
def is_word_only_css(self):
return self.is_background_image()
def is_word_any_file(self):
if (self.is_app_import() or
self.is_app_uses() or
self.is_new_class() or
self.is_local_function() or
self.is_email_template() or
self.is_datasource() or
self.is_route() or
self.is_namespace_use() or
self.is_include_require() or
self.is_extend_implement() or
self.is_configure_load() or
self.is_configure_read() or
self.is_view_blocks() or
self.is_view_fetch() or
self.is_enclosed_word() or
self.is_class_operator()):
return True
return False
def is_render_function(self):
(plugin_name, controller_name, view_name, self.layout_name) = Text().match_render_function(self.select_line_str)
if not view_name:
return False
if self.layout_name:
if self.layout_name == self.select_word:
self.path.switch_to_category(self.view, 'layout', self.layout_name)
return True
if not controller_name:
controller_name = self.plural_name
return self.path.switch_to_view(self.view, controller_name, view_name, plugin_name)
def is_redirect_function(self):
(controller_name, self.action_name) = Text().match_redirect_function(self.select_line_str)
if self.action_name is None:
return False
if controller_name is None:
controller_name = self.plural_name
file_path = self.path.search_class_file_all_dir(self.path.complete_file_name('controller', controller_name, False), self.current_file_type)
if file_path == False:
return False
self.path.set_open_file_callback(Text().move_point_function, self.action_name)
self.path.switch_to_file(file_path, self.view)
return True
def is_layout_variable(self):
(plugin_name, self.layout_name) = Text().match_layout_variable(self.select_line_str)
if self.layout_name is None:
return False
layout_file_name = self.path.complete_file_name('layout', self.layout_name)
category_path = self.path.get_category_path('layout', plugin_name)
if category_path == False:
return False
file_path = category_path + layout_file_name
self.path.switch_to_file(file_path, self.view)
return True
def is_element_function(self):
(plugin_name, self.element_name) = Text().match_element_function(self.select_line_str)
if self.element_name is None:
return False
element_file_name = self.path.complete_file_name('element', self.element_name)
category_path = self.path.get_category_path('element', plugin_name)
if category_path == False:
return False
file_path = category_path + element_file_name
self.path.switch_to_file(file_path, self.view)
return True
def is_javascript_function(self):
self.javascript_name = Text().match_javascript_function(self.select_line_str)
if self.javascript_name is None:
return False
javascript_file_name = self.path.complete_file_name('javascript', self.javascript_name)
file_path = self.path.search_file_recursive(javascript_file_name, self.path.folder_path["javascript"])
if file_path == False:
return False
self.path.switch_to_file(file_path, self.view)
return True
def is_css_function(self):
self.css_name = Text().match_css_function(self.select_line_str)
if self.css_name is None:
return False
css_file_name = self.path.complete_file_name('css', self.css_name)
file_path = self.path.search_file_recursive(css_file_name, self.path.folder_path["css"])
if file_path == False:
return False
self.path.switch_to_file(file_path, self.view)
return True
def is_tag_id_class(self):
(id_list, class_list) = Text().match_tag_id_class(self.select_line_str)
name = None
type = None
for str in id_list:
if str == self.select_css_tag_word:
name = str
type = 'id'
for str in class_list:
if str == self.select_css_tag_word:
name = str
type = 'class'
if name is None:
return False
self.path.set_open_file_callback(Text().move_line_number, 0) # 0: dummy
self.copy_word_to_find_panel('css_word')
self.path.search_css_list(self.view, name, type)
return True
def is_background_image(self):
image_path = Text().match_background_image(self.select_line_str)
if image_path is None:
return False
file_path = self.path.search_file_recursive(image_path, self.path.folder_path["image"])
if file_path == False:
return False
self.path.execute(file_path)
return True
def is_image_function(self):
image_path = Text().match_html_image(self.select_line_str)
if image_path is None:
return False
file_path = self.path.search_file_recursive(image_path, self.path.folder_path["image"])
if file_path == False:
return False
self.path.execute(file_path)
return True
def is_new_class(self):
self.new_class_name = Text().match_new_class(self.select_line_str)
if not self.new_class_name or self.new_class_name != self.select_word:
return False
file_path = self.path.search_class_file_all_dir(self.new_class_name, self.current_file_type)
if file_path == False:
return False
self.path.switch_to_file(file_path, self.view)
return True
def is_enclosed_word(self):
if not self.enclosed_word:
return False
if self.is_fixture():
return True
split = self.enclosed_word.split('.')
class_name = split[-1]
if len(split) > 1:
plugin_name = split[0]
file_path = self.path.search_class_file_plugin_all(class_name, self.current_file_type, plugin_name)
else:
file_path = self.path.search_class_file_all_dir(class_name, self.current_file_type)
if not file_path:
return False
self.path.switch_to_file(file_path, self.view)
return True
def is_fixture(self):
split = self.enclosed_word.split('.')
if len(split) == 1 or not Text().match_fixture(self.enclosed_word):
return False
type = split[0]
if type == "plugin":
plugin_name = split[1]
class_name = split[2]
else:
plugin_name = False
class_name = split[1]
return self.path.switch_to_fixture(self.view, type, class_name, plugin_name)
def is_class_operator(self):
if self.select_class_name is None:
return False
if (self.select_class_name == "this" or
self.select_class_name == "static" or
self.select_class_name == "self" or
self.select_class_name == "parent"):
return self.find_type_this()
# search class
list = [self.select_class_name]
if self.select_sub_type is None:
self.select_sub_type = "class_head"
self.select_sub_name = ""
thread = FindParentThread(self, self.select_sub_type, self.select_sub_name, list)
thread.start()
return True
def is_app_import(self):
(plugin_name, folder_name, file_name) = Text().match_app_import(self.select_line_str)
if not file_name:
return False
if plugin_name and folder_name:
category_path = self.path.get_category_path(folder_name.lower(), plugin_name)
if not category_path:
return False
unserscore_name = Inflector().underscore(file_name)
camelize_name = Inflector().camelize(file_name)
file_path = self.path.search_file_recursive(file_name + ".php", category_path)
if not file_path:
file_path = self.path.search_file_recursive(unserscore_name + ".php", category_path)
if not file_path:
file_path = self.path.search_file_recursive(camelize_name + ".php", category_path)
if not file_path:
return False
self.path.switch_to_file(file_path, self.view)
else:
file_path = self.path.search_class_file_all_dir(file_name, self.current_file_type)
if not file_path:
return False
self.path.switch_to_file(file_path, self.view)
return True
def is_app_uses(self):
(plugin_name, folder_name, file_name) = Text().match_app_uses(self.select_line_str)
if not file_name:
return False
if plugin_name and folder_name:
category_path = self.path.get_category_path(folder_name.lower(), plugin_name)
if not category_path:
return False
file_path = category_path + file_name + ".php"
self.path.switch_to_file(file_path, self.view)
else:
file_path = self.path.search_class_file_all_dir(file_name, self.current_file_type)
if not file_path:
return False
self.path.switch_to_file(file_path, self.view)
return True
def is_local_function(self):
(plugin_name, msg_id) = Text().match_local_function(self.select_line_str)
if not msg_id:
return False
self.path.set_open_file_callback(Text().move_point_msgid, msg_id)
return self.path.switch_to_locale(self.view, plugin_name)
def is_datasource(self):
(plugin_name, text) = Text().match_datasource(self.select_line_str)
if not text:
return False
return self.path.path_to_datasource(self.view, plugin_name, text)
def is_email_template(self):
(template_name, layout_name) = Text().match_email_template(self.select_line_str)
if not template_name and not layout_name:
return False
if (layout_name and layout_name != template_name and
(not template_name or self.enclosed_word == layout_name)):
(plugin_name, file_name) = self.path.split_plugin_name(layout_name)
category_path = self.path.get_category_path('email_layout', plugin_name)
elif template_name:
(plugin_name, file_name) = self.path.split_plugin_name(template_name)
category_path = self.path.get_category_path('email', plugin_name)
else:
return False
if not category_path:
return False
return self.path.switch_to_email_template(self.view, category_path, file_name)
def is_route(self):
if not self.path.is_routes_file(self.view):
return False
(plugin_name, controller_name, action_name) = Text().match_route(self.select_line_str)
if not controller_name:
return False
category_path = self.path.get_category_path("controller", plugin_name)
if not category_path:
return False
file_path = category_path + self.path.complete_file_name('controller', controller_name)
if action_name:
self.path.set_open_file_callback(Text().move_point_function, action_name)
self.path.switch_to_file(file_path, self.view)
return True
def is_include_require(self):
(up_dir_count, path_words) = Text().match_include_require(self.select_line_str)
if not path_words:
return False
file_path = self.path.convert_include_require_word(self.view, up_dir_count, path_words)
self.path.switch_to_file(file_path, self.view)
return True
def is_namespace_use(self):
class_name = Text().match_namespace_use(self.select_line_str)
if not class_name:
return False
file_path = self.path.search_class_file_all_dir(class_name, self.current_file_type)
if file_path == False:
return False
self.path.switch_to_file(file_path, self.view)
return True
def is_extend_implement(self):
(line_extend, line_interfaces) = Text().match_extend_implement(self.select_line_str)
(extend, interfaces) = Text().match_extend_implement(Text().view_content(self.view))
class_name = False
if extend:
if extend == self.select_word:
class_name = extend
if interfaces:
for interface in interfaces:
if interface == self.select_word:
class_name = interface
# When a cursor is on line and outside word
if not class_name:
if line_extend:
class_name = line_extend
elif line_interfaces:
class_name = line_interfaces[0]
if not class_name:
return False
file_path = self.path.search_class_file_all_dir(class_name, self.current_file_type)
if file_path == False:
return False
self.path.switch_to_file(file_path, self.view)
return True
def is_configure_load(self):
(match_name, plugin_name, setting_name) = Text().match_configure_load(self.select_line_str)
if not setting_name or match_name != self.enclosed_word:
return False
file_path = self.path.get_configure_load_file(plugin_name, setting_name)
if file_path == False:
return False
self.path.switch_to_file(file_path, self.view)
return True
def is_configure_read(self):
word = Text().match_configure_read(self.select_line_str)
if not word or word != self.enclosed_word:
return False
load_files = self.path.get_configure_load_files(Text().match_configure_load, self.view)
if len(load_files) == 0:
return False
path_app_list = self.path.get_configure_file(Text().match_configure_load_variables, load_files, word)
if len(path_app_list) == 0:
return False
self.path.set_open_file_callback(Text().move_line_number, 0) # 0: dummy
self.path.show_panel_result_list(self.view, path_app_list, {"line_number": True})
return True
def is_view_blocks(self):
view_block_name = Text().match_view_blocks(self.select_line_str)
if not view_block_name:
return False
self.path.set_open_file_callback(Text().move_line_number, 0) # 0: dummy
return self.path.find_view_fetch_list(self, view_block_name, Text().match_view_fetch)
def is_view_fetch(self):
view_fetch_name = Text().match_view_fetch(self.select_line_str)
if not view_fetch_name:
return False
self.path.set_open_file_callback(Text().move_line_number, 0) # 0: dummy
return self.path.find_view_block_list(self, view_fetch_name, Text().match_view_blocks)
def copy_word_to_find_panel(self, type = 'word'):
if type == 'word':
region = self.select_word_region
elif type == 'css_word':
region = self.select_css_tag_region
self.view.sel().add(region)
self.view.window().run_command("show_panel", {"panel": "find"})
self.view.window().run_command("hide_panel")
if len(self.view.sel()) > 1:
self.view.sel().subtract(region)
def find_type_this(self):
if self.select_sub_type is None:
return False
if (self.select_class_name == "this" or
self.select_class_name == "static" or
self.select_class_name == "self"):
if self.select_sub_type == "function":
move_flag = Text().move_point_function(self.view, [self.select_sub_name])
elif self.select_sub_type == "variable":
move_flag = Text().move_point_variable(self.view, [self.select_sub_name])
if move_flag:
return True
if self.select_class_name == "static":
return True # True because user miss type
# this, self, parent
# search parent class
list = []
(extend, interfaces) = Text().match_extend_implement(Text().view_content(self.view))
if extend:
list.append(extend)
traits = Text().match_use_trait(Text().view_content(self.view))
if traits:
list += traits
actsas = Text().match_model_actsas(Text().view_content(self.view))
if actsas:
list += actsas
if len(list) == 0:
return True
thread = FindParentThread(self, self.select_sub_type, self.select_sub_name, list)
thread.start()
return True
def find_parent_call_next(self, list = [], count = 0):
thread = FindParentThread(self, self.select_sub_type, self.select_sub_name, list, count)
thread.start()
def find_parent_open_file(self, file_path):
if self.select_sub_type == "function":
self.path.set_open_file_callback(Text().move_point_function, self.select_sub_name)
elif self.select_sub_type == "variable":
self.path.set_open_file_callback(Text().move_point_variable, self.select_sub_name)
self.path.switch_to_file(file_path, self.view)
class CakeFindCommand(SublimeCakephpFind):
def run(self, edit):
if not self.set_app_path():
return False
if not self.is_file():
sublime.status_message("Can't find file type.")
return
(self.select_word, self.select_css_tag_word, self.select_word_region,
self.select_css_tag_region, self.select_line_str, self.select_class_name,
self.select_sub_name, self.select_sub_type, self.enclosed_word) = Text().get_cursol_info(self.view)
found = False
if self.current_file_type == "controller":
found = self.is_word_only_controller()
elif self.current_file_type == "view":
found = self.is_word_only_view()
elif self.current_file_type == "helper":
found = self.is_word_only_helper()
elif self.current_file_type == "layout":
found = self.is_word_only_layout()
elif self.current_file_type == "css":
found = self.is_word_only_css()
if found:
return
if not self.is_word_any_file():
sublime.status_message("Can't find file.")
return
class CakeGrepCommand(SublimeCakephpFind):
def run(self, edit):
if not self.set_app_path():
return
where = self.path.get_grep_where(self.view, self.user_settings)
self.view.window().run_command("show_panel", {"panel": "find_in_files", "where": where})
class CakeSwitchToModelCommand(SublimeCakephpFind):
def run(self, edit):
if not self.set_app_path():
return
if not self.is_file() or self.singular_name is None:
sublime.status_message("Can't switch to model.")
return
self.path.switch_to_category(self.view, 'model', self.singular_name)
class CakeSwitchToControllerCommand(SublimeCakephpFind):
def run(self, edit):
if not self.set_app_path():
return
if not self.is_file() or self.plural_name is None:
sublime.status_message("Can't switch to contoroller.")
return
if self.action_name is not None:
self.path.set_open_file_callback(Text().move_point_controller_action, self.action_name)
self.path.switch_to_category(self.view, 'controller', self.plural_name)
class CakeSwitchToViewCommand(SublimeCakephpFind):
def run(self, edit):
if not self.set_app_path():
return
if not self.is_file() or self.action_name is None or self.plural_name is None:
sublime.status_message("Can't switch to view.")
return
return self.path.switch_to_view(self.view, self.plural_name, self.action_name)
class CakeSwitchToTestCommand(SublimeCakephpFind):
def run(self, edit):
if not self.set_app_path():
return
if not self.is_file():
sublime.status_message("Can't switch to test file.")
return
type = self.current_file_type
if type != "plugin" and type != "core":
type = "app"
return self.path.switch_to_test(self.view, type)
class CakeShowDirectoryListCommand(SublimeCakephpFind):
def run(self, edit):
if not self.set_app_path(): return
self.path.show_dir_list(self.path.get_this_dir(self.view), self.view)
class CakeShowControllerListCommand(SublimeCakephpFind):
def run(self, edit):
if not self.set_app_path(): return
self.path.show_dir_list_by_folder("controller", self.view)
class CakeShowModelListCommand(SublimeCakephpFind):
def run(self, edit):
if not self.set_app_path(): return
self.path.show_dir_list_by_folder("model", self.view)
class CakeShowViewListCommand(SublimeCakephpFind):
def run(self, edit):
if not self.set_app_path(): return
self.path.show_dir_list_by_folder("view", self.view)
class CakeShowComponentListCommand(SublimeCakephpFind):
def run(self, edit):
if not self.set_app_path(): return
self.path.show_dir_list_by_folder("component", self.view)
class CakeShowBehaviorListCommand(SublimeCakephpFind):
def run(self, edit):
if not self.set_app_path(): return
self.path.show_dir_list_by_folder("behavior", self.view)
class CakeShowHelperListCommand(SublimeCakephpFind):
def run(self, edit):
if not self.set_app_path(): return
self.path.show_dir_list_by_folder("helper", self.view)
class CakeShowLibListCommand(SublimeCakephpFind):
def run(self, edit):
if not self.set_app_path(): return
self.path.show_dir_list_by_folder("lib", self.view)
class CakeShowVendorListCommand(SublimeCakephpFind):
def run(self, edit):
if not self.set_app_path(): return
self.path.show_dir_list_by_folder("vendor", self.view)
class CakeShowLayoutListCommand(SublimeCakephpFind):
def run(self, edit):
if not self.set_app_path(): return
self.path.show_dir_list_by_folder("layout", self.view)
class CakeShowCssListCommand(SublimeCakephpFind):
def run(self, edit):
if not self.set_app_path(): return
self.path.show_dir_list_by_folder("css", self.view)
class CakeShowJavascriptListCommand(SublimeCakephpFind):
def run(self, edit):
if not self.set_app_path(): return
self.path.show_dir_list_by_folder("javascript", self.view)
class CakeShowElementListCommand(SublimeCakephpFind):
def run(self, edit):
if not self.set_app_path(): return
self.path.show_dir_list_by_folder("element", self.view)
class CakeShowConfigListCommand(SublimeCakephpFind):
def run(self, edit):
if not self.set_app_path(): return
self.path.show_dir_list_by_folder("config", self.view)
class CakeShowPluginListCommand(SublimeCakephpFind):
def run(self, edit):
if not self.set_app_path(): return
self.path.show_dir_list_by_folder("plugin", self.view)
class CakeShowTestListCommand(SublimeCakephpFind):
def run(self, edit):
if not self.set_app_path(): return
self.path.show_dir_list_by_folder("test", self.view)
class CakeShowFixtureListCommand(SublimeCakephpFind):
def run(self, edit):
if not self.set_app_path(): return
self.path.show_dir_list_by_folder("fixture", self.view)
class CakeOpenFolderCommand(SublimeCakephpFind):
def run(self, edit):
if not self.set_app_path(): return
self.path.execute(self.path.get_this_dir(self.view))