Commit 1119c5bb authored by yann300's avatar yann300

merge editor plugin

parent c64a11ca
...@@ -247,7 +247,7 @@ Please make a backup of your contracts and start using http://remix.ethereum.org ...@@ -247,7 +247,7 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
appManager.register([ appManager.register([
contentImport, contentImport,
themeModule, themeModule,
editor.sourceHighlighters, editor,
fileManager, fileManager,
compilerMetadataGenerator, compilerMetadataGenerator,
compilersArtefacts, compilersArtefacts,
......
...@@ -4,26 +4,16 @@ const SourceHighlighter = require('./sourceHighlighter') ...@@ -4,26 +4,16 @@ const SourceHighlighter = require('./sourceHighlighter')
import { Plugin } from '@remixproject/engine' import { Plugin } from '@remixproject/engine'
import * as packageJson from '../../../package.json' import * as packageJson from '../../../package.json'
const profile = {
displayName: 'Editor',
name: 'editor',
description: 'service - highlight source code',
version: packageJson.version,
methods: ['highlight', 'discardHighlight']
}
// EditorApi: // EditorApi:
// - methods: ['highlight', 'discardHighlight'], // - methods: ['highlight', 'discardHighlight'],
class SourceHighlighters extends Plugin { class SourceHighlighters {
constructor () { constructor () {
super(profile)
this.highlighters = {} this.highlighters = {}
} }
highlight (position, filePath, hexColor) { highlight (position, filePath, hexColor, from) {
const { from } = this.currentRequest
try { try {
if (!this.highlighters[from]) this.highlighters[from] = new SourceHighlighter() if (!this.highlighters[from]) this.highlighters[from] = new SourceHighlighter()
this.highlighters[from].currentSourceLocation(null) this.highlighters[from].currentSourceLocation(null)
...@@ -33,8 +23,7 @@ class SourceHighlighters extends Plugin { ...@@ -33,8 +23,7 @@ class SourceHighlighters extends Plugin {
} }
} }
discardHighlight () { discardHighlight (from) {
const { from } = this.currentRequest
if (this.highlighters[from]) this.highlighters[from].currentSourceLocation(null) if (this.highlighters[from]) this.highlighters[from].currentSourceLocation(null)
} }
} }
......
...@@ -3,6 +3,8 @@ const EventManager = require('../../lib/events') ...@@ -3,6 +3,8 @@ const EventManager = require('../../lib/events')
const yo = require('yo-yo') const yo = require('yo-yo')
const csjs = require('csjs-inject') const csjs = require('csjs-inject')
const ace = require('brace') const ace = require('brace')
import { Plugin } from '@remixproject/engine'
import * as packageJson from '../../../package.json'
const globalRegistry = require('../../global/registry') const globalRegistry = require('../../global/registry')
const SourceHighlighters = require('./SourceHighlighters') const SourceHighlighters = require('./SourceHighlighters')
...@@ -37,9 +39,18 @@ document.head.appendChild(yo` ...@@ -37,9 +39,18 @@ document.head.appendChild(yo`
</style> </style>
`) `)
class Editor { const profile = {
displayName: 'Editor',
name: 'editor',
description: 'service - editor',
version: packageJson.version,
methods: ['highlight', 'discardHighlight', 'clearAnnotations', 'addAnnotation']
}
class Editor extends Plugin {
constructor (opts = {}, themeModule) { constructor (opts = {}, themeModule) {
super(profile)
// Dependancies // Dependancies
this._components = {} this._components = {}
this._components.registry = globalRegistry this._components.registry = globalRegistry
...@@ -177,6 +188,16 @@ class Editor { ...@@ -177,6 +188,16 @@ class Editor {
}) })
} }
highlight (position, filePath, hexColor) {
const { from } = this.currentRequest
this.sourceHighlighters.highlight(position, filePath, hexColor, from)
}
discardHighlight () {
const { from } = this.currentRequest
this.sourceHighlighters.discardHighlight(from)
}
setTheme (type) { setTheme (type) {
this.editor.setTheme('ace/theme/' + this._themes[type]) this.editor.setTheme('ace/theme/' + this._themes[type])
} }
......
...@@ -178,6 +178,7 @@ module.exports = class TestTab extends ViewPlugin { ...@@ -178,6 +178,7 @@ module.exports = class TestTab extends ViewPlugin {
} }
runTests () { runTests () {
this.call('editor', 'clearAnnotations')
this.testsOutput.innerHTML = '' this.testsOutput.innerHTML = ''
this.testsSummary.innerHTML = '' this.testsSummary.innerHTML = ''
var tests = this.data.selectedTests var tests = this.data.selectedTests
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment