Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
baas-ide
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guxukai
baas-ide
Commits
1ea31f8b
Commit
1ea31f8b
authored
Sep 28, 2017
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move Compiler & ContextualListener & ContextViewer up
parent
4559f4f8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
71 additions
and
68 deletions
+71
-68
app.js
src/app.js
+71
-68
No files found.
src/app.js
View file @
1ea31f8b
...
...
@@ -35,7 +35,7 @@ var EventsDecoder = require('./app/execution/eventsDecoder')
var
handleImports
=
require
(
'./app/compiler/compiler-imports'
)
var
FileManager
=
require
(
'./app/files/fileManager'
)
var
ContextualListener
=
require
(
'./app/editor/contextualListener'
)
var
ContextView
=
require
(
'./app/editor/
C
ontextView'
)
var
ContextView
=
require
(
'./app/editor/
c
ontextView'
)
var
styleGuide
=
remix
.
ui
.
styleGuide
var
styles
=
styleGuide
()
...
...
@@ -171,6 +171,24 @@ module.exports = App
function
run
()
{
var
self
=
this
// ----------------- Compiler -----------------
var
compiler
=
new
Compiler
((
url
,
cb
)
=>
{
var
provider
=
fileManager
.
fileProviderOf
(
url
)
if
(
provider
&&
provider
.
exists
(
url
))
{
return
provider
.
get
(
url
,
cb
)
}
handleImports
.
import
(
url
,
(
error
,
content
)
=>
{
if
(
!
error
)
{
// FIXME: at some point we should invalidate the browser cache
filesProviders
[
'browser'
].
addReadOnly
(
url
,
content
)
cb
(
null
,
content
)
}
else
{
cb
(
error
)
}
})
})
var
offsetToLineColumnConverter
=
new
OffsetToLineColumnConverter
(
compiler
.
event
)
// ----------------- UniversalDApp -----------------
var
transactionContextAPI
=
{
getAddress
:
(
cb
)
=>
{
...
...
@@ -248,12 +266,63 @@ function run () {
txlistener
.
startListening
()
// ----------------- editor ----------------------------
this
.
_components
.
editor
=
new
Editor
({})
// @TODO: put into editorpanel
var
editor
=
self
.
_components
.
editor
// shortcut for the editor
// ---------------- ContextualListener -----------------------
this
.
_components
.
contextualListener
=
new
ContextualListener
({
getCursorPosition
:
()
=>
{
return
this
.
_components
.
editor
.
getCursorPosition
()
},
getCompilationResult
:
()
=>
{
return
compiler
.
lastCompilationResult
},
getCurrentFile
:
()
=>
{
return
config
.
get
(
'currentFile'
)
},
highlight
:
(
position
,
node
)
=>
{
if
(
compiler
.
lastCompilationResult
&&
compiler
.
lastCompilationResult
.
data
)
{
var
lineColumn
=
offsetToLineColumnConverter
.
offsetToLineColumn
(
position
,
position
.
file
,
compiler
.
lastCompilationResult
)
var
css
=
'highlightreference'
if
(
node
.
children
&&
node
.
children
.
length
)
{
// If node has children, highlight the entire line. if not, just highlight the current source position of the node.
css
=
'highlightreferenceline'
lineColumn
=
{
start
:
{
line
:
lineColumn
.
start
.
line
,
column
:
0
},
end
:
{
line
:
lineColumn
.
start
.
line
+
1
,
column
:
0
}
}
}
return
editor
.
addMarker
(
lineColumn
,
compiler
.
lastCompilationResult
.
data
.
sourceList
[
position
.
file
],
css
)
}
return
null
},
stopHighlighting
:
(
event
)
=>
{
editor
.
removeMarker
(
event
.
eventId
,
event
.
fileTarget
)
}
},
{
compiler
:
compiler
.
event
,
editor
:
editor
.
event
})
// ---------------- ContextView -----------------------
this
.
_components
.
contextView
=
new
ContextView
({
contextualListener
:
this
.
_components
.
contextualListener
},
{
contextualListener
:
this
.
_components
.
contextualListener
.
event
})
// ----------------- editor panel ----------------------
this
.
_components
.
editorpanel
=
new
EditorPanel
({
api
:
{
editor
:
self
.
_components
.
editor
,
config
:
self
.
_api
.
config
,
txListener
:
txlistener
txListener
:
txlistener
,
contextview
:
self
.
_components
.
contextView
}
})
this
.
_components
.
editorpanel
.
event
.
register
(
'resize'
,
direction
=>
self
.
_adjustLayout
(
direction
))
...
...
@@ -263,7 +332,6 @@ function run () {
var
queryParams
=
new
QueryParams
()
var
gistHandler
=
new
GistHandler
()
var
editor
=
self
.
_components
.
editor
// The event listener needs to be registered as early as possible, because the
// parent will send the message upon the "load" event.
var
filesToLoad
=
null
...
...
@@ -370,71 +438,6 @@ function run () {
fileManager
.
switchFile
()
}
var
compiler
=
new
Compiler
((
url
,
cb
)
=>
{
var
provider
=
fileManager
.
fileProviderOf
(
url
)
if
(
provider
&&
provider
.
exists
(
url
))
{
return
provider
.
get
(
url
,
cb
)
}
handleImports
.
import
(
url
,
(
error
,
content
)
=>
{
if
(
!
error
)
{
// FIXME: at some point we should invalidate the browser cache
filesProviders
[
'browser'
].
addReadOnly
(
url
,
content
)
cb
(
null
,
content
)
}
else
{
cb
(
error
)
}
})
})
var
offsetToLineColumnConverter
=
new
OffsetToLineColumnConverter
(
compiler
.
event
)
// ---------------- ContextualListener -----------------------
this
.
_components
.
contextualListener
=
new
ContextualListener
({
getCursorPosition
:
()
=>
{
return
this
.
_components
.
editor
.
getCursorPosition
()
},
getCompilationResult
:
()
=>
{
return
compiler
.
lastCompilationResult
},
getCurrentFile
:
()
=>
{
return
config
.
get
(
'currentFile'
)
},
highlight
:
(
position
,
node
)
=>
{
if
(
compiler
.
lastCompilationResult
&&
compiler
.
lastCompilationResult
.
data
)
{
var
lineColumn
=
offsetToLineColumnConverter
.
offsetToLineColumn
(
position
,
position
.
file
,
compiler
.
lastCompilationResult
)
var
css
=
'highlightreference'
if
(
node
.
children
&&
node
.
children
.
length
)
{
// If node has children, highlight the entire line. if not, just highlight the current source position of the node.
css
=
'highlightreferenceline'
lineColumn
=
{
start
:
{
line
:
lineColumn
.
start
.
line
,
column
:
0
},
end
:
{
line
:
lineColumn
.
start
.
line
+
1
,
column
:
0
}
}
}
return
editor
.
addMarker
(
lineColumn
,
compiler
.
lastCompilationResult
.
data
.
sourceList
[
position
.
file
],
css
)
}
return
null
},
stopHighlighting
:
(
event
)
=>
{
editor
.
removeMarker
(
event
.
eventId
,
event
.
fileTarget
)
}
},
{
compiler
:
compiler
.
event
,
editor
:
editor
.
event
})
// ---------------- ContextView -----------------------
this
.
_components
.
contextView
=
new
ContextView
({
contextualListener
:
this
.
_components
.
contextualListener
},
{
contextualListener
:
this
.
_components
.
contextualListener
.
event
})
// ----------------- Renderer -----------------
var
rendererAPI
=
{
error
:
(
file
,
error
)
=>
{
...
...
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