Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
0e2b7637
R
roslyn
项目概览
lwm1986
/
roslyn
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
roslyn
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
0e2b7637
编写于
12月 10, 2019
作者:
I
Ivan Basov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more business logic
上级
c3b3e1f3
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
71 addition
and
56 deletion
+71
-56
src/VisualStudio/Core/Def/Implementation/ChangeSignature/AddParameterDialog.xaml
...ef/Implementation/ChangeSignature/AddParameterDialog.xaml
+3
-3
src/VisualStudio/Core/Def/Implementation/ChangeSignature/AddParameterDialog.xaml.cs
...Implementation/ChangeSignature/AddParameterDialog.xaml.cs
+30
-13
src/VisualStudio/Core/Def/Implementation/ChangeSignature/AddParameterTextViewModelProvider.cs
...tion/ChangeSignature/AddParameterTextViewModelProvider.cs
+5
-5
src/VisualStudio/Core/Def/Implementation/ChangeSignature/ChangeSignatureWorkspace.cs
...mplementation/ChangeSignature/ChangeSignatureWorkspace.cs
+2
-1
src/VisualStudio/Core/Def/Implementation/ChangeSignature/VisualStudioChangeSignatureOptionsService.cs
...ngeSignature/VisualStudioChangeSignatureOptionsService.cs
+4
-4
src/VisualStudio/Core/Def/Implementation/Utilities/IntellisenseTextBox.cs
.../Core/Def/Implementation/Utilities/IntellisenseTextBox.cs
+9
-30
src/VisualStudio/Core/Def/Implementation/Utilities/IntellisenseTextBoxViewModel.cs
.../Implementation/Utilities/IntellisenseTextBoxViewModel.cs
+18
-0
未找到文件。
src/VisualStudio/Core/Def/Implementation/ChangeSignature/AddParameterDialog.xaml
浏览文件 @
0e2b7637
...
...
@@ -42,15 +42,15 @@
<Label Grid.Row="0" Grid.Column="0" Content="{Binding ElementName=dialog, Path=TypeNameLabel}" />
<Border Grid.Row="0" Grid.Column="1" BorderThickness="1" Margin="6,0,0,0"> <ContentControl x:Name="TypeNameContentControl" Focusable="True" PreviewKeyDown="TypeNameContentControl_PreviewKeyDown" Margin="100,0,100,15" BorderBrush="{DynamicResource {x:Static SystemColors.InactiveBorderBrushKey}}" /> </Border>
<Label Grid.Row="1" Grid.Column="0" Content="{Binding ElementName=dialog, Path=ParameterNameLabel}" />
<TextBox Grid.Row="1" Grid.Column="1" Width="200" Text="{Binding ParameterName
}" Margin="100,0,100,15
" />
<TextBox Grid.Row="1" Grid.Column="1" Width="200" Text="{Binding ParameterName
, Mode=TwoWay}" Margin="100,0,100,15" TextChanged="TextBox_ParameterNameChanged
" />
<Label Grid.Row="2" Grid.Column="0" Content="{Binding ElementName=dialog, Path=CallsiteValueLabel}" />
<TextBox Grid.Row="2" Grid.Column="1" Width="200" Text="{Binding CallsiteValue}" Margin="100,0,100,15" />
<TextBox Grid.Row="2" Grid.Column="1" Width="200" Text="{Binding CallsiteValue
, Mode=TwoWay
}" Margin="100,0,100,15" />
</Grid>
<StackPanel Grid.Row="1"
HorizontalAlignment="Right"
Margin="0, 11, 0, 0"
Orientation="Horizontal" Width="153">
<vs:DialogButton x:Uid="OKButton"
<vs:DialogButton x:Uid="OKButton"
x:Name="OKButton"
Content="{Binding ElementName=dialog, Path=OK}"
Margin="0, 0, 0, 0"
Padding="{StaticResource ResourceKey=okCancelButtonPadding}"
...
...
src/VisualStudio/Core/Def/Implementation/ChangeSignature/AddParameterDialog.xaml.cs
浏览文件 @
0e2b7637
...
...
@@ -14,9 +14,18 @@ namespace Microsoft.VisualStudio.LanguageServices.Implementation.ChangeSignature
internal
partial
class
AddParameterDialog
:
DialogWindow
{
public
readonly
AddParameterDialogViewModel
ViewModel
;
private
readonly
IVsTextLines
_vsTextLines
;
private
readonly
IVsTextView
_textView
;
private
readonly
IWpfTextView
_wpfTextView
;
private
readonly
IntellisenseTextBoxViewModel
_intellisenseTextBoxView
;
private
bool
_isValid
;
private
bool
IsValid
{
get
{
return
_isValid
;
}
set
{
this
.
OKButton
.
IsEnabled
=
value
;
_isValid
=
value
;
}
}
public
string
OK
{
get
{
return
ServicesVSResources
.
OK
;
}
}
public
string
Cancel
{
get
{
return
ServicesVSResources
.
Cancel
;
}
}
...
...
@@ -29,16 +38,16 @@ internal partial class AddParameterDialog : DialogWindow
public
string
AddParameterDialogTitle
{
get
{
return
ServicesVSResources
.
Add_Parameter
;
}
}
public
AddParameterDialog
(
IVsTextLines
vsTextLines
,
IVsTextView
vsTextView
,
IWpfTextView
wpfTextView
)
public
AddParameterDialog
(
IntellisenseTextBoxViewModel
intellisenseTextBoxViewModel
)
{
// TODO this should be initlialized when called for Edit.
ViewModel
=
new
AddParameterDialogViewModel
();
_vsTextLines
=
vsTextLines
;
_textView
=
vsTextView
;
_wpfTextView
=
wpfTextView
;
_intellisenseTextBoxView
=
intellisenseTextBoxViewModel
;
this
.
Loaded
+=
AddParameterDialog_Loaded
;
DataContext
=
ViewModel
;
// This is for Add. For edit, it should be true by default.
IsValid
=
false
;
InitializeComponent
();
}
...
...
@@ -46,7 +55,7 @@ internal partial class AddParameterDialog : DialogWindow
private
void
AddParameterDialog_Loaded
(
object
sender
,
RoutedEventArgs
e
)
{
IntellisenseTextBox
typeNameTextBox
=
new
IntellisenseTextBox
(
_
vsTextLines
,
_textView
,
_wpfText
View
,
TypeNameContentControl
);
_
intellisenseTextBox
View
,
TypeNameContentControl
);
this
.
TypeNameContentControl
.
Content
=
typeNameTextBox
;
}
...
...
@@ -54,7 +63,6 @@ private void OK_Click(object sender, RoutedEventArgs e)
{
if
(
ViewModel
.
TrySubmit
())
{
// TODO maybe we should try binding.
ViewModel
.
TypeName
=
((
IntellisenseTextBox
)
TypeNameContentControl
.
Content
).
Text
;
DialogResult
=
true
;
}
...
...
@@ -83,7 +91,6 @@ private void TypeNameContentControl_PreviewKeyDown(object sender, KeyEventArgs e
{
// Do nothing. This case is handled in parent control KeyDown events.
}
else
if
(
e
.
Key
==
Key
.
Tab
&&
!
typeNameTextBox
.
HasActiveIntellisenseSession
)
{
// Do nothing. This case is handled in parent control KeyDown events.
...
...
@@ -96,5 +103,15 @@ private void TypeNameContentControl_PreviewKeyDown(object sender, KeyEventArgs e
}
}
}
private
void
TextBox_ParameterNameChanged
(
object
sender
,
System
.
Windows
.
Controls
.
TextChangedEventArgs
e
)
{
// check for empty
// check for starting with non-letter
// check for special symbols
// check for matching other parameter names
// if not valid and _isValid, then _isValid = false;
// if valid and !_isValid, then validate all controls
}
}
}
src/VisualStudio/Core/Def/Implementation/ChangeSignature/AddParameterTextViewModelProvider.cs
浏览文件 @
0e2b7637
...
...
@@ -27,11 +27,11 @@ public ITextViewModel CreateTextViewModel(ITextDataModel dataModel, ITextViewRol
var
span
=
projectionSnapshot
.
GetSourceSpans
()[
1
];
var
mappedSpans
=
projectionSnapshot
.
MapFromSourceSnapshot
(
span
);
var
elisionBuffer
=
ProjectionBufferFactoryService
.
CreateElisionBuffer
(
/*resolver=*/
null
,
new
NormalizedSnapshotSpanCollection
(
new
[]{
new
SnapshotSpan
(
dataModel
.
DocumentBuffer
.
CurrentSnapshot
,
mappedSpans
[
0
])
}),
ElisionBufferOptions
.
None
);
ProjectionBufferFactoryService
.
CreateElisionBuffer
(
projectionEditResolver
:
null
,
exposedSpans
:
new
NormalizedSnapshotSpanCollection
(
new
[]
{
new
SnapshotSpan
(
dataModel
.
DocumentBuffer
.
CurrentSnapshot
,
mappedSpans
[
0
])
}),
options
:
ElisionBufferOptions
.
None
);
return
new
ElisionBufferTextViewModel
(
dataModel
,
elisionBuffer
);
}
...
...
src/VisualStudio/Core/Def/Implementation/ChangeSignature/ChangeSignatureWorkspace.cs
浏览文件 @
0e2b7637
...
...
@@ -24,7 +24,8 @@ public ChangeSignatureWorkspace(Solution solution, Project project)
Options
=
Options
.
WithChangedOption
(
EditorCompletionOptions
.
UseSuggestionMode
,
true
);
}
private
string
GetDocumentText
()
// TODO do we need to keep this?
private
static
string
GetDocumentText
()
{
return
$@"
{{
...
...
src/VisualStudio/Core/Def/Implementation/ChangeSignature/VisualStudioChangeSignatureOptionsService.cs
浏览文件 @
0e2b7637
...
...
@@ -170,14 +170,14 @@ public AddedParameterResult GetAddedParameter(Document document, int insertPosit
// Start getting the compilation so the PartialSolution will be ready when the user starts typing in the window
await
document
.
Project
.
GetCompilationAsync
(
cancellationToken
).
ConfigureAwait
(
false
);
var
roleSet
=
_textEditorFactoryService
.
CreateTextViewRoleSet
(
ITextViewRoleSet
roleSet
=
_textEditorFactoryService
.
CreateTextViewRoleSet
(
PredefinedTextViewRoles
.
Editable
,
PredefinedTextViewRoles
.
Interactive
,
AddParameterTextViewRole
);
var
vsTextView
=
_editorAdaptersFactoryService
.
CreateVsTextViewAdapter
(
_serviceProvider
,
roleSet
);
IVsTextView
vsTextView
=
_editorAdaptersFactoryService
.
CreateVsTextViewAdapter
(
_serviceProvider
,
roleSet
);
var
initView
=
new
[]
{
INITVIEW
[]
initView
=
new
[]
{
new
INITVIEW
()
{
fSelectionMargin
=
0
,
...
...
@@ -198,7 +198,7 @@ public AddedParameterResult GetAddedParameter(Document document, int insertPosit
IWpfTextView
wpfTextView
=
_editorAdaptersFactoryService
.
GetWpfTextView
(
vsTextView
);
wpfTextView
.
TextBuffer
.
ChangeContentType
(
_contentType
,
null
);
return
new
AddParameterDialog
(
vsTextLines
,
vsTextView
,
wpfTextView
);
return
new
AddParameterDialog
(
new
IntellisenseTextBoxViewModel
(
vsTextView
,
wpfTextView
)
);
}
}
}
src/VisualStudio/Core/Def/Implementation/Utilities/IntellisenseTextBox.cs
浏览文件 @
0e2b7637
...
...
@@ -27,11 +27,6 @@ namespace Microsoft.VisualStudio.LanguageServices.Implementation
/// </summary>
internal
class
IntellisenseTextBox
:
FrameworkElement
,
IOleCommandTarget
{
/// <summary>
/// Contains the text in the buffer
/// </summary>
private
readonly
IVsTextLines
_vsTextLines
;
/// <summary>
/// IWpfTextView container
/// </summary>
...
...
@@ -55,11 +50,9 @@ internal class IntellisenseTextBox : FrameworkElement, IOleCommandTarget
/// <summary>
/// Initializes a new instance of the <see cref="IntellisenseTextBox"/> class.
/// </summary>
public
IntellisenseTextBox
(
IVsTextLines
vsTextLines
,
IVsTextView
vsTextView
,
IWpfTextView
wpfTextView
,
ContentControl
container
)
public
IntellisenseTextBox
(
IntellisenseTextBoxViewModel
viewModel
,
ContentControl
container
)
{
this
.
_vsTextLines
=
vsTextLines
;
this
.
InitializeEditorControl
(
vsTextView
,
wpfTextView
,
container
);
this
.
InitializeEditorControl
(
viewModel
,
container
);
}
/// <summary>
...
...
@@ -91,15 +84,7 @@ public bool HasActiveIntellisenseSession
/// </summary>
public
string
Text
{
get
{
int
length
;
string
text
;
// TODO why 0?
this
.
_vsTextLines
.
GetLengthOfLine
(
0
,
out
length
);
this
.
_vsTextLines
.
GetLineText
(
0
,
0
,
0
,
length
,
out
text
);
return
text
;
}
get
=>
this
.
_textViewHost
.
TextView
.
TextSnapshot
.
GetText
();
}
///// <summary>
...
...
@@ -107,10 +92,7 @@ public string Text
///// </summary>
protected
override
int
VisualChildrenCount
{
get
{
return
1
;
}
get
=>
1
;
}
/// <summary>
...
...
@@ -275,15 +257,12 @@ protected override void OnGotFocus(RoutedEventArgs e)
/// <summary>
/// Initializes the editor control
/// </summary>
private
void
InitializeEditorControl
(
I
VsTextView
vsTextView
,
IWpfTextView
wpfTextView
,
ContentControl
container
)
private
void
InitializeEditorControl
(
I
ntellisenseTextBoxViewModel
viewModel
,
ContentControl
container
)
{
IComponentModel
componentModel
=
(
IComponentModel
)
Package
.
GetGlobalService
(
typeof
(
SComponentModel
));
// TODO Set text buffer initial contents
// ErrorHandler.ThrowOnFailure(vsTextBuffer.InitializeContent(initialContent, initialContent != null ? initialContent.Length : 0));
// Sets editor options that control its final look
IEditorOptions
editorOptions
=
w
pfTextView
.
Properties
.
GetProperty
(
typeof
(
IEditorOptions
))
as
IEditorOptions
;
IEditorOptions
editorOptions
=
viewModel
.
W
pfTextView
.
Properties
.
GetProperty
(
typeof
(
IEditorOptions
))
as
IEditorOptions
;
editorOptions
.
SetOptionValue
(
"TextViewHost/ZoomControl"
,
false
);
editorOptions
.
SetOptionValue
(
DefaultWpfViewOptions
.
AppearanceCategory
,
appearanceCategory
);
...
...
@@ -301,14 +280,14 @@ private void InitializeEditorControl(IVsTextView vsTextView, IWpfTextView wpfTex
IEditorOperationsFactoryService
editorOperationsFactoryService
=
componentModel
.
GetService
<
IEditorOperationsFactoryService
>();
if
(
editorOperationsFactoryService
!=
null
)
{
this
.
_editorOperations
=
editorOperationsFactoryService
.
GetEditorOperations
(
w
pfTextView
);
this
.
_editorOperations
=
editorOperationsFactoryService
.
GetEditorOperations
(
viewModel
.
W
pfTextView
);
}
ErrorHandler
.
ThrowOnFailure
(
vsTextView
.
AddCommandFilter
(
this
,
out
this
.
_nextCommandTarget
));
ErrorHandler
.
ThrowOnFailure
(
v
iewModel
.
V
sTextView
.
AddCommandFilter
(
this
,
out
this
.
_nextCommandTarget
));
// Get the host control to render the view
IVsEditorAdaptersFactoryService
editorAdapterFactory
=
componentModel
.
GetService
<
IVsEditorAdaptersFactoryService
>();
this
.
_textViewHost
=
editorAdapterFactory
.
GetWpfTextViewHost
(
vsTextView
);
this
.
_textViewHost
=
editorAdapterFactory
.
GetWpfTextViewHost
(
v
iewModel
.
V
sTextView
);
// For non-blurry text
TextOptions
.
SetTextFormattingMode
(
this
.
_textViewHost
.
HostControl
,
TextFormattingMode
.
Display
);
...
...
src/VisualStudio/Core/Def/Implementation/Utilities/IntellisenseTextBoxViewModel.cs
0 → 100644
浏览文件 @
0e2b7637
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using
Microsoft.VisualStudio.Text.Editor
;
using
Microsoft.VisualStudio.TextManager.Interop
;
namespace
Microsoft.VisualStudio.LanguageServices.Implementation
{
internal
readonly
struct
IntellisenseTextBoxViewModel
{
public
readonly
IVsTextView
VsTextView
;
public
readonly
IWpfTextView
WpfTextView
;
public
IntellisenseTextBoxViewModel
(
IVsTextView
vsTextView
,
IWpfTextView
wpfTextView
)
{
VsTextView
=
vsTextView
;
WpfTextView
=
wpfTextView
;
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录