def on_idle(self, view):
"""
"""
structure_info = self._get_structure_info(view)
linting = self.get_settings(view, "linting", True)
# linting
if linting and "key.diagnostics" in structure_info:
diagnostics = structure_info["key.diagnostics"]
self.errors = {}
for entry in diagnostics:
description = entry["key.description"]
#level = entry['key.severity']
row, col = entry["key.line"], entry["key.column"]
pos = view.text_point(row-1,col-1)
self.errors[pos] = description
view.add_regions(
"swiftkitten.diagnostics",
[Region(pos,pos+1) for pos in self.errors.keys()],
"constant",
"",
sublime.DRAW_STIPPLED_UNDERLINE | sublime.DRAW_NO_OUTLINE | sublime.DRAW_NO_FILL
)
self._update_linting_status(view)
python类DRAW_STIPPLED_UNDERLINE的实例源码
def get_draw_style(self):
"""Get the region styling.
"""
underlined = sublime.DRAW_NO_FILL | sublime.DRAW_NO_OUTLINE
style = self.get('vale_alert_style')
if style == 'solid_underline':
return sublime.DRAW_SOLID_UNDERLINE | underlined
elif style == 'stippled_underline':
return sublime.DRAW_STIPPLED_UNDERLINE | underlined
elif style == 'squiggly_underline':
return sublime.DRAW_SQUIGGLY_UNDERLINE | underlined
return sublime.DRAW_OUTLINED
def run_coverage(self, view):
settings = find_flow_settings(view.window().project_data())
if not settings.get('show_coverage'):
return
result = None
try:
result = CLI(view).coverage()
except InvalidContext:
view.erase_regions('flow_error')
view.erase_regions('flow_uncovered')
except Exception as e:
display_unknown_error(self.view, e)
if not result:
return
regions = []
for line in result['expressions']['uncovered_locs']:
start = line['start']
end = line['end']
row = int(start['line']) - 1
col = int(start['column']) - 1
endrow = int(end['line']) - 1
endcol = int(end['column'])
regions.append(
rowcol_to_region(view, row, col, endcol, endrow)
)
view.add_regions(
'flow_uncovered', regions, 'comment', '',
sublime.DRAW_STIPPLED_UNDERLINE +
sublime.DRAW_NO_FILL +
sublime.DRAW_NO_OUTLINE
)
uncovered_count = result['expressions']['uncovered_count']
covered_count_text = 'Flow coverage: {} line{} uncovered'.format(
uncovered_count, '' if uncovered_count is 1 else 's'
)
view.set_status('flow_coverage', covered_count_text)
def add_lint_marks(view, lines, **errors):
"""Adds lint marks to view on the given lines.
"""
erase_lint_marks(view)
types = {
'warning': errors['warning_underlines'],
'illegal': errors['error_underlines'],
'violation': errors['violation_underlines'],
}
style = get_settings(view, 'anaconda_linter_mark_style', 'outline')
show_underlines = get_settings(view, 'anaconda_linter_underlines', True)
if show_underlines:
for type_name, underlines in types.items():
if len(underlines) > 0:
view.add_regions(
'anaconda-lint-underline-{}'.format(type_name), underlines,
'anaconda.underline.{}'.format(type_name),
flags=sublime.DRAW_EMPTY_AS_OVERWRITE
)
if len(lines) > 0:
outline_style = {
'solid_underline': sublime.DRAW_NO_FILL | sublime.DRAW_NO_OUTLINE | sublime.DRAW_SOLID_UNDERLINE,
'stippled_underline': sublime.DRAW_NO_FILL | sublime.DRAW_NO_OUTLINE | sublime.DRAW_STIPPLED_UNDERLINE,
'squiggly_underline': sublime.DRAW_NO_FILL | sublime.DRAW_NO_OUTLINE | sublime.DRAW_SQUIGGLY_UNDERLINE,
'outline': sublime.DRAW_OUTLINED,
'none': sublime.HIDDEN,
'fill': None
}
gutter_theme = get_settings(
view, 'anaconda_gutter_theme', 'basic').lower()
package_name = os.path.dirname(__file__).rsplit(os.path.sep, 3)[1]
ico_path = (
'Packages/' + package_name + '/anaconda_lib/linting/'
'gutter_mark_themes/{theme}-{type}.png'
)
for lint_type, lints in get_outlines(view).items():
if len(lints) > 0:
if get_settings(view, 'anaconda_gutter_marks', False):
if gutter_theme == 'basic':
gutter_marks = marks[lint_type]
else:
gutter_marks = ico_path.format(theme=gutter_theme,
type=lint_type)
else:
gutter_marks = ''
args = [
'anaconda-lint-outlines-{}'.format(lint_type),
lints,
'anaconda.outline.{}'.format(lint_type),
gutter_marks
]
draw_style = outline_style.get(style, sublime.DRAW_OUTLINED)
if draw_style is not None:
args.append(draw_style)
view.add_regions(*args)