Permalink
Browse files

Added coverage files to .gitignore.

Cleaned up what I think is dead code (not covered by coverage at
the very least). Some minor tests added to the unittests to cover
more code.
  • Loading branch information...
1 parent 043b5a1 commit e24efed22ff3ac2bcf280a676fd3e37c2a343a27 @quarnster committed Nov 11, 2012
Showing with 14 additions and 92 deletions.
  1. +2 −0 .gitignore
  2. +1 −1 parsehelp
  3. +2 −0 src/CMakeLists.txt
  4. +3 −88 translationunitcache.py
  5. BIN unittests/gold.txt.gz
  6. +6 −3 unittests/unittest.py
View
@@ -5,3 +5,5 @@ sublimeclang.sublime-workspace
*.dll
*.so
*.cache
+.coverage
+*,cover
Submodule parsehelp updated 1 files
+2 −0 .gitignore
View
@@ -183,6 +183,8 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
COMMAND find . -name \"*.cache\" -exec rm -rf {} +
COMMAND find . -name \"*.sublime-workspace\" -exec rm -rf {} +
COMMAND find . -name \"lib*.so\" -exec rm -rf {} +
+ COMMAND find . -name \"*,cover\" -exec rm -rf {} +
+ COMMAND find . -name \".coverage\" -exec rm -rf {} +
DEPENDS ${TARGETLIB} ${PROJECT_BINARY_DIR}/release clean_release
DEPENDS ${PROJECT_SOURCE_DIR}/../libclang.dll ${PROJECT_SOURCE_DIR}/../libcache.dll
DEPENDS ${PROJECT_SOURCE_DIR}/../libclang_x64.dll ${PROJECT_SOURCE_DIR}/../libcache_x64.dll
View
@@ -140,8 +140,7 @@ def remove_duplicates(data):
class Cache:
def __init__(self, tu, filename):
self.cache = _createCache(tu.cursor)
- if self.cache == None:
- raise Exception("cache is None")
+ assert self.cache != None
self.tu = tu
self.filename = filename
@@ -212,13 +211,6 @@ def find_type(self, data, typename):
return child
return None
- def get_template_type_count(self, temp):
- ret = []
- for child in temp.get_children():
- if child.kind == cindex.CursorKind.TEMPLATE_TYPE_PARAMETER:
- ret.append(child)
- return len(ret)
-
def solve_template_from_cursor(self, temp, member, template):
found = False
children = []
@@ -314,6 +306,7 @@ def complete(self, data, prefix):
ret = None
cached_results = cache_complete_startswith(self.cache, prefix)
if cached_results:
+ ret = []
for x in cached_results[0]:
if x.cursor.kind != cindex.CursorKind.MACRO_DEFINITION and \
x.cursor.kind != cindex.CursorKind.CXX_METHOD:
@@ -849,20 +842,6 @@ def worker(self):
import traceback
traceback.print_exc()
- def get_possible_targets():
- if len(es.target) > 0:
- return self.target
- elif not self.candidates.empty():
- display = []
- while not self.candidates.empty():
- name, function, line, column = self.candidates.get()
- pos = "%s:%d:%d" % (name, line, column)
- display.append([function, pos])
- self.candidates.task_done()
- return display
- else:
- return None
-
class LockedTranslationUnit(LockedVariable):
def __init__(self, var, fn):
@@ -965,74 +944,10 @@ def get_definition(self, data, offset, found_callback, folders):
if len(word_under_cursor) == 0:
found_callback(None)
return
- if cursor == None or cursor.kind.is_invalid() or (cursor_spelling != word_under_cursor and cursor.kind != cindex.CursorKind.INCLUSION_DIRECTIVE):
- # Try to determine what we're supposed to be looking for
- line, col = get_line_and_column_from_offset(data, offset)
-
- data = data[:get_offset_from_line_and_column(data, line+1, 0)]
- chars = r"[\[\]\(\)&|.+-/*,<>;]"
-
- word = [0,0]
- off = len(data)
- while True:
- off = data[:off].rfind(word_under_cursor)
- word = [off, off+len(word_under_cursor)]
- if offset >= off and offset <= off+len(word_under_cursor):
- break
- for match in re.finditer(r"(^|\w+|=|%s|\s)\s*(%s)\s*($|==|%s)" % (chars, word_under_cursor, chars), data):
- if (match.start(2), match.end(2)) == (word[0], word[1]):
- if match.group(3) == "(":
- # Probably a function
- ExtensiveSearch(None, word_under_cursor, found_callback, folders, self.opts, self.opts_script, impl=False)
- return
- else:
- # A variable perhaps?
- data = data[:match.end(2)] + "."
- typedef = get_type_definition(data)
- if typedef:
- line, column, name, var, extra = typedef
- if line > 0 and column > 0:
- found_callback("%s:%d:%d" % (self.fn, line, column))
- return
- elif name != None and name == get_base_type(name):
- search_re = re.compile(r"(^|\s|\})\s*(class|struct)(\s+%s\s*)(;|\{)" % name)
- ExtensiveSearch(None, name, found_callback, folders, self.opts, self.opts_script, impl=False, search_re=search_re)
- return
- break
- found_callback(None)
- return
ref = cursor.get_reference()
target = None
- if ref != None and cursor == ref:
- can = cursor.get_canonical_cursor()
- if can != None and can != cursor:
- target = format_cursor(can)
- else:
- o = cursor.get_overridden()
- if len(o) == 1:
- target = format_cursor(o[0])
- elif len(o) > 1:
- opts = []
- for i in range(len(o)):
- opts.append(self.quickpanel_format(o[i]))
- target = opts
- elif (cursor.kind == cindex.CursorKind.VAR_DECL or \
- cursor.kind == cindex.CursorKind.PARM_DECL or \
- cursor.kind == cindex.CursorKind.FIELD_DECL):
- for child in cursor.get_children():
- if child.kind == cindex.CursorKind.TYPE_REF:
- d = child.get_definition()
- if d != None:
- target = format_cursor(d)
- break
- elif cursor.kind == cindex.CursorKind.CLASS_DECL:
- for child in cursor.get_children():
- if child.kind == cindex.CursorKind.CXX_BASE_SPECIFIER:
- d = child.get_definition()
- if d != None:
- target = format_cursor(d)
- elif ref != None:
+ if ref != None:
target = format_cursor(ref)
elif cursor.kind == cindex.CursorKind.INCLUSION_DIRECTIVE:
f = cursor.get_included_file()
View
Binary file not shown.
View
@@ -154,7 +154,10 @@ def defimp_base(data, offset, queue):
word = parsehelp.extract_word_at_offset(data, offset)
res = queue.get()
def fixup(res):
- name, line, col = res.split(":")
+ if res.count(":") == 2:
+ name, line, col = res.split(":")
+ else:
+ name, line, col = res, 1, 1
line, col = int(line), int(col)
name = os.path.relpath(name)
# Just to ensure uniform results on all platforms
@@ -258,8 +261,7 @@ def read_file(filename):
add_goto_def_test(data2, data2.rfind("CXCursor_FunctionTemplate")+2)
add_goto_def_test(data2, data2.find("mNamespaces")+2)
add_goto_def_test(data2, data2.find("mFound")+2)
-
-
+ add_goto_def_test(data, data.find("\"")+3)
if goto_imp:
@@ -362,6 +364,7 @@ def check_correct(a, b):
# ---------------------------------------------------------
tu = get_tu("unittests/3.cpp")
+ add_completion_test("::", True)
add_completion_test("new ", True)
add_completion_test("new std::", True)
add_completion_test("new std::rel_ops::", True)

0 comments on commit e24efed

Please sign in to comment.