Skip to content

Commit 52689d0

Browse files
author
马蹄疾
authored
Merge branch 'dashboard' into git-push
2 parents 628e813 + 3d6dc37 commit 52689d0

File tree

24 files changed

+343
-248
lines changed

24 files changed

+343
-248
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
dist: trusty
22
language: node_js
33
node_js:
4-
- '7'
4+
- '10.14.1'
55

66
cache: yarn
77

app/commons/File/actions.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import flattenDeep from 'lodash/flattenDeep'
22
import { registerAction } from 'utils/actions'
33
import settings from 'settings'
44
import is from 'utils/is'
5-
import { capitalize } from 'lodash'
65
import { action, when } from 'mobx'
76
import api from 'backendAPI'
87
import config from 'config'
@@ -70,8 +69,8 @@ const setLanguageSetting = (data) => {
7069
showModal({ type: 'ProjectTypeSelector', position: 'center', data })
7170
} else if (data.length === 1) {
7271
const { type, srcPath } = data[0]
73-
config.mainLanguage = capitalize(type)
74-
settings.languageserver.projectType.value = capitalize(type)
72+
config.mainLanguage = type
73+
settings.languageserver.projectType.value = type
7574
settings.languageserver.sourcePath.value = srcPath
7675
}
7776
}
@@ -96,7 +95,7 @@ export const fetchProjectRoot = registerAction('fs:init', () =>
9695
}
9796
fetchLanguageServerSetting(config.spaceKey).then((res) => {
9897
if (res.code === 0 && res.data) {
99-
setLanguageSetting(res.data.default)
98+
setLanguageSetting([res.data])
10099
} else {
101100
tryIdentificationWorkSpaceType(data)
102101
.then(setLanguageSetting)

app/components/Modal/ProjectTypeSelector/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import { dismissModal } from 'components/Modal/actions'
1010
class ProjectTypeSelector extends PureComponent {
1111
handleClick = (data) => {
1212
const { type, srcPath } = data
13-
config.mainLanguage = capitalize(type)
14-
settings.languageserver.projectType.value = capitalize(type)
13+
config.mainLanguage = type
14+
settings.languageserver.projectType.value = type
1515
settings.languageserver.sourcePath.value = srcPath
1616
setLanguageServerOne(data)
1717
dismissModal()

app/components/MonacoEditor/Editors/createHelper.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export function createLanguageClient (services, connection) {
9393
initializationFailedHandler: (err) => {
9494
const detail = err instanceof Error ? err.message : ''
9595
},
96-
diagnosticCollectionName: lowerCase(config.mainLanguage)
96+
diagnosticCollectionName: config.mainLanguage.toLowerCase()
9797
},
9898
// services,
9999
connectionProvider: {
@@ -119,7 +119,7 @@ export function createWebSocket () {
119119
transports: ['websocket'],
120120
query: {
121121
ws: config.spaceKey,
122-
language: lowerCase(config.mainLanguage)
122+
language: config.mainLanguage.toLowerCase()
123123
}
124124
}
125125
return io.connect(

app/components/MonacoEditor/LanguageClientState.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import {
2626
JAVA_UPDATE_DEBUG_SETTINGS,
2727
JAVA_PROJECT_CONFIGURATION_UPDATE,
2828
LANGUAGE_PROGRESS_REPORT,
29+
OMNISHARP_METADATA,
2930
} from 'components/MonacoEditor/languageRequestTypes'
3031
import emitter, { SOCKET_RETRY, OFFLINE_WS_SYSTEM } from 'utils/emitter'
3132
import isConfigFile from './utils/isConfigFile'
@@ -105,8 +106,8 @@ export class LanguageClient {
105106
this.ioToWebSocket.onopen()
106107
})
107108

108-
this.socket.on('message', ({ data }) => {
109-
this.ioToWebSocket.onmessage({ data })
109+
this.socket.on('message', (response) => {
110+
this.ioToWebSocket.onmessage({ data: response.data ? response.data : response })
110111
})
111112

112113
this.start()
@@ -125,7 +126,6 @@ export class LanguageClient {
125126
this.client = createLanguageClient(
126127
this.services,
127128
connection,
128-
this.curLanguage
129129
)
130130
this.client.onReady()
131131
.then(() => {
@@ -185,6 +185,10 @@ export class LanguageClient {
185185
fetchJavaClassContent = params =>
186186
this.client.sendRequest(JAVA_CLASS_PATH_REQUEST, params)
187187

188+
fetchOmnisharpMetadata = params => {
189+
return this.client.sendRequest(OMNISHARP_METADATA, params)
190+
}
191+
188192
shutdown = () => this.client.sendRequest(ShutdownRequest.type)
189193

190194
exit = () => this.client.sendNotification(ExitNotification.type)

app/components/MonacoEditor/MonacoReact/BaseEditor.jsx

Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -78,60 +78,60 @@ class MonacoEditor extends React.PureComponent {
7878
}
7979
})
8080

81-
autorun(() => {
82-
const languageClient = languageState.clients.get(this.language)
83-
if (languageClient) {
84-
let path, content
85-
if (this.editor.file) {
86-
path = this.editor.file.path
87-
content = this.editor.file.content
88-
} else {
89-
path = this.editor.uri
90-
content = this.editor.content
91-
}
92-
/**
93-
* client 状态
94-
* enum ClientState {
95-
* Initial, // 0
96-
* Starting, // 1
97-
* StartFailed, // 2
98-
* Running, // 3
99-
* Stopping, // 4
100-
* Stopped, // 5
101-
* }
102-
*/
103-
const uri = path.startsWith('jdt://') ? path : `file://${languageClient._ROOT_URI_}${path}`
104-
let model = monaco.editor.getModel(uri)
105-
if (!model) {
106-
model = monaco.editor.createModel(
107-
content,
108-
lowerCase(this.language),
109-
monaco.Uri.parse(path.startsWith('jdt://') ? path : `file://${languageClient._ROOT_URI_}${path}`)
110-
)
111-
this.uri = path.startsWith('jdt://') ? path : `file://${languageClient._ROOT_URI_}${path}`
112-
const tmpModel = monaco.editor.getModel(`inmemory://model/${this.editor.id}`)
113-
if (tmpModel) {
114-
tmpModel.dispose()
115-
}
116-
}
117-
this.editor.model = model
118-
monacoEditor.setModel(model)
119-
const { client, openeduri } = languageClient
120-
if (client && client.state === 3 && this.props.active && this.didmount) {
121-
if (!openeduri.get(path)) {
122-
languageClient.openTextDocument({
123-
textDocument: {
124-
uri: `file://${languageClient._ROOT_URI_}${path}`,
125-
languageId: lowerCase(this.language),
126-
text: content,
127-
version: 1,
128-
}
129-
})
130-
openeduri.set(path, content)
131-
}
132-
}
133-
}
134-
})
81+
// autorun(() => {
82+
// const languageClient = languageState.clients.get(this.language)
83+
// if (languageClient) {
84+
// let path, content
85+
// if (this.editor.file) {
86+
// path = this.editor.file.path
87+
// content = this.editor.file.content
88+
// } else {
89+
// path = this.editor.uri
90+
// content = this.editor.content
91+
// }
92+
// /**
93+
// * client 状态
94+
// * enum ClientState {
95+
// * Initial, // 0
96+
// * Starting, // 1
97+
// * StartFailed, // 2
98+
// * Running, // 3
99+
// * Stopping, // 4
100+
// * Stopped, // 5
101+
// * }
102+
// */
103+
// const uri = path.startsWith('jdt://') || path.startsWith('omnisharp-metadata') ? path : `file://${languageClient._ROOT_URI_}${path}`
104+
// let model = monaco.editor.getModel(uri)
105+
// if (!model) {
106+
// model = monaco.editor.createModel(
107+
// content,
108+
// this.language.toLowerCase(),
109+
// monaco.Uri.parse(path.startsWith('jdt://') || path.startsWith('omnisharp-metadata') ? path : `file://${languageClient._ROOT_URI_}${path}`)
110+
// )
111+
// this.uri = path.startsWith('jdt://') || path.startsWith('omnisharp-metadata') ? path : `file://${languageClient._ROOT_URI_}${path}`
112+
// const tmpModel = monaco.editor.getModel(`inmemory://model/${this.editor.id}`)
113+
// if (tmpModel) {
114+
// tmpModel.dispose()
115+
// }
116+
// }
117+
// this.editor.model = model
118+
// monacoEditor.setModel(model)
119+
// const { client, openeduri } = languageClient
120+
// if (client && client.state === 3 && this.props.active && this.didmount) {
121+
// // if (!openeduri.get(path)) {
122+
// // languageClient.openTextDocument({
123+
// // textDocument: {
124+
// // uri: path.startsWith('jdt://') || path.startsWith('omnisharp-metadata') ? path : `file://${languageClient._ROOT_URI_}${path}`,
125+
// // languageId: this.language.toLowerCase(),
126+
// // text: content,
127+
// // version: 1,
128+
// // }
129+
// // })
130+
// // openeduri.set(path, content)
131+
// // }
132+
// }
133+
// }
134+
// })
135135
}
136136

137137
componentWillReceiveProps (nextProps) {

app/components/MonacoEditor/actions.js

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import LanguageState, { LanguageClient } from './LanguageClientState'
1111
import { supportLangServer } from './utils/languages'
1212

1313
const INMEMORY = 'inmemory'
14+
const CSHARP_METADATE = 'omnisharp-metadata'
1415
const JDT = 'jdt'
1516

1617
when(() => config.spaceKey !== '', () => {
@@ -21,14 +22,8 @@ export const toDefinition = registerAction('monaco:goto_definition', (params) =>
2122
const { resource } = params
2223
const { path, scheme } = resource
2324
if (scheme === INMEMORY) return false
24-
if (scheme !== JDT) {
25-
const relativePath = path.substring(config.__WORKSPACE_URI__.length)
26-
openFile({
27-
path: relativePath,
28-
editor: { filePath: relativePath, selection: params.options && params.options.selection },
29-
})
30-
} else {
31-
const languageClient = LanguageState.clients.get(config.mainLanguage)
25+
const languageClient = LanguageState.clients.get(config.mainLanguage)
26+
if (scheme === JDT) {
3227
const fileName = resource.path.split('/').pop()
3328
const name = fileName.endsWith('class') ? `${fileName.substr(0, fileName.length - 5)}java` : fileName
3429
const tabItem = TabState.tabs.get(`fake_${name}`)
@@ -51,15 +46,41 @@ export const toDefinition = registerAction('monaco:goto_definition', (params) =>
5146
selection: params.options.selection,
5247
content: data,
5348
readOnly: true,
54-
filePath: formattedUri,
49+
filePath: `${formattedUri.substr(0, formattedUri.length - 5)}java`,
50+
},
51+
})
52+
})
53+
}
54+
} else if (scheme === CSHARP_METADATE) {
55+
const uri = decodeURIComponent(resource.toString()).replace('[metadata] ', '').replace('omnisharp-metadata://', '')
56+
const fileName = resource.path.split('/').pop()
57+
const tabItem = TabState.tabs.get(`fake_${fileName}`)
58+
if (tabItem) {
59+
tabItem.activate()
60+
} else {
61+
languageClient.fetchOmnisharpMetadata({ uri })
62+
.then((data) => {
63+
createTab({
64+
title: fileName,
65+
id: `fake_${fileName}`,
66+
icon: 'fa fa-file-o',
67+
editor: {
68+
selection: params.options.selection,
69+
content: data,
70+
readOnly: true,
71+
filePath: resource.toString(),
5572
},
5673
})
5774
})
5875
}
76+
} else {
77+
const relativePath = path.substring(config.__WORKSPACE_URI__.length)
78+
openFile({
79+
path: relativePath,
80+
editor: { filePath: relativePath, selection: params.options && params.options.selection },
81+
})
5982
}
60-
/**
61-
*
62-
*/
83+
6384
return new Promise((resolve, reject) => {
6485
resolve({
6586
getControl: () => null

app/components/MonacoEditor/codeEditorService.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class CodeEditorService {
5757
openCodeEditor (input, source) {
5858
toDefinition(input)
5959
const editor = this.doOpenEditor(source, input)
60-
return monaco.Promise.as(editor)
60+
return monaco.Promise.as(null)
6161
}
6262
}
6363

app/components/MonacoEditor/languageRequestTypes.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,8 @@ export const JAVA_FETCH_USAGE_DATA = 'vscode.java.fetchUsageData'
1515
export const JAVA_UPDATE_DEBUG_SETTINGS = 'vscode.java.updateDebugSettings'
1616
export const JAVA_BUILD_WORKSPACE = 'vscode.java.buildWorkspace'
1717
export const JAVA_START_DEBUGSESSION = 'vscode.java.startDebugSession'
18+
19+
/**
20+
* omnisharp
21+
*/
22+
export const OMNISHARP_METADATA = 'omnisharp/metadata'

app/components/MonacoEditor/state.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,13 @@ class EditorInfo {
4545
state.entities.set(this.id, this)
4646
EditorState.entities.set(this.id, this)
4747
this.update(props)
48-
this.uri = this.filePath || `inmemory://model/${this.id}`
48+
this.uri = this.filePath
49+
? (this.filePath.startsWith('jdt://')
50+
|| this.filePath.startsWith('omnisharp-metadata://')
51+
? this.filePath
52+
: `file://${config._ROOT_URI_}${this.filePath}`)
53+
: `inmemory://model/${this.id}`
54+
4955
if (!props.filePath || this.isMonaco) {
5056
this.createMonacoEditorInstance(props)
5157
}
@@ -60,10 +66,9 @@ class EditorInfo {
6066
if (this.filePath) {
6167
this.languageMode = findLanguageByextensions(this.filePath.split('.').pop()).id
6268
}
63-
6469
const model =
65-
monaco.editor.getModel(monaco.Uri.parse(this.uri).toString()) ||
66-
monaco.editor.createModel(this.content || '', this.languageMode, monaco.Uri.parse(this.uri))
70+
monaco.editor.getModel(monaco.Uri.parse(this.uri).toString()) ||
71+
monaco.editor.createModel(this.content || '', this.languageMode, monaco.Uri.parse(this.uri))
6772
this.uri = model.uri._formatted
6873
const monacoEditor = monaco.editor.create(
6974
this.monacoElement,
@@ -302,9 +307,7 @@ class EditorInfo {
302307
filePath: String,
303308
gitBlame: Object
304309
})
305-
if (!this.file && props.content) {
306-
this._content = props.content
307-
}
310+
this._content = props.content || ''
308311

309312
if (props.monacoEditor) {
310313
this.monacoEditor = props.monacoEditor

0 commit comments

Comments
 (0)