Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ Example settings for Windows:
if `"cc_include_options"` exists in your project settings, it will merge to
the `"include_options"` defined in `cc.sublime-settings`.

if `"cc_additional_language_options"` exists in your project settings, it will merge to
the `"additional_language_options"` defined in `cc.sublime-settings`.

if `"cc_display_filters"` exists in exists in your project settings, it will merge to
the `"display_filters"` defined in `cc.sublime-settings`.

## Preview
<img src="http://ww4.sinaimg.cn/large/7608d17fgw1eo4dgrggc0g20da0bi44p.gif" width="50%" />
Expand Down
5 changes: 4 additions & 1 deletion cc.sublime-settings
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"include_options":
[
"-isystem", "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/6.0/include",
"-isystem", "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/",
"-isystem", "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/",
"-isystem", "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/c++/4.2.1",
"-F/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/",
"-isystem", "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1",
Expand All @@ -49,4 +49,7 @@

// do not show the panel for warnings and errors on save.
"hide_error_panel": false,

// automatically hide the panel when the panel is empty
"hide_error_panel_when_empty": true,
}
4 changes: 3 additions & 1 deletion clang_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,14 @@ def close(self):
sublime.active_window().run_command("hide_panel", {"panel": "output.cc"})


def error_marks(self, view, digst, display):
def error_marks(self, view, digst, display, filterfn, filters):
self.erase_error_marks(view)

cur_filename = view.file_name()
outlines = {'warning': [], 'error': [], 'fatal error': []}
for i, (filename, line, col, error_type, info) in digst:
if filterfn(info, filters):
continue
print(error_type, line)
if error_type in outlines and cur_filename == filename:
outlines[error_type].append(view.full_line(view.text_point(line-1, 0)))
Expand Down
24 changes: 18 additions & 6 deletions st_cc.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ def can_complete(view):
return language in drivers


def should_be_filtered(err, filters):
for filter in filters:
if re.search(filter, err) is not None:
return True
return False

class WraperComplete(object):

def __init__(self):
Expand Down Expand Up @@ -159,9 +165,10 @@ def get_settings():
@staticmethod
def get_opt(view):
settings = Complete.get_settings()
project_settings = view.settings()
additional_lang_opts = settings.get("additional_language_options", {})
additional_lang_opts.update(project_settings.get("cc_additional_language_options", {}))
language = get_language(view)
project_settings = view.settings()
include_opts = settings.get("include_options", []) + project_settings.get("cc_include_options", [])

window = sublime.active_window()
Expand Down Expand Up @@ -265,30 +272,35 @@ def hack2():
})
sublime.set_timeout(hack2, 1)


def on_post_save_async(self, view):
if not can_complete(view):
return

settings = Complete.get_settings()
project_settings = view.settings()
hide_error_panel = settings.get('hide_error_panel') or False
hide_error_panel_when_empty = settings.get('hide_error_panel_when_empty') or False
hide_error_mark = settings.get('hide_error_mark') or False
filters = settings.get('display_filters', []) + project_settings.get('cc_display_filters', [])
file_name = view.file_name()
sym = Complete.get_symbol(file_name, view)
if self.dirty:
sym.reparse()
self.dirty = False
digst = sym.diagnostic()

output = "\n".join([err for _, (_, _, _, _, err) in digst])
output = "\n".join([err for _, (_, _, _, _, err) in digst if not should_be_filtered(err, filters)])
clang_error_panel.set_data(output)
clang_error_panel.error_marks(view, digst, not hide_error_mark)
clang_error_panel.error_marks(view, digst, not hide_error_mark, should_be_filtered, filters)

if output:
print(output)
window = view.window()
if not window is None and len(digst) >= 1:
window.run_command("clang_toggle_panel", {"show": not hide_error_panel})
if not window is None:
if output:
window.run_command("clang_toggle_panel", {"show": not hide_error_panel})
elif hide_error_panel_when_empty:
window.run_command("clang_toggle_panel", {"show": False})


def on_query_completions(self, view, prefix, locations):
Expand Down