Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
SublimeCodeIntel/libs/codeintel2/oop/controller.py at development · SourceCode/SublimeCodeIntel · GitHub
Skip to content
Navigation Menu
Sign in
Appearance settings
Platform
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
Solutions
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
View all industries
View all solutions
Resources
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
Open Source
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
Enterprise
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
SourceCode
/
SublimeCodeIntel
Public
forked from
SublimeCodeIntel/SublimeCodeIntel
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Files
Expand file tree
development
Breadcrumbs
SublimeCodeIntel
/
libs
/
codeintel2
/
oop
/
controller.py
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
161 lines (139 loc) · 5.87 KB
development
Breadcrumbs
SublimeCodeIntel
/
libs
/
codeintel2
/
oop
/
controller.py
Copy path
Top
File metadata and controls
Code
Blame
161 lines (139 loc) · 5.87 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#!/usr/bin/env python2
import
codeintel2
.
common
from
codeintel2
.
common
import
EvalController
import
logging
import
io
import
pprint
log
=
logging
.
getLogger
(
"codeintel.oop.controller"
)
class
OOPEvalController
(
EvalController
):
"""Eval controller for out-of-process codeintel
"""
have_errors
=
have_warnings
=
False
silent
=
False
def
__init__
(
self
,
driver
=
None
,
request
=
None
,
trg
=
None
,
*
args
,
**
kwargs
):
"""Create an eval controller
@param driver {Driver} The OOP driver instance to communicate via
@param request {Request} The request causing the evaluation
"""
log
.
debug
(
"__init__"
)
EvalController
.
__init__
(
self
,
*
args
,
**
kwargs
)
self
.
driver
=
driver
self
.
request
=
request
self
.
trg
=
trg
self
.
silent
=
request
.
get
(
"silent"
,
False
)
self
.
keep_existing
=
request
.
get
(
"keep_existing"
,
self
.
keep_existing
)
# Set up a *new* logger to record any errors
# Note that the output will be discarded if there is no error
self
.
log_stream
=
io
.
StringIO
()
self
.
log_hndlr
=
logging
.
StreamHandler
(
self
.
log_stream
)
loggerClass
=
logging
.
Logger
.
manager
.
loggerClass
if
not
loggerClass
:
loggerClass
=
logging
.
getLoggerClass
()
self
.
log
=
loggerClass
(
"codeintel.evaluator"
)
self
.
log
.
manager
=
logging
.
Logger
.
manager
self
.
log
.
propagate
=
False
self
.
log
.
addHandler
(
self
.
log_hndlr
)
self
.
best_msg
=
(
0
,
""
)
def
close
(
self
):
log
.
debug
(
"close"
)
EvalController
.
close
(
self
)
def
set_desc
(
self
,
desc
):
log
.
debug
(
"set_desc: %s"
,
desc
)
EvalController
.
set_desc
(
self
,
desc
)
if
not
self
.
silent
:
self
.
log
.
error
(
"error evaluating %s:
\n
trigger: %s
\n
log:"
,
desc
,
self
.
trg
)
# Reset the formatter to be minimal
fmt
=
logging
.
Formatter
(
fmt
=
" %(levelname)s: %(message)s"
)
self
.
log_hndlr
.
setFormatter
(
fmt
)
def
setStatusMessage
(
self
,
msg
,
highlight
):
log
.
debug
(
"setStatusMessage: %s, %s"
,
msg
,
highlight
)
self
.
driver
.
send
(
request
=
self
.
request
,
success
=
None
,
message
=
msg
,
highlight
=
highlight
)
def
abort
(
self
):
log
.
debug
(
"abort: %r"
,
self
.
request
)
if
self
.
is_aborted
:
# Controllers don't abort immediately; this is in the process of
# aborting but hasn't finished yet
log
.
debug
(
"Suppressing repeat abort message: %r"
,
self
.
request
)
return
EvalController
.
abort
(
self
)
self
.
driver
.
fail
(
request
=
self
.
request
,
msg
=
"aborted"
)
def
done
(
self
,
reason
):
log
.
debug
(
"done: %s %s"
,
reason
,
"(aborted)"
if
self
.
is_aborted
()
else
""
)
retrigger
=
self
.
trg
.
retriggerOnCompletion
if
self
.
trg
else
False
if
self
.
cplns
:
# Report completions
self
.
driver
.
send
(
cplns
=
self
.
cplns
,
request
=
self
.
request
,
retrigger
=
retrigger
)
elif
self
.
calltips
:
self
.
driver
.
send
(
calltip
=
self
.
calltips
[
0
],
request
=
self
.
request
,
retrigger
=
retrigger
)
elif
self
.
defns
:
# We can't exactly serialize blobs directly...
def
defn_serializer
(
defn
):
return
defn
.
__dict__
self
.
driver
.
send
(
defns
=
list
(
map
(
defn_serializer
,
self
.
defns
or
[])),
request
=
self
.
request
,
retrigger
=
retrigger
)
elif
self
.
is_aborted
():
pass
# already reported the abort
elif
self
.
best_msg
[
0
]:
try
:
msg
=
"No %s found"
%
(
self
.
desc
,)
if
self
.
have_errors
:
msg
=
self
.
best_msg
[
1
]
+
" (error determining %s)"
%
(
self
.
desc
,)
self
.
driver
.
report_error
(
self
.
log_stream
.
getvalue
())
elif
self
.
have_warnings
:
msg
+=
"(warning: %s)"
%
(
self
.
best_msg
[
1
],)
except
TypeError
as
ex
:
# Guard against this common problem in log formatting above:
# TypeError: not enough arguments for format string
log
.
exception
(
"problem logging eval failure: self.log=%r"
,
self
.
log_entries
)
msg
=
"error evaluating '%s'"
%
desc
self
.
driver
.
fail
(
request
=
self
.
request
,
message
=
msg
)
else
:
# ERROR
self
.
driver
.
fail
(
request
=
self
.
request
,
msg
=
reason
)
self
.
log
=
log
# If we have any more problems, put it in the main log
self
.
log_stream
.
close
()
EvalController
.
done
(
self
,
reason
)
def
setup_log
(
self
):
if
not
self
.
desc
:
desc
=
{
codeintel2
.
common
.
TRG_FORM_CPLN
:
"completions"
,
codeintel2
.
common
.
TRG_FORM_CALLTIP
:
"calltip"
,
codeintel2
.
common
.
TRG_FORM_DEFN
:
"definition"
,
}.
get
(
self
.
trg
.
form
,
"???"
)
self
.
set_desc
(
desc
)
def
debug
(
self
,
msg
,
*
args
):
if
self
.
silent
:
return
self
.
setup_log
()
self
.
log
.
debug
(
msg
,
*
args
)
if
self
.
best_msg
[
0
]
<
logging
.
DEBUG
:
self
.
best_msg
=
(
logging
.
DEBUG
,
msg
%
args
)
def
info
(
self
,
msg
,
*
args
):
if
self
.
silent
:
return
self
.
setup_log
()
self
.
log
.
info
(
msg
,
*
args
)
if
self
.
best_msg
[
0
]
<
logging
.
INFO
:
self
.
best_msg
=
(
logging
.
INFO
,
msg
%
args
)
def
warn
(
self
,
msg
,
*
args
):
if
self
.
silent
:
return
self
.
setup_log
()
self
.
log
.
warn
(
msg
,
*
args
)
if
self
.
best_msg
[
0
]
<
logging
.
WARN
:
self
.
best_msg
=
(
logging
.
WARN
,
msg
%
args
)
self
.
have_warnings
=
True
def
error
(
self
,
msg
,
*
args
):
if
self
.
silent
:
return
self
.
setup_log
()
self
.
log
.
error
(
msg
,
*
args
)
if
self
.
best_msg
[
0
]
<
logging
.
ERROR
:
self
.
best_msg
=
(
logging
.
ERROR
,
msg
%
args
)
self
.
have_errors
=
True
You can’t perform that action at this time.