Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
b275fc78
V
vscode
项目概览
xxadev
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
b275fc78
编写于
7月 26, 2017
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
introduce IColorDecorationExtraOptions
clean up monaco.d.ts
上级
7efa9545
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
122 addition
and
136 deletion
+122
-136
src/vs/editor/common/editorCommon.ts
src/vs/editor/common/editorCommon.ts
+0
-11
src/vs/editor/common/model/textModelWithDecorations.ts
src/vs/editor/common/model/textModelWithDecorations.ts
+17
-5
src/vs/editor/common/modes.ts
src/vs/editor/common/modes.ts
+1
-16
src/vs/editor/contrib/colorPicker/browser/colorPicker.ts
src/vs/editor/contrib/colorPicker/browser/colorPicker.ts
+19
-20
src/vs/editor/contrib/colorPicker/common/color.ts
src/vs/editor/contrib/colorPicker/common/color.ts
+17
-0
src/vs/editor/contrib/hover/browser/modesContentHover.ts
src/vs/editor/contrib/hover/browser/modesContentHover.ts
+59
-42
src/vs/editor/contrib/hover/common/hover.ts
src/vs/editor/contrib/hover/common/hover.ts
+2
-6
src/vs/monaco.d.ts
src/vs/monaco.d.ts
+1
-30
src/vs/workbench/api/node/extHostTypeConverters.ts
src/vs/workbench/api/node/extHostTypeConverters.ts
+4
-4
src/vs/workbench/test/electron-browser/api/extHostLanguageFeatures.test.ts
...test/electron-browser/api/extHostLanguageFeatures.test.ts
+2
-2
未找到文件。
src/vs/editor/common/editorCommon.ts
浏览文件 @
b275fc78
...
...
@@ -25,7 +25,6 @@ import * as editorOptions from 'vs/editor/common/config/editorOptions';
import
{
ICursorPositionChangedEvent
,
ICursorSelectionChangedEvent
}
from
'
vs/editor/common/controller/cursorEvents
'
;
import
{
ICursors
,
CursorConfiguration
}
from
'
vs/editor/common/controller/cursorCommon
'
;
import
{
ThemeColor
}
from
'
vs/platform/theme/common/themeService
'
;
import
{
Color
}
from
'
vs/base/common/color
'
;
/**
* Vertical Lane in the overview ruler of the editor.
...
...
@@ -62,12 +61,6 @@ export interface IModelDecorationOverviewRulerOptions {
position
:
OverviewRulerLane
;
}
export
type
IColorFormat
=
string
|
{
opaque
:
string
,
transparent
:
string
};
export
interface
IColorInfo
{
color
:
Color
;
format
:
IColorFormat
;
availableFormats
:
IColorFormat
[];
}
/**
* Options for a model decoration.
*/
...
...
@@ -89,10 +82,6 @@ export interface IModelDecorationOptions {
* Array of MarkedString to render as the decoration message.
*/
hoverMessage
?:
MarkedString
|
MarkedString
[];
/**
* Color with mode to render in the color picker.
*/
colorInfo
?:
IColorInfo
;
/**
* Should the decoration expand to encompass a whole line.
*/
...
...
src/vs/editor/common/model/textModelWithDecorations.ts
浏览文件 @
b275fc78
...
...
@@ -879,15 +879,23 @@ export class ModelDecorationOverviewRulerOptions implements editorCommon.IModelD
let
lastStaticId
=
0
;
// TODO@Joao
// This was introduced to solve the color problem.
// We don't want to expose colors in decorations, although
// we piggyback on decorations to implement colors in the model.
export
interface
IModelDecorationExtraOptions
{
__extraOptions
?:
any
;
}
export
class
ModelDecorationOptions
implements
editorCommon
.
IModelDecorationOptions
{
public
static
EMPTY
:
ModelDecorationOptions
;
public
static
register
(
options
:
editorCommon
.
IModelDecorationOptions
):
ModelDecorationOptions
{
public
static
register
(
options
:
editorCommon
.
IModelDecorationOptions
&
IModelDecorationExtraOptions
):
ModelDecorationOptions
{
return
new
ModelDecorationOptions
(
++
lastStaticId
,
options
);
}
public
static
createDynamic
(
options
:
editorCommon
.
IModelDecorationOptions
):
ModelDecorationOptions
{
public
static
createDynamic
(
options
:
editorCommon
.
IModelDecorationOptions
&
IModelDecorationExtraOptions
):
ModelDecorationOptions
{
return
new
ModelDecorationOptions
(
0
,
options
);
}
...
...
@@ -895,7 +903,6 @@ export class ModelDecorationOptions implements editorCommon.IModelDecorationOpti
readonly
stickiness
:
editorCommon
.
TrackedRangeStickiness
;
readonly
className
:
string
;
readonly
hoverMessage
:
MarkedString
|
MarkedString
[];
readonly
colorInfo
:
editorCommon
.
IColorInfo
;
readonly
glyphMarginHoverMessage
:
MarkedString
|
MarkedString
[];
readonly
isWholeLine
:
boolean
;
readonly
showIfCollapsed
:
boolean
;
...
...
@@ -906,13 +913,13 @@ export class ModelDecorationOptions implements editorCommon.IModelDecorationOpti
readonly
inlineClassName
:
string
;
readonly
beforeContentClassName
:
string
;
readonly
afterContentClassName
:
string
;
readonly
extraOptions
:
any
;
private
constructor
(
staticId
:
number
,
options
:
editorCommon
.
IModelDecorationOptions
)
{
private
constructor
(
staticId
:
number
,
options
:
editorCommon
.
IModelDecorationOptions
&
IModelDecorationExtraOptions
)
{
this
.
staticId
=
staticId
;
this
.
stickiness
=
options
.
stickiness
||
editorCommon
.
TrackedRangeStickiness
.
AlwaysGrowsWhenTypingAtEdges
;
this
.
className
=
options
.
className
?
cleanClassName
(
options
.
className
)
:
strings
.
empty
;
this
.
hoverMessage
=
options
.
hoverMessage
||
[];
this
.
colorInfo
=
options
.
colorInfo
||
undefined
;
this
.
glyphMarginHoverMessage
=
options
.
glyphMarginHoverMessage
||
strings
.
empty
;
this
.
isWholeLine
=
options
.
isWholeLine
||
false
;
this
.
showIfCollapsed
=
options
.
showIfCollapsed
||
false
;
...
...
@@ -923,6 +930,10 @@ export class ModelDecorationOptions implements editorCommon.IModelDecorationOpti
this
.
inlineClassName
=
options
.
inlineClassName
?
cleanClassName
(
options
.
inlineClassName
)
:
strings
.
empty
;
this
.
beforeContentClassName
=
options
.
beforeContentClassName
?
cleanClassName
(
options
.
beforeContentClassName
)
:
strings
.
empty
;
this
.
afterContentClassName
=
options
.
afterContentClassName
?
cleanClassName
(
options
.
afterContentClassName
)
:
strings
.
empty
;
if
(
options
.
__extraOptions
)
{
this
.
extraOptions
=
options
.
__extraOptions
;
}
}
public
equals
(
other
:
ModelDecorationOptions
):
boolean
{
...
...
@@ -944,6 +955,7 @@ export class ModelDecorationOptions implements editorCommon.IModelDecorationOpti
&&
markedStringsEquals
(
this
.
hoverMessage
,
other
.
hoverMessage
)
&&
markedStringsEquals
(
this
.
glyphMarginHoverMessage
,
other
.
glyphMarginHoverMessage
)
&&
this
.
overviewRuler
.
equals
(
other
.
overviewRuler
)
&&
this
.
extraOptions
===
other
.
extraOptions
);
}
}
...
...
src/vs/editor/common/modes.ts
浏览文件 @
b275fc78
...
...
@@ -156,7 +156,7 @@ export interface IState {
* A hover represents additional information for a symbol or word. Hovers are
* rendered in a tooltip-like widget.
*/
export
interface
MarkedString
Hover
{
export
interface
Hover
{
/**
* The contents of this hover.
*/
...
...
@@ -170,21 +170,6 @@ export interface MarkedStringHover {
range
:
IRange
;
}
// TODO@michel documentation
export
interface
ColorHover
{
color
:
Color
;
format
:
IColorFormat
;
availableFormats
:
IColorFormat
[];
/**
* The range to which this hover applies. When missing, the
* editor will use the range at the current position or the
* current position itself.
*/
range
:
IRange
;
}
export
type
Hover
=
MarkedStringHover
|
ColorHover
;
/**
* The hover provider interface defines the contract between extensions and
* the [hover](https://code.visualstudio.com/docs/editor/intellisense)-feature.
...
...
src/vs/editor/contrib/colorPicker/browser/colorPicker.ts
浏览文件 @
b275fc78
...
...
@@ -3,16 +3,17 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
{
ICommonCodeEditor
,
IEditorContribution
,
IModelDecorationsChangeAccessor
,
IModelDeltaDecoration
}
from
"
vs/editor/common/editorCommon
"
;
import
{
editorContribution
}
from
"
vs/editor/browser/editorBrowserExtensions
"
;
import
{
ICodeEditor
}
from
"
vs/editor/browser/editorBrowser
"
;
import
{
IDisposable
,
dispose
}
from
"
vs/base/common/lifecycle
"
;
import
{
registerThemingParticipant
}
from
"
vs/platform/theme/common/themeService
"
;
import
{
editorWidgetBackground
,
editorWidgetBorder
}
from
"
vs/platform/theme/common/colorRegistry
"
;
import
{
ColorProviderRegistry
,
IColorInfo
}
from
"
vs/editor/common/modes
"
;
import
{
TPromise
}
from
"
vs/base/common/winjs.base
"
;
import
{
getColors
}
from
"
vs/editor/contrib/colorPicker/common/colorPicker
"
;
import
{
IRange
}
from
"
vs/editor/common/core/range
"
;
import
{
ICommonCodeEditor
,
IEditorContribution
,
IModelDecorationsChangeAccessor
,
IModelDeltaDecoration
}
from
'
vs/editor/common/editorCommon
'
;
import
{
editorContribution
}
from
'
vs/editor/browser/editorBrowserExtensions
'
;
import
{
ICodeEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
registerThemingParticipant
}
from
'
vs/platform/theme/common/themeService
'
;
import
{
editorWidgetBackground
,
editorWidgetBorder
}
from
'
vs/platform/theme/common/colorRegistry
'
;
import
{
ColorProviderRegistry
,
IColorInfo
}
from
'
vs/editor/common/modes
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
getColors
}
from
'
vs/editor/contrib/colorPicker/common/colorPicker
'
;
import
{
IRange
}
from
'
vs/editor/common/core/range
'
;
import
{
IColorDecorationExtraOptions
}
from
'
../common/color
'
;
@
editorContribution
export
class
ColorPicker
implements
IEditorContribution
{
...
...
@@ -111,18 +112,16 @@ export class ColorPicker implements IEditorContribution {
endColumn
:
c
.
range
.
endColumn
};
const
decoration
=
{
range
:
range
,
options
:
{
colorInfo
:
{
color
:
c
.
color
,
format
:
c
.
format
,
availableFormats
:
c
.
availableFormats
}
}
const
extraOptions
:
IColorDecorationExtraOptions
=
{
color
:
c
.
color
,
format
:
c
.
format
,
availableFormats
:
c
.
availableFormats
};
newDecorations
.
push
(
decoration
);
// TODO@Joao
const
options
=
{
__extraOptions
:
extraOptions
}
as
any
;
newDecorations
.
push
({
range
,
options
});
}
this
.
currentDecorations
=
changeAccessor
.
deltaDecorations
(
this
.
currentDecorations
,
newDecorations
);
...
...
src/vs/editor/contrib/colorPicker/common/color.ts
0 → 100644
浏览文件 @
b275fc78
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
{
IColorFormat
}
from
'
vs/editor/common/modes
'
;
import
{
Color
}
from
'
vs/base/common/color
'
;
export
interface
IColorDecorationExtraOptions
{
readonly
color
:
Color
;
readonly
format
:
IColorFormat
;
readonly
availableFormats
:
IColorFormat
[];
}
export
function
isColorDecorationOptions
(
options
:
any
):
options
is
IColorDecorationExtraOptions
{
return
!!
(
options
&&
(
options
as
any
).
color
);
}
\ No newline at end of file
src/vs/editor/contrib/hover/browser/modesContentHover.ts
浏览文件 @
b275fc78
...
...
@@ -12,25 +12,38 @@ import { TPromise } from 'vs/base/common/winjs.base';
import
{
renderMarkedString
}
from
'
vs/base/browser/htmlContentRenderer
'
;
import
{
IOpenerService
,
NullOpenerService
}
from
'
vs/platform/opener/common/opener
'
;
import
{
IModeService
}
from
'
vs/editor/common/services/modeService
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
IRange
,
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
Position
}
from
'
vs/editor/common/core/position
'
;
import
{
HoverProviderRegistry
,
Hover
}
from
'
vs/editor/common/modes
'
;
import
{
HoverProviderRegistry
,
Hover
,
IColorFormat
}
from
'
vs/editor/common/modes
'
;
import
{
tokenizeToString
}
from
'
vs/editor/common/modes/textToHtmlTokenizer
'
;
import
{
ICodeEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
getHover
,
isColorHover
}
from
'
../common/hover
'
;
import
{
getHover
}
from
'
../common/hover
'
;
import
{
HoverOperation
,
IHoverComputer
}
from
'
./hoverOperation
'
;
import
{
ContentHoverWidget
}
from
'
./hoverWidgets
'
;
import
{
textToMarkedString
,
MarkedString
}
from
'
vs/base/common/htmlContent
'
;
import
{
ModelDecorationOptions
}
from
'
vs/editor/common/model/textModelWithDecorations
'
;
import
{
ColorPickerModel
}
from
"
vs/editor/contrib/colorPicker/browser/colorPickerModel
"
;
import
{
ColorPickerWidget
}
from
"
vs/editor/contrib/colorPicker/browser/colorPickerWidget
"
;
import
{
IColorInfo
}
from
'
vs/editor/common/editorCommon
'
;
import
{
ColorFormatter
}
from
"
vs/editor/contrib/colorPicker/common/colorFormatter
"
;
import
{
isColorDecorationOptions
}
from
'
vs/editor/contrib/colorPicker/common/color
'
;
import
{
ColorFormatter
}
from
'
vs/editor/contrib/colorPicker/common/colorFormatter
'
;
import
{
Color
}
from
'
vs/base/common/color
'
;
class
ColorHover
{
constructor
(
public
readonly
range
:
IRange
,
public
readonly
color
:
Color
,
public
readonly
format
:
IColorFormat
,
public
readonly
availableFormats
:
IColorFormat
[]
)
{
}
}
type
HoverPart
=
Hover
|
ColorHover
;
class
ModesContentComputer
implements
IHoverComputer
<
Hover
[]
>
{
class
ModesContentComputer
implements
IHoverComputer
<
Hover
Part
[]
>
{
private
_editor
:
ICodeEditor
;
private
_result
:
Hover
[];
private
_result
:
Hover
Part
[];
private
_range
:
Range
;
constructor
(
editor
:
ICodeEditor
)
{
...
...
@@ -47,7 +60,7 @@ class ModesContentComputer implements IHoverComputer<Hover[]> {
this
.
_result
=
[];
}
computeAsync
():
TPromise
<
Hover
[]
>
{
computeAsync
():
TPromise
<
Hover
Part
[]
>
{
const
model
=
this
.
_editor
.
getModel
();
if
(
!
HoverProviderRegistry
.
has
(
model
))
{
...
...
@@ -60,7 +73,7 @@ class ModesContentComputer implements IHoverComputer<Hover[]> {
));
}
computeSync
():
Hover
[]
{
computeSync
():
Hover
Part
[]
{
const
lineNumber
=
this
.
_range
.
startLineNumber
;
if
(
lineNumber
>
this
.
_editor
.
getModel
().
getLineCount
())
{
...
...
@@ -68,7 +81,7 @@ class ModesContentComputer implements IHoverComputer<Hover[]> {
return
[];
}
const
hasHoverContent
=
(
contents
:
MarkedString
|
MarkedString
[]
|
IColorInfo
)
=>
{
const
hasHoverContent
=
(
contents
:
MarkedString
|
MarkedString
[])
=>
{
return
contents
&&
(
!
Array
.
isArray
(
contents
)
||
(
<
MarkedString
[]
>
contents
).
length
>
0
);
};
...
...
@@ -79,45 +92,49 @@ class ModesContentComputer implements IHoverComputer<Hover[]> {
const
startColumn
=
(
d
.
range
.
startLineNumber
===
lineNumber
)
?
d
.
range
.
startColumn
:
1
;
const
endColumn
=
(
d
.
range
.
endLineNumber
===
lineNumber
)
?
d
.
range
.
endColumn
:
maxColumn
;
if
(
startColumn
>
this
.
_range
.
startColumn
||
this
.
_range
.
endColumn
>
endColumn
||
(
!
hasHoverContent
(
d
.
options
.
hoverMessage
)
&&
!
hasHoverContent
(
d
.
options
.
colorInfo
))
)
{
if
(
startColumn
>
this
.
_range
.
startColumn
||
this
.
_range
.
endColumn
>
endColumn
)
{
return
null
;
}
const
range
=
new
Range
(
this
.
_range
.
startLineNumber
,
startColumn
,
this
.
_range
.
startLineNumber
,
endColumn
);
let
contents
:
MarkedString
[];
if
(
d
.
options
.
hoverMessage
)
{
if
(
Array
.
isArray
(
d
.
options
.
hoverMessage
))
{
contents
=
[...
d
.
options
.
hoverMessage
];
}
else
{
contents
=
[
d
.
options
.
hoverMessage
];
// TOOD@Joao
const
options
=
d
.
options
as
any
;
const
extraOptions
=
options
&&
options
.
extraOptions
;
if
(
isColorDecorationOptions
(
extraOptions
))
{
console
.
log
(
'
found color!
'
);
const
{
color
,
format
,
availableFormats
}
=
extraOptions
;
return
new
ColorHover
(
range
,
color
,
format
,
availableFormats
);
}
else
{
if
(
!
hasHoverContent
(
d
.
options
.
hoverMessage
))
{
return
null
;
}
}
const
colorInfo
=
d
.
options
.
colorInfo
;
let
contents
:
MarkedString
[]
;
if
(
colorInfo
)
{
return
{
color
:
colorInfo
.
color
,
format
:
colorInfo
.
format
,
availableFormats
:
colorInfo
.
availableFormats
,
range
:
range
,
};
}
if
(
d
.
options
.
hoverMessage
)
{
if
(
Array
.
isArray
(
d
.
options
.
hoverMessage
))
{
contents
=
[...
d
.
options
.
hoverMessage
];
}
else
{
contents
=
[
d
.
options
.
hoverMessage
];
}
}
return
{
contents
,
range
};
return
{
contents
,
range
};
}
});
return
result
.
filter
(
d
=>
!!
d
);
}
onResult
(
result
:
Hover
[],
isFromSynchronousComputation
:
boolean
):
void
{
onResult
(
result
:
Hover
Part
[],
isFromSynchronousComputation
:
boolean
):
void
{
// Always put synchronous messages before asynchronous ones
if
(
isFromSynchronousComputation
)
{
this
.
_result
=
result
.
concat
(
this
.
_result
.
sort
((
a
,
b
)
=>
{
if
(
isColorHover
(
a
)
)
{
// sort picker messages at to the top
if
(
a
instanceof
ColorHover
)
{
// sort picker messages at to the top
return
-
1
;
}
else
if
(
isColorHover
(
b
)
)
{
}
else
if
(
b
instanceof
ColorHover
)
{
return
1
;
}
return
0
;
...
...
@@ -127,15 +144,15 @@ class ModesContentComputer implements IHoverComputer<Hover[]> {
}
}
getResult
():
Hover
[]
{
getResult
():
Hover
Part
[]
{
return
this
.
_result
.
slice
(
0
);
}
getResultWithLoadingMessage
():
Hover
[]
{
getResultWithLoadingMessage
():
Hover
Part
[]
{
return
this
.
_result
.
slice
(
0
).
concat
([
this
.
_getLoadingMessage
()]);
}
private
_getLoadingMessage
():
Hover
{
private
_getLoadingMessage
():
Hover
Part
{
return
{
range
:
this
.
_range
,
contents
:
[
textToMarkedString
(
nls
.
localize
(
'
modesContentHover.loading
'
,
"
Loading...
"
))]
...
...
@@ -147,10 +164,10 @@ export class ModesContentHoverWidget extends ContentHoverWidget {
static
ID
=
'
editor.contrib.modesContentHoverWidget
'
;
private
_messages
:
Hover
[];
private
_messages
:
Hover
Part
[];
private
_lastRange
:
Range
;
private
_computer
:
ModesContentComputer
;
private
_hoverOperation
:
HoverOperation
<
Hover
[]
>
;
private
_hoverOperation
:
HoverOperation
<
Hover
Part
[]
>
;
private
_highlightDecorations
:
string
[];
private
_isChangingDecorations
:
boolean
;
private
_openerService
:
IOpenerService
;
...
...
@@ -169,9 +186,9 @@ export class ModesContentHoverWidget extends ContentHoverWidget {
this
.
_hoverOperation
=
new
HoverOperation
(
this
.
_computer
,
(
result
:
Hover
[])
=>
this
.
_withResult
(
result
,
true
),
result
=>
this
.
_withResult
(
result
,
true
),
null
,
(
result
:
any
)
=>
this
.
_withResult
(
result
,
false
)
result
=>
this
.
_withResult
(
result
,
false
)
);
}
...
...
@@ -209,7 +226,7 @@ export class ModesContentHoverWidget extends ContentHoverWidget {
if
(
this
.
_showAtPosition
.
lineNumber
!==
range
.
startLineNumber
)
{
this
.
hide
();
}
else
{
var
filteredMessages
:
Hover
[]
=
[];
var
filteredMessages
:
Hover
Part
[]
=
[];
for
(
var
i
=
0
,
len
=
this
.
_messages
.
length
;
i
<
len
;
i
++
)
{
var
msg
=
this
.
_messages
[
i
];
var
rng
=
msg
.
range
;
...
...
@@ -244,7 +261,7 @@ export class ModesContentHoverWidget extends ContentHoverWidget {
}
}
_withResult
(
result
:
Hover
[],
complete
:
boolean
):
void
{
private
_withResult
(
result
:
HoverPart
[],
complete
:
boolean
):
void
{
this
.
_messages
=
result
;
if
(
this
.
_lastRange
&&
this
.
_messages
.
length
>
0
)
{
...
...
@@ -254,7 +271,7 @@ export class ModesContentHoverWidget extends ContentHoverWidget {
}
}
private
_renderMessages
(
renderRange
:
Range
,
messages
:
Hover
[]):
void
{
private
_renderMessages
(
renderRange
:
Range
,
messages
:
Hover
Part
[]):
void
{
// update column from which to show
var
renderColumn
=
Number
.
MAX_VALUE
,
...
...
@@ -269,7 +286,7 @@ export class ModesContentHoverWidget extends ContentHoverWidget {
renderColumn
=
Math
.
min
(
renderColumn
,
msg
.
range
.
startColumn
);
highlightRange
=
Range
.
plusRange
(
highlightRange
,
msg
.
range
);
if
(
!
isColorHover
(
msg
))
{
if
(
!
(
msg
instanceof
ColorHover
))
{
msg
.
contents
.
filter
(
contents
=>
!!
contents
)
.
forEach
(
contents
=>
{
...
...
src/vs/editor/contrib/hover/common/hover.ts
浏览文件 @
b275fc78
...
...
@@ -10,14 +10,10 @@ import { onUnexpectedExternalError } from 'vs/base/common/errors';
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
IReadOnlyModel
}
from
'
vs/editor/common/editorCommon
'
;
import
{
CommonEditorRegistry
}
from
'
vs/editor/common/editorCommonExtensions
'
;
import
{
Hover
,
HoverProviderRegistry
,
ColorHover
}
from
'
vs/editor/common/modes
'
;
import
{
Hover
,
HoverProviderRegistry
}
from
'
vs/editor/common/modes
'
;
import
{
asWinJsPromise
}
from
'
vs/base/common/async
'
;
import
{
Position
}
from
'
vs/editor/common/core/position
'
;
export
function
isColorHover
(
hover
:
Hover
):
hover
is
ColorHover
{
return
!!
(
hover
as
any
).
color
;
}
export
function
getHover
(
model
:
IReadOnlyModel
,
position
:
Position
):
TPromise
<
Hover
[]
>
{
const
supports
=
HoverProviderRegistry
.
ordered
(
model
);
...
...
@@ -29,7 +25,7 @@ export function getHover(model: IReadOnlyModel, position: Position): TPromise<Ho
}).
then
((
result
)
=>
{
if
(
result
)
{
let
hasRange
=
(
typeof
result
.
range
!==
'
undefined
'
);
let
hasHtmlContent
=
!
isColorHover
(
result
)
&&
(
typeof
result
.
contents
!==
'
undefined
'
&&
result
.
contents
&&
result
.
contents
.
length
>
0
)
;
let
hasHtmlContent
=
typeof
result
.
contents
!==
'
undefined
'
&&
result
.
contents
&&
result
.
contents
.
length
>
0
;
if
(
hasRange
&&
hasHtmlContent
)
{
values
[
idx
]
=
result
;
}
...
...
src/vs/monaco.d.ts
浏览文件 @
b275fc78
...
...
@@ -1121,17 +1121,6 @@ declare module monaco.editor {
position
:
OverviewRulerLane
;
}
export
type
IColorFormat
=
string
|
{
opaque
:
string
;
transparent
:
string
;
};
export
interface
IColorInfo
{
color
:
Color
;
format
:
IColorFormat
;
availableFormats
:
IColorFormat
[];
}
/**
* Options for a model decoration.
*/
...
...
@@ -1153,10 +1142,6 @@ declare module monaco.editor {
* Array of MarkedString to render as the decoration message.
*/
hoverMessage
?:
MarkedString
|
MarkedString
[];
/**
* Color with mode to render in the color picker.
*/
colorInfo
?:
IColorInfo
;
/**
* Should the decoration expand to encompass a whole line.
*/
...
...
@@ -4437,7 +4422,7 @@ declare module monaco.languages {
* A hover represents additional information for a symbol or word. Hovers are
* rendered in a tooltip-like widget.
*/
export
interface
MarkedString
Hover
{
export
interface
Hover
{
/**
* The contents of this hover.
*/
...
...
@@ -4450,20 +4435,6 @@ declare module monaco.languages {
range
:
IRange
;
}
export
interface
ColorHover
{
color
:
Color
;
format
:
IColorFormat
;
availableFormats
:
IColorFormat
[];
/**
* The range to which this hover applies. When missing, the
* editor will use the range at the current position or the
* current position itself.
*/
range
:
IRange
;
}
export
type
Hover
=
MarkedStringHover
|
ColorHover
;
/**
* The hover provider interface defines the contract between extensions and
* the [hover](https://code.visualstudio.com/docs/editor/intellisense)-feature.
...
...
src/vs/workbench/api/node/extHostTypeConverters.ts
浏览文件 @
b275fc78
...
...
@@ -16,7 +16,7 @@ import { SaveReason } from 'vs/workbench/services/textfile/common/textfiles';
import
{
IPosition
}
from
'
vs/editor/common/core/position
'
;
import
{
IRange
}
from
'
vs/editor/common/core/range
'
;
import
{
ISelection
}
from
'
vs/editor/common/core/selection
'
;
import
{
IColorInfo
}
from
"
vs/workbench/api/node/extHost.protocol
"
;
import
{
IColorInfo
}
from
'
vs/workbench/api/node/extHost.protocol
'
;
export
interface
PositionLike
{
line
:
number
;
...
...
@@ -254,14 +254,14 @@ export const location = {
}
};
export
function
fromHover
(
hover
:
vscode
.
Hover
):
modes
.
MarkedString
Hover
{
return
<
modes
.
MarkedString
Hover
>
{
export
function
fromHover
(
hover
:
vscode
.
Hover
):
modes
.
Hover
{
return
<
modes
.
Hover
>
{
range
:
fromRange
(
hover
.
range
),
contents
:
hover
.
contents
};
}
export
function
toHover
(
info
:
modes
.
MarkedString
Hover
):
types
.
Hover
{
export
function
toHover
(
info
:
modes
.
Hover
):
types
.
Hover
{
return
new
types
.
Hover
(
info
.
contents
,
toRange
(
info
.
range
));
}
...
...
src/vs/workbench/test/electron-browser/api/extHostLanguageFeatures.test.ts
浏览文件 @
b275fc78
...
...
@@ -26,7 +26,7 @@ import { IHeapService } from 'vs/workbench/api/electron-browser/mainThreadHeapSe
import
{
ExtHostDocuments
}
from
'
vs/workbench/api/node/extHostDocuments
'
;
import
{
ExtHostDocumentsAndEditors
}
from
'
vs/workbench/api/node/extHostDocumentsAndEditors
'
;
import
{
getDocumentSymbols
}
from
'
vs/editor/contrib/quickOpen/common/quickOpen
'
;
import
{
DocumentSymbolProviderRegistry
,
DocumentHighlightKind
,
MarkedString
Hover
}
from
'
vs/editor/common/modes
'
;
import
{
DocumentSymbolProviderRegistry
,
DocumentHighlightKind
,
Hover
}
from
'
vs/editor/common/modes
'
;
import
{
getCodeLensData
}
from
'
vs/editor/contrib/codelens/browser/codelens
'
;
import
{
getDefinitionsAtPosition
,
getImplementationsAtPosition
,
getTypeDefinitionsAtPosition
}
from
'
vs/editor/contrib/goToDeclaration/browser/goToDeclaration
'
;
import
{
getHover
}
from
'
vs/editor/contrib/hover/common/hover
'
;
...
...
@@ -440,7 +440,7 @@ suite('ExtHostLanguageFeatures', function () {
return
threadService
.
sync
().
then
(()
=>
{
return
getHover
(
model
,
new
EditorPosition
(
1
,
1
)).
then
(
value
=>
{
assert
.
equal
(
value
.
length
,
2
);
let
[
first
,
second
]
=
value
as
MarkedString
Hover
[];
let
[
first
,
second
]
=
value
as
Hover
[];
assert
.
equal
(
first
.
contents
[
0
],
'
registered second
'
);
assert
.
equal
(
second
.
contents
[
0
],
'
registered first
'
);
});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录