-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Basic handling of function pointer types in the IDE #44564
Changes from 1 commit
d1971b8
c703569
3d643fa
4d82657
9052e85
cba43db
3ca29da
deeb912
0150ae2
ee20709
d6b45ee
d57ff24
ed7c4ae
dd47d72
6f706da
5d4b41b
e8194c5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1693,7 +1693,9 @@ public static NameSyntax ParseName(string text, int offset = 0, bool consumeFull | |
/// <summary> | ||
/// Parse a TypeNameSyntax node using the grammar rule for type names. | ||
/// </summary> | ||
public static TypeSyntax ParseTypeName(string text, int offset = 0, bool consumeFullText = true) | ||
// Backcompat overload, do not remove | ||
[EditorBrowsable(EditorBrowsableState.Never)] | ||
public static TypeSyntax ParseTypeName(string text, int offset, bool consumeFullText) | ||
CyrusNajmabadi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
using (var lexer = MakeLexer(text, offset)) | ||
using (var parser = MakeParser(lexer)) | ||
|
@@ -1704,6 +1706,20 @@ public static TypeSyntax ParseTypeName(string text, int offset = 0, bool consume | |
} | ||
} | ||
|
||
/// <summary> | ||
/// Parse a TypeNameSyntax node using the grammar rule for type names. | ||
/// </summary> | ||
public static TypeSyntax ParseTypeName(string text, int offset = 0, ParseOptions? options = null, bool consumeFullText = true) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Why is this needed? #Closed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Should this be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We seem to be inconsistent as to whether we take a ParseOptions or a CSharpParseOptions, but given that this (and the rest where we take a In reply to: 432679991 [](ancestors = 432679991) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Please add targeted compiler test for this API #Closed |
||
{ | ||
using (var lexer = MakeLexer(text, offset, (CSharpParseOptions?)options)) | ||
using (var parser = MakeParser(lexer)) | ||
{ | ||
var node = parser.ParseTypeName(); | ||
if (consumeFullText) node = parser.ConsumeUnexpectedTokens(node); | ||
return (TypeSyntax)node.CreateRed(); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Parse an ExpressionSyntax node using the lowest precedence grammar rule for expressions. | ||
/// </summary> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
|
||
Shared Microsoft.CodeAnalysis.VisualBasic.SyntaxFactory.ParseTypeName(text As String, offset As Integer = 0, options As Microsoft.CodeAnalysis.ParseOptions = Nothing, consumeFullText As Boolean = True) -> Microsoft.CodeAnalysis.VisualBasic.Syntax.TypeSyntax | ||
Shared Microsoft.CodeAnalysis.VisualBasic.SyntaxFactory.ParseTypeName(text As String, offset As Integer, consumeFullText As Boolean) -> Microsoft.CodeAnalysis.VisualBasic.Syntax.TypeSyntax | ||
*REMOVED*Shared Microsoft.CodeAnalysis.VisualBasic.SyntaxFactory.ParseTypeName(text As String, offset As Integer = 0, consumeFullText As Boolean = True) -> Microsoft.CodeAnalysis.VisualBasic.Syntax.TypeSyntax |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ Imports Microsoft.CodeAnalysis.VisualBasic.SyntaxFacts | |
Imports InternalSyntax = Microsoft.CodeAnalysis.VisualBasic.Syntax.InternalSyntax | ||
Imports Microsoft.CodeAnalysis.Syntax | ||
Imports System.Collections.Immutable | ||
Imports System.ComponentModel | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this needed? #Closed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
Namespace Microsoft.CodeAnalysis.VisualBasic | ||
|
||
|
@@ -191,7 +192,22 @@ Namespace Microsoft.CodeAnalysis.VisualBasic | |
''' </summary> | ||
''' <param name="text">The input string</param> | ||
''' <param name="offset">The starting offset in the string</param> | ||
Public Shared Function ParseTypeName(text As String, Optional offset As Integer = 0, Optional consumeFullText As Boolean = True) As TypeSyntax | ||
Public Shared Function ParseTypeName(text As String, Optional offset As Integer = 0, Optional options As ParseOptions = Nothing, Optional consumeFullText As Boolean = True) As TypeSyntax | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Should this be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Please add targeted compiler test for this API #Closed |
||
Using p = New InternalSyntax.Parser(MakeSourceText(text, offset), If(DirectCast(options, VisualBasicParseOptions), VisualBasicParseOptions.Default)) | ||
p.GetNextToken() | ||
Dim node = p.ParseGeneralType() | ||
Return DirectCast(If(consumeFullText, p.ConsumeUnexpectedTokens(node), node).CreateRed(Nothing, 0), TypeSyntax) | ||
End Using | ||
End Function | ||
|
||
'' Backcompat overload, do not touch | ||
''' <summary> | ||
''' Parse a type name. | ||
''' </summary> | ||
''' <param name="text">The input string</param> | ||
''' <param name="offset">The starting offset in the string</param> | ||
<EditorBrowsable(EditorBrowsableState.Never)> | ||
Public Shared Function ParseTypeName(text As String, offset As Integer, consumeFullText As Boolean) As TypeSyntax | ||
Using p = New InternalSyntax.Parser(MakeSourceText(text, offset), VisualBasicParseOptions.Default) | ||
p.GetNextToken() | ||
Dim node = p.ParseGeneralType() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we keep this API? #Closed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or is the only change that we removed default values for parameters?
In reply to: 432672190 [](ancestors = 432672190)