# Path: lib/utils/debug.py
# def Debug(classification, text):
#     if 'all' in print_classifications or classification in print_classifications:
#         print("ArcticTypescript: %s: %s" % (classification.ljust(8), text))
#     if classification not in possible_classifications:
#         print("ArcticTypescript: debug: got unknown debug message classification: %s. " \
#             "Consider adding this to possible_classifications" % classification)
#     sys.stdout.flush()
# 
# Path: lib/utils/uiutils.py
# def get_prefix(token):
#     if token in PREFIXES:
#         return PREFIXES[token]
#     else:
#         return ''
# 
# Path: lib/utils/viewutils.py
# def get_file_infos(view):
#     return (view.file_name(), get_lines(view), get_content(view))
# 
# def get_content_of_line_at(view, pos):
#     return view.substr(sublime.Region(view.line(pos-1).a, pos))


import re
import json
import sublime
from ..utils import Debug
from ..utils.uiutils import get_prefix
from ..utils.viewutils import get_file_infos, get_content_of_line_at
# coding=utf8




# IS AN OBJECT MEMBER
# TRUE: line=Instance. or line=Instance.fooba or line=Instance.foobar.alic
# FALSE: line=Inst
js_id_re = re.compile(u'^[_$a-zA-Z\u00FF-\uFFFF][_$a-zA-Z0-9\u00FF-\uFFFF]*')
def is_member_completion(line_text):
    def partial_completion():
        sp = line_text.split(".")
        if len(sp) > 1:
            return js_id_re.match(sp[-1]) is not None
        return False

# Path: lib/utils/debug.py
# def Debug(classification, text):
#     if 'all' in print_classifications or classification in print_classifications:
#         print("ArcticTypescript: %s: %s" % (classification.ljust(8), text))
#     if classification not in possible_classifications:
#         print("ArcticTypescript: debug: got unknown debug message classification: %s. " \
#             "Consider adding this to possible_classifications" % classification)
#     sys.stdout.flush()
# 
# Path: lib/utils/uiutils.py
# def get_prefix(token):
#     if token in PREFIXES:
#         return PREFIXES[token]
#     else:
#         return ''
# 
# Path: lib/utils/viewutils.py
# def get_file_infos(view):
#     return (view.file_name(), get_lines(view), get_content(view))
# 
# def get_content_of_line_at(view, pos):
#     return view.substr(sublime.Region(view.line(pos-1).a, pos))


# Path: lib/system/Completion.py
import re
import json
import sublime
from ..utils import Debug
from ..utils.uiutils import get_prefix
from ..utils.viewutils import get_file_infos, get_content_of_line_at

# coding=utf8




# IS AN OBJECT MEMBER
# TRUE: line=Instance. or line=Instance.fooba or line=Instance.foobar.alic
# FALSE: line=Inst
js_id_re = re.compile(u'^[_$a-zA-Z\u00FF-\uFFFF][_$a-zA-Z0-9\u00FF-\uFFFF]*')
def is_member_completion(line_text):
    def partial_completion():
        sp = line_text.split(".")
        if len(sp) > 1:
            return js_id_re.match(sp[-1]) is not None
        return False

    return line_text.endswith(".") or partial_completion()