<commit_before>import sys
import subprocess
import json
import os
import threading
import copy

import sublime
import sublime_plugin

st2 = (sys.version_info[0] == 2)
dist_dir = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, dist_dir)

import gs
import gsq

DOMAIN = 'BaiduFECodeStyleLint'
CL_DOMAIN = 'BaiduFECodeStyleCompLint'
CL_DOMAIN_FORMAT = 'BaiduFECodeStyleCompFormat'


settings = None

def plugin_loaded():
  global settings
  settings = sublime.load_settings("Baidu FE Code Style.sublime-settings")

if st2:
  plugin_loaded()

class FileRef(object):
  def __init__(self, view, file):
    self.view = view
    self.state = 0
    self.file = file
    self.errors = []

def highlight_regions(fr):
  regions = []
  regions0 = []
  domain0 = DOMAIN+'-zero'
  if len(fr.errors) > 0:
    print '\n%s' % fr.file
  for r in fr.errors:
    row = r.get('line') or 0
    col = r.get('column') or 0
    print '%s:%s %s' % (row, col, r.get('message').encode('utf-8'))
    line = fr.view.line(fr.view.text_point(row-1, 0))
    pos = line.begin() + col
    if pos >= line.end():
      pos = line.end()
    if pos == line.begin():
      regions0.append(sublime.Region(pos, pos))
    else:
      regions.append(sublime.Region(pos, pos))

  if regions:
    fr.view.add_regions(DOMAIN, regions, 'comment', 'dot', sublime.DRAW_EMPTY_AS_OVERWRITE)<commit_msg>错误信息放到 sublime 的 console 里面去显示<commit_after>import sys
import subprocess
import json
import os
import threading
import copy

import sublime
import sublime_plugin

st2 = (sys.version_info[0] == 2)
dist_dir = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, dist_dir)

import gs
import gsq

DOMAIN = 'BaiduFECodeStyleLint'
CL_DOMAIN = 'BaiduFECodeStyleCompLint'
CL_DOMAIN_FORMAT = 'BaiduFECodeStyleCompFormat'


settings = None

def plugin_loaded():
  global settings
  settings = sublime.load_settings("Baidu FE Code Style.sublime-settings")

if st2:
  plugin_loaded()

class FileRef(object):
  def __init__(self, view, file):
    self.view = view
    self.state = 0
    self.file = file
    self.errors = []

def highlight_regions(fr):
  regions = []
  regions0 = []
  domain0 = DOMAIN+'-zero'

  if len(fr.errors) > 0:
    print '\n%s' % fr.file
  else:
    print '\n%s\nCongratulations! Everything is OK!' % fr.file

  for r in fr.errors:
    row = r.get('line') or 0
    col = r.get('column') or 0
    print '%s:%s %s' % (row, col, r.get('message').encode('utf-8'))
    line = fr.view.line(fr.view.text_point(row-1, 0))
    pos = line.begin() + col
    if pos >= line.end():
      pos = line.end()
    if pos == line.begin():
      regions0.append(sublime.Region(pos, pos))
    else:
      regions.append(sublime.Region(pos, pos))

  if regions:
    fr.view.add_regions(DOMAIN, regions, 'comment', 'dot', sublime.DRAW_EMPTY_AS_OVERWRITE)
{'fraction_non_alphanumeric': 0.1377840909090909, 'fraction_numerical': 0.01065340909090909, 'mean_word_length': 3.679401993355482, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7328300', 'n_tokens_mistral': 1078, 'n_tokens_neox': 1052, 'n_words': 242}