Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
b51c9f68
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,发现更多精彩内容 >>
未验证
提交
b51c9f68
编写于
4月 15, 2019
作者:
I
Ivan Basov
提交者:
GitHub
4月 15, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
disable completion for immediate window commands (#32631)
上级
357fa7e9
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
63 addition
and
23 deletion
+63
-23
src/EditorFeatures/Core/Implementation/IntelliSense/Completion/AsyncCompletionService.cs
...ntation/IntelliSense/Completion/AsyncCompletionService.cs
+10
-0
src/VisualStudio/Core/Def/Implementation/DebuggerIntelliSense/AbstractDebuggerIntelliSenseContext.cs
...buggerIntelliSense/AbstractDebuggerIntelliSenseContext.cs
+3
-10
src/VisualStudio/Core/Def/Implementation/DebuggerIntelliSense/DebuggerIntellisenseFilter.cs
...tation/DebuggerIntelliSense/DebuggerIntellisenseFilter.cs
+36
-8
src/VisualStudio/Core/Def/Implementation/LanguageService/AbstractLanguageService`2.IVsImmediateStatementCompletion2.cs
...ractLanguageService`2.IVsImmediateStatementCompletion2.cs
+14
-5
未找到文件。
src/EditorFeatures/Core/Implementation/IntelliSense/Completion/AsyncCompletionService.cs
浏览文件 @
b51c9f68
...
...
@@ -13,6 +13,7 @@
using
Microsoft.CodeAnalysis.Shared.TestHooks
;
using
Microsoft.CodeAnalysis.Shared.Utilities
;
using
Microsoft.CodeAnalysis.Text
;
using
Microsoft.VisualStudio.Editor
;
using
Microsoft.VisualStudio.Language.Intellisense
;
using
Microsoft.VisualStudio.Text
;
using
Microsoft.VisualStudio.Text.BraceCompletion
;
...
...
@@ -26,6 +27,7 @@ namespace Microsoft.CodeAnalysis.Editor.Implementation.IntelliSense.Completion
internal
class
AsyncCompletionService
:
ForegroundThreadAffinitizedObject
,
IAsyncCompletionService
{
private
readonly
IEditorOperationsFactoryService
_editorOperationsFactoryService
;
private
readonly
IFeatureServiceFactory
_featureServiceFactory
;
private
readonly
ITextUndoHistoryRegistry
_undoHistoryRegistry
;
private
readonly
IInlineRenameService
_inlineRenameService
;
private
readonly
IIntelliSensePresenter
<
ICompletionPresenterSession
,
ICompletionSession
>
_completionPresenter
;
...
...
@@ -45,6 +47,7 @@ internal class AsyncCompletionService : ForegroundThreadAffinitizedObject, IAsyn
public
AsyncCompletionService
(
IThreadingContext
threadingContext
,
IEditorOperationsFactoryService
editorOperationsFactoryService
,
IFeatureServiceFactory
featureServiceFactory
,
ITextUndoHistoryRegistry
undoHistoryRegistry
,
IInlineRenameService
inlineRenameService
,
IAsynchronousOperationListenerProvider
listenerProvider
,
...
...
@@ -53,6 +56,7 @@ internal class AsyncCompletionService : ForegroundThreadAffinitizedObject, IAsyn
:
base
(
threadingContext
)
{
_editorOperationsFactoryService
=
editorOperationsFactoryService
;
_featureServiceFactory
=
featureServiceFactory
;
_undoHistoryRegistry
=
undoHistoryRegistry
;
_inlineRenameService
=
inlineRenameService
;
_completionPresenter
=
ExtensionOrderer
.
Order
(
completionPresenters
).
Select
(
lazy
=>
lazy
.
Value
).
FirstOrDefault
();
...
...
@@ -72,6 +76,12 @@ public bool TryGetController(ITextView textView, ITextBuffer subjectBuffer, out
return
false
;
}
if
(!
_featureServiceFactory
.
GetOrCreate
(
textView
).
IsEnabled
(
PredefinedEditorFeatureNames
.
Completion
))
{
controller
=
null
;
return
false
;
}
var
autobraceCompletionCharSet
=
GetAllAutoBraceCompletionChars
(
subjectBuffer
.
ContentType
);
controller
=
Controller
.
GetInstance
(
ThreadingContext
,
...
...
src/VisualStudio/Core/Def/Implementation/DebuggerIntelliSense/AbstractDebuggerIntelliSenseContext.cs
浏览文件 @
b51c9f68
// 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
System
;
using
System.Collections.Generic
;
using
System.Collections.ObjectModel
;
using
System.Linq
;
using
System.Runtime.InteropServices
;
using
Microsoft.CodeAnalysis
;
using
Microsoft.CodeAnalysis.Editor
;
using
Microsoft.CodeAnalysis.Text
;
using
Microsoft.VisualStudio
;
using
Microsoft.VisualStudio.ComponentModelHost
;
using
Microsoft.VisualStudio.Editor
;
using
Microsoft.VisualStudio.Shell.Interop
;
using
Microsoft.VisualStudio.Text
;
using
Microsoft.VisualStudio.Text.Editor
;
using
Microsoft.VisualStudio.Text.Projection
;
using
Microsoft.VisualStudio.TextManager.Interop
;
using
Microsoft.VisualStudio.Utilities
;
using
TextSpan
=
Microsoft
.
VisualStudio
.
TextManager
.
Interop
.
TextSpan
;
namespace
Microsoft.VisualStudio.LanguageServices.Implementation.DebuggerIntelliSense
{
...
...
@@ -27,7 +20,7 @@ internal abstract class AbstractDebuggerIntelliSenseContext : IDisposable
private
readonly
IContentType
_contentType
;
private
readonly
IContentType
_originalContentType
;
protected
readonly
IProjectionBufferFactoryService
ProjectionBufferFactoryService
;
protected
readonly
Microsoft
.
VisualStudio
.
TextManager
.
Interop
.
TextSpan
CurrentStatementSpan
;
protected
readonly
TextManager
.
Interop
.
TextSpan
CurrentStatementSpan
;
private
readonly
IVsTextLines
_debuggerTextLines
;
private
IProjectionBuffer
_projectionBuffer
;
private
DebuggerTextView
_debuggerTextView
;
...
...
@@ -49,7 +42,7 @@ private class ImmediateWindowContext
IVsTextView
vsTextView
,
IVsTextLines
vsDebuggerTextLines
,
ITextBuffer
contextBuffer
,
Microsoft
.
VisualStudio
.
TextManager
.
Interop
.
TextSpan
[]
currentStatementSpan
,
TextManager
.
Interop
.
TextSpan
[]
currentStatementSpan
,
IComponentModel
componentModel
,
IServiceProvider
serviceProvider
,
IContentType
contentType
)
...
...
@@ -93,7 +86,7 @@ private class ImmediateWindowContext
protected
bool
InImmediateWindow
{
get
{
return
_immediateWindowContext
!=
null
;
}
}
protected
ITextBuffer
ContextBuffer
{
get
;
private
set
;
}
internal
ITextBuffer
ContextBuffer
{
get
;
private
set
;
}
public
abstract
bool
CompletionStartsOnQuestionMark
{
get
;
}
...
...
src/VisualStudio/Core/Def/Implementation/DebuggerIntelliSense/DebuggerIntellisenseFilter.cs
浏览文件 @
b51c9f68
...
...
@@ -5,6 +5,7 @@
using
System.Runtime.InteropServices
;
using
Microsoft.CodeAnalysis.Editor
;
using
Microsoft.CodeAnalysis.Editor.Shared.Extensions
;
using
Microsoft.CodeAnalysis.Text
;
using
Microsoft.VisualStudio.ComponentModelHost
;
using
Microsoft.VisualStudio.Editor
;
using
Microsoft.VisualStudio.LanguageServices.Implementation.LanguageService
;
...
...
@@ -17,26 +18,46 @@
namespace
Microsoft.VisualStudio.LanguageServices.Implementation.DebuggerIntelliSense
{
internal
class
DebuggerIntelliSenseFilter
<
TPackage
,
TLanguageService
>
:
AbstractVsTextViewFilter
<
TPackage
,
TLanguageService
>,
IDisposable
internal
class
DebuggerIntelliSenseFilter
<
TPackage
,
TLanguageService
>
:
AbstractVsTextViewFilter
<
TPackage
,
TLanguageService
>,
IDisposable
,
IFeatureController
where
TPackage
:
AbstractPackage
<
TPackage
,
TLanguageService
>
where
TLanguageService
:
AbstractLanguageService
<
TPackage
,
TLanguageService
>
{
private
readonly
ICommandHandlerServiceFactory
_commandFactory
;
private
readonly
I
WpfTextView
_wpfTextView
;
private
readonly
I
FeatureServiceFactory
_featureServiceFactory
;
private
AbstractDebuggerIntelliSenseContext
_context
;
private
IOleCommandTarget
_originalNextCommandFilter
;
internal
bool
Enabled
{
get
;
set
;
}
private
IFeatureDisableToken
_completionDisabledToken
;
public
DebuggerIntelliSenseFilter
(
AbstractLanguageService
<
TPackage
,
TLanguageService
>
languageService
,
IWpfTextView
wpfTextView
,
IVsEditorAdaptersFactoryService
adapterFactory
,
ICommandHandlerServiceFactory
commandFactory
)
ICommandHandlerServiceFactory
commandFactory
,
IFeatureServiceFactory
featureServiceFactory
)
:
base
(
languageService
,
wpfTextView
,
adapterFactory
,
commandFactory
)
{
_wpfTextView
=
wpfTextView
;
_commandFactory
=
commandFactory
;
_featureServiceFactory
=
featureServiceFactory
;
}
internal
void
EnableCompletion
()
{
if
(
_completionDisabledToken
==
null
)
{
return
;
}
_completionDisabledToken
.
Dispose
();
_completionDisabledToken
=
null
;
}
internal
void
DisableCompletion
()
{
var
featureService
=
_featureServiceFactory
.
GetOrCreate
(
WpfTextView
);
if
(
_completionDisabledToken
==
null
)
{
_completionDisabledToken
=
featureService
.
Disable
(
PredefinedEditorFeatureNames
.
Completion
,
this
);
}
}
internal
void
SetNextFilter
(
IOleCommandTarget
nextFilter
)
...
...
@@ -82,7 +103,7 @@ internal void SetCommandHandlers(ITextBuffer buffer)
// instead of trying to have our command handlers to work.
public
override
int
Exec
(
ref
Guid
pguidCmdGroup
,
uint
commandId
,
uint
executeInformation
,
IntPtr
pvaIn
,
IntPtr
pvaOut
)
{
if
(
_context
==
null
||
!
Enabled
)
if
(
_context
==
null
)
{
return
NextCommandTarget
.
Exec
(
pguidCmdGroup
,
commandId
,
executeInformation
,
pvaIn
,
pvaOut
);
}
...
...
@@ -187,6 +208,13 @@ internal void SetContentType(bool install)
=>
_context
?.
SetContentType
(
install
);
public
void
Dispose
()
=>
RemoveContext
();
{
if
(
_completionDisabledToken
!=
null
)
{
_completionDisabledToken
.
Dispose
();
}
RemoveContext
();
}
}
}
src/VisualStudio/Core/Def/Implementation/LanguageService/AbstractLanguageService`2.IVsImmediateStatementCompletion2.cs
浏览文件 @
b51c9f68
...
...
@@ -8,11 +8,10 @@
using
Microsoft.CodeAnalysis.ErrorReporting
;
using
Microsoft.VisualStudio.Editor
;
using
Microsoft.VisualStudio.LanguageServices.Implementation.DebuggerIntelliSense
;
using
Microsoft.VisualStudio.OLE.Interop
;
using
Microsoft.VisualStudio.Text
;
using
Microsoft.VisualStudio.Text.Editor
;
using
Microsoft.VisualStudio.TextManager.Interop
;
using
Roslyn
.Utilities
;
using
Microsoft.VisualStudio
.Utilities
;
namespace
Microsoft.VisualStudio.LanguageServices.Implementation.LanguageService
{
...
...
@@ -25,9 +24,18 @@ int IVsImmediateStatementCompletion2.EnableStatementCompletion(int enable, int s
{
if
(
filters
.
TryGetValue
(
textView
,
out
var
filter
))
{
filter
.
Enabled
=
enable
!=
0
;
if
(
enable
!=
0
)
{
filter
.
EnableCompletion
();
}
else
{
filter
.
DisableCompletion
();
}
}
// Debugger wants Roslyn to return OK in all cases,
// for example, even if Rolsyn tried to enable the one already enabled.
return
VSConstants
.
S_OK
;
}
...
...
@@ -45,7 +53,8 @@ int IVsImmediateStatementCompletion2.InstallStatementCompletion(int install, IVs
filter
=
new
DebuggerIntelliSenseFilter
<
TPackage
,
TLanguageService
>(
this
,
this
.
EditorAdaptersFactoryService
.
GetWpfTextView
(
textView
),
this
.
Package
.
ComponentModel
.
GetService
<
IVsEditorAdaptersFactoryService
>(),
this
.
Package
.
ComponentModel
.
GetService
<
ICommandHandlerServiceFactory
>());
this
.
Package
.
ComponentModel
.
GetService
<
ICommandHandlerServiceFactory
>(),
this
.
Package
.
ComponentModel
.
GetService
<
IFeatureServiceFactory
>());
this
.
filters
[
textView
]
=
filter
;
Marshal
.
ThrowExceptionForHR
(
textView
.
AddCommandFilter
(
filter
,
out
var
nextFilter
));
filter
.
SetNextFilter
(
nextFilter
);
...
...
@@ -66,7 +75,7 @@ int IVsImmediateStatementCompletion2.InstallStatementCompletion(int install, IVs
int
IVsImmediateStatementCompletion2
.
SetCompletionContext
(
string
filePath
,
IVsTextLines
buffer
,
Microsoft
.
VisualStudio
.
TextManager
.
Interop
.
TextSpan
[]
currentStatementSpan
,
TextSpan
[]
currentStatementSpan
,
object
punkContext
,
IVsTextView
textView
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录