Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenfin committed Mar 19, 2014
2 parents cbd7caf + 3cfd53b commit 5f5880b
Show file tree
Hide file tree
Showing 9 changed files with 324 additions and 24 deletions.
12 changes: 12 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# After changing this file, check it on:
# http://lint.travis-ci.org/
language: python
python:
- "2.6" # sublime text 2
- "3.3" # sublime text 3
before_install:
- sudo apt-get install exuberant-ctags
- if [[ $TRAVIS_PYTHON_VERSION == '2.6' ]]; then pip install unittest2; fi
script:
- if [[ $TRAVIS_PYTHON_VERSION == '2.6' ]]; then python -m unittest2.__main__ discover; fi
- if [[ $TRAVIS_PYTHON_VERSION == '3.3' ]]; then python -m unittest discover; fi
2 changes: 2 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
CTags
=====

.. image:: https://travis-ci.org/SublimeText/CTags.png?branch=development :target: https://travis-ci.org/SublimeText/CTags

About
=====

Expand Down
25 changes: 16 additions & 9 deletions ctags.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,24 @@
import codecs
import re
import os
import sys
import subprocess
import bisect
import mmap

if sys.version_info<(2,7,0):
from helpers.check_output import check_output
else:
from subprocess import check_output

"""
Contants
"""

TAGS_RE = re.compile(
r'(?P<symbol>[^\t]+)\t'
r'(?P<filename>[^\t]+)\t'
r'(?P<ex_command>.*?\$/);"\t'
r'(?P<ex_command>(/.+/|\?.+\?|\d+));"\t'
r'(?P<type>[^\t\r\n]+)'
r'(?:\t(?P<fields>.*))?'
)
Expand Down Expand Up @@ -89,6 +95,8 @@ def parse_tag_lines(lines, order_by='symbol', tag_class=None, filters=[]):
if isinstance(line, Tag): # handle both text and tag objects
line = line.line

line = line.rstrip('\r\n')

search_obj = TAGS_RE.search(line)

if not search_obj:
Expand Down Expand Up @@ -304,15 +312,14 @@ def build_ctags(path, tag_file=None, recursive=False, opts=None, cmd=None,
else: # search all files in current directory
cmd.append(os.path.join(path, '*'))

# execute the command
p = subprocess.Popen(cmd, cwd=cwd, shell=False, env=env,
stdin=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
# workaround for the issue described here:
# http://bugs.python.org/issue6689
if os.name == 'posix':
cmd = ' '.join(cmd)

ret = p.wait()

if ret:
raise EnvironmentError(ret, p.stdout.read())
# execute the command
check_output(cmd, cwd=cwd, shell=True, env=env, stdin=subprocess.PIPE,
stderr=subprocess.STDOUT)

if not tag_file: # Exuberant ctags defaults to ``tags`` filename.
tag_file = os.path.join(cwd, 'tags')
Expand Down
26 changes: 18 additions & 8 deletions ctagsplugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import re
import string
import threading
import subprocess

from itertools import chain
from operator import itemgetter as iget
Expand Down Expand Up @@ -51,7 +52,6 @@
ENTITY_SCOPE = 'entity.name.function, entity.name.type, meta.toc-list'

RUBY_SPECIAL_ENDINGS = '\?|!'
RUBY_SCOPES = '.*(ruby|rails).*'

ON_LOAD = sublime_plugin.all_callbacks['on_load']

Expand Down Expand Up @@ -676,7 +676,6 @@ class NavigateToDefinition(sublime_plugin.TextCommand):

def __init__(self, args):
sublime_plugin.TextCommand.__init__(self, args)
self.scopes = re.compile(RUBY_SCOPES)
self.endings = re.compile(RUBY_SPECIAL_ENDINGS)

def is_visible(self):
Expand All @@ -687,6 +686,13 @@ def run(self, view, args, tags_file):
region = view.sel()[0]
if region.begin() == region.end(): # point
region = view.word(region)

# handle special line endings for Ruby
language = view.settings().get('syntax')
endings = view.substr(sublime.Region(region.end(), region.end()+1))

if 'Ruby' in language and self.endings.match(endings):
region = sublime.Region(region.begin(), region.end()+1)
symbol = view.substr(region)

return JumpToDefinition.run(symbol, view, tags_file)
Expand Down Expand Up @@ -868,15 +874,19 @@ def tags_built(tag_file):
recursive=recursive, opts=opts,
cmd=command)
except IOError as e:
error_message(str(e).rstrip())
error_message(e.strerror)
return
except EnvironmentError as e:
if not isinstance(e.strerror, str):
str_err = ' '.join(e.strerror.decode('utf-8').splitlines())
except subprocess.CalledProcessError as e:
if sublime.platform() == 'windows':
str_err = ' '.join(
e.output.decode('windows-1252').splitlines())
else:
str_err = str(e).rstrip()
error_message(str_err) # show error_message
str_err = e.output.rstrip()
error_message(str_err)
return
except Exception as e:
error_message("An unknown error occured.\nCheck the console for info.")
raise e

tags_built(result)

Expand Down
27 changes: 27 additions & 0 deletions helpers/check_output.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env python

# Based on source from here: https://gist.github.com/edufelipe/1027906

"""Backport version of 'subprocess.check_output' for Python 2.6.x"""

import subprocess

def check_output(*popenargs, **kwargs):
r"""Run command with arguments and return its output as a byte string.
Backported from Python 2.7 as it's implemented as pure python on stdlib.
>>> check_output(['/usr/bin/python', '--version'])
Python 2.6.2
"""
process = subprocess.Popen(stdout=subprocess.PIPE, *popenargs, **kwargs)
output, unused_err = process.communicate()
retcode = process.poll()
if retcode:
cmd = kwargs.get("args")
if cmd is None:
cmd = popenargs[0]
error = subprocess.CalledProcessError(retcode, cmd)
error.output = output
raise error
return output
3 changes: 2 additions & 1 deletion messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
"0.3.3": "messages/0.3.3.md",
"0.3.4": "messages/0.3.4.md",
"0.3.5": "messages/0.3.5.md",
"0.3.6": "messages/0.3.6.md"
"0.3.6": "messages/0.3.6.md",
"0.3.7": "messages/0.3.7.md"
}
24 changes: 24 additions & 0 deletions messages/0.3.7.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Changes in 0.3.7
================

- Resolve regressions caused by multiple previous releases
- General improvements in error handling and other corner cases
- Bug Fixes

Fixes
=====

* Ruby: Exception and ? ignored., #177
* Can't Jump to the definition which defined by #define, #213

Resolves
========

* Travis-ci Integration, #218
* Tests aren't cross platform, #219
* Better formatted build warnings #220

*******************************************************************************

For more detailed information about these changes, run ``git v0.3.6..v0.3.7``
on the Git repository found [here](https://github.com/SublimeText/CTags).
Loading

0 comments on commit 5f5880b

Please sign in to comment.