Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
7
Merge Requests
7
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Jérome Perrin
erp5
Commits
37b06519
Commit
37b06519
authored
Jun 17, 2015
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
codemirror: integrate jedi to autocomplete python code
parent
9d08cb2c
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
203 additions
and
1 deletion
+203
-1
bt5/erp5_code_mirror/ExtensionTemplateItem/portal_components/extension.erp5.JediUtils.py
...emplateItem/portal_components/extension.erp5.JediUtils.py
+14
-0
bt5/erp5_code_mirror/ExtensionTemplateItem/portal_components/extension.erp5.JediUtils.xml
...mplateItem/portal_components/extension.erp5.JediUtils.xml
+123
-0
bt5/erp5_code_mirror/SkinTemplateItem/portal_skins/erp5_code_mirror/ERP5Site_getPythonSourceCodeCompletionList.xml
...ode_mirror/ERP5Site_getPythonSourceCodeCompletionList.xml
+28
-0
bt5/erp5_code_mirror/SkinTemplateItem/portal_skins/erp5_code_mirror/code_mirror_support.xml
...tem/portal_skins/erp5_code_mirror/code_mirror_support.xml
+36
-0
bt5/erp5_code_mirror/bt/copyright_list
bt5/erp5_code_mirror/bt/copyright_list
+1
-1
bt5/erp5_code_mirror/bt/template_extension_id_list
bt5/erp5_code_mirror/bt/template_extension_id_list
+1
-0
No files found.
bt5/erp5_code_mirror/ExtensionTemplateItem/portal_components/extension.erp5.JediUtils.py
0 → 100644
View file @
37b06519
import
jedi
import
json
# XXX this page is not up to date
# https://jedi.readthedocs.org/en/latest/docs/plugin-api.html
def
getCompletionList
(
self
,
source
,
line
,
column
,
bound_names
=
None
,
params
=
None
,
REQUEST
=
None
):
line
=
int
(
line
)
column
=
int
(
column
)
script
=
jedi
.
Script
(
source
,
line
,
column
,
''
)
if
REQUEST
:
REQUEST
.
RESPONSE
.
setHeader
(
'content-type'
,
'application/json'
)
return
json
.
dumps
([
completion
.
name
for
completion
in
script
.
completions
()])
bt5/erp5_code_mirror/ExtensionTemplateItem/portal_components/extension.erp5.JediUtils.xml
0 → 100644
View file @
37b06519
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"Extension Component"
module=
"erp5.portal_type"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_recorded_property_dict
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAI=
</string>
</persistent>
</value>
</item>
<item>
<key>
<string>
default_reference
</string>
</key>
<value>
<string>
JediUtils
</string>
</value>
</item>
<item>
<key>
<string>
description
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
extension.erp5.JediUtils
</string>
</value>
</item>
<item>
<key>
<string>
portal_type
</string>
</key>
<value>
<string>
Extension Component
</string>
</value>
</item>
<item>
<key>
<string>
sid
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
text_content_error_message
</string>
</key>
<value>
<tuple/>
</value>
</item>
<item>
<key>
<string>
text_content_warning_message
</string>
</key>
<value>
<tuple/>
</value>
</item>
<item>
<key>
<string>
version
</string>
</key>
<value>
<string>
erp5
</string>
</value>
</item>
<item>
<key>
<string>
workflow_history
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAM=
</string>
</persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record
id=
"2"
aka=
"AAAAAAAAAAI="
>
<pickle>
<global
name=
"PersistentMapping"
module=
"Persistence.mapping"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
data
</string>
</key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record
id=
"3"
aka=
"AAAAAAAAAAM="
>
<pickle>
<global
name=
"PersistentMapping"
module=
"Persistence.mapping"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
data
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
component_validation_workflow
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAQ=
</string>
</persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record
id=
"4"
aka=
"AAAAAAAAAAQ="
>
<pickle>
<global
name=
"WorkflowHistoryList"
module=
"Products.ERP5Type.patches.WorkflowTool"
/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key>
<string>
action
</string>
</key>
<value>
<string>
validate
</string>
</value>
</item>
<item>
<key>
<string>
validation_state
</string>
</key>
<value>
<string>
validated
</string>
</value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
</ZopeData>
bt5/erp5_code_mirror/SkinTemplateItem/portal_skins/erp5_code_mirror/ERP5Site_getPythonSourceCodeCompletionList.xml
0 → 100644
View file @
37b06519
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"ExternalMethod"
module=
"Products.ExternalMethod.ExternalMethod"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_function
</string>
</key>
<value>
<string>
getCompletionList
</string>
</value>
</item>
<item>
<key>
<string>
_module
</string>
</key>
<value>
<string>
JediUtils
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
ERP5Site_getPythonSourceCodeCompletionList
</string>
</value>
</item>
<item>
<key>
<string>
title
</string>
</key>
<value>
<string></string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
bt5/erp5_code_mirror/SkinTemplateItem/portal_skins/erp5_code_mirror/code_mirror_support.xml
View file @
37b06519
...
...
@@ -513,6 +513,42 @@
if(parent_height !== undefined
&&
parent_height > (300 * 0.8)) {\n
cm.setSize(undefined, parent_height);\n
}\n
\n
\n
CodeMirror.registerHelper(\n
"hint", "ajax",\n
function (mirror, callback, options) {\n
var cur = mirror.getCursor();\n
var tok = mirror.getTokenAt(cur);\n
\n
var completion_parameters = {source: cm.getValue(), column: cur.ch, line: cur.line+1};\n
<dtml-if
bound_names
>
\n
completion_parameters[\'bound_names\'] =
<dtml-var
name=
"bound_names"
>
;\n
completion_parameters[\'params\'] = $(\'input[name="params"]\').val();\n
</dtml-if>
\n
console.log("Checking at", cur.ch, " ", cur.line);\n
$.getJSON(\n
"
&dtml-portal_url;
/ERP5Site_getPythonSourceCodeCompletionList",\n
completion_parameters,\n
function (res) {\n
console.log("Got response ", res);\n
console.log("Returing", { list: res,\n
from: CodeMirror.Pos(cur.line, tok.start),\n
to: CodeMirror.Pos(cur.line, tok.end)\n
});\n
callback({ list: res,\n
from: CodeMirror.Pos(cur.line, tok.start),\n
to: CodeMirror.Pos(cur.line, tok.end)\n
})\n
})\n
})\n
\n
CodeMirror.registerHelper(\n
"hint", "python",\n
function (mirror, options) {\n
CodeMirror.commands.autocomplete(mirror, CodeMirror.hint.ajax, { async: true })\n
})\n
\n
\n
updateErrorWarningMessageDivWithJump();\n
\n
...
...
bt5/erp5_code_mirror/bt/copyright_list
View file @
37b06519
...
...
@@ -11,4 +11,4 @@ jshint.js (under modified MIT license):
Copyright (c) 2002 Douglas Crockford (www.JSLint.com)
csslint.js (under MIT license):
Copyright (c) 2009-2011 Nicholas C. Zakas. All rights reserved.
Copyright (c) 2009-2011 Nicholas C. Zakas. All rights reserved.
\ No newline at end of file
bt5/erp5_code_mirror/bt/template_extension_id_list
0 → 100644
View file @
37b06519
extension.erp5.JediUtils
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment