soft-select select camelcase matched item if user might be typing an …#80809
soft-select select camelcase matched item if user might be typing an …#80809genlu merged 4 commits intodotnet:mainfrom
Conversation
…undefined type parameter
| if (string.IsNullOrEmpty(text)) | ||
| return false; | ||
|
|
||
| // Pattern: starts with 'T', and optionally followed by an uppercase letter |
There was a problem hiding this comment.
perhaps mention this is just a weak heuristic. But it helps given general .Net naming patterns.
|
|
||
| spanStart = WalkOutOfGenericType(syntaxTree, spanStart, semanticModel, cancellationToken); | ||
| spanStart = WalkOutOfTupleType(syntaxTree, spanStart, cancellationToken); | ||
| spanStart = WalkOutOfRefType(syntaxTree, spanStart, cancellationToken); |
There was a problem hiding this comment.
if you make these helpers into local functions, you can just rewrite this as:
spanStart = WalkOutOfGeneric(WalkOutOfTuple(WalkOutOfRef(spanStart)))
| } | ||
| } | ||
|
|
||
| public static bool IsSpeculativeTypeParameterContext(SyntaxTree syntaxTree, int position, SemanticModel? semanticModel, bool inMemberDeclarationOnly, CancellationToken cancellationToken) |
There was a problem hiding this comment.
can you put a doc comment on what a 'Speculative type parameter context' is? at first i thought this was about SpecultiveSemanticModels :)
| syntaxTree.IsGlobalMemberDeclarationContext(spanStart, SyntaxKindSet.AllGlobalMemberModifiers, cancellationToken) || | ||
| (!inMemberDeclarationOnly && (syntaxTree.IsStatementContext(spanStart, token, cancellationToken) || | ||
| syntaxTree.IsGlobalStatementContext(spanStart, cancellationToken) || | ||
| syntaxTree.IsDelegateReturnTypeContext(spanStart, token))); |
There was a problem hiding this comment.
consider breaking these into individual statements.
There was a problem hiding this comment.
with examples for each.
There was a problem hiding this comment.
i'm finding the !inMemberDeclarationOnly portion of this hard to read/rerason out. please break out and doc.
| } | ||
|
|
||
| return position; | ||
| return CompletionUtilities.IsSpeculativeTypeParameterContext(syntaxTree, position, context.SemanticModel, inMemberDeclarationOnly: false, cancellationToken); |
There was a problem hiding this comment.
why the 'false' for 'inMemberDeclarationOnly'
There was a problem hiding this comment.
I think it is less likely that someone is trying to type an undeclared type parameter when they are inside method body. It is fine to provide a speculative T item there, since typing 2 characters would filter it out, but for selection, I'd want TypeBuilder to be hard selected here
public Foo()
{
TB%%
}|
|
||
| internal override async Task<bool> IsSpeculativeTypeParameterContextAsync(Document document, int position, CancellationToken cancellationToken) | ||
| { | ||
| var syntaxTree = await document.GetRequiredSyntaxTreeAsync(cancellationToken).ConfigureAwait(false); |
There was a problem hiding this comment.
doc why 'true' for inMemberDeclarationOnly
| internal override async Task<bool> IsSpeculativeTypeParameterContextAsync(Document document, int position, CancellationToken cancellationToken) | ||
| { | ||
| var syntaxTree = await document.GetRequiredSyntaxTreeAsync(cancellationToken).ConfigureAwait(false); | ||
| return CompletionUtilities.IsSpeculativeTypeParameterContext(syntaxTree, position, semanticModel: null, inMemberDeclarationOnly: true, cancellationToken); |
There was a problem hiding this comment.
nit: getting a semantic model is cheap. just get the semantic model here, and pass that into the helper. the helper doesn't need to take the syntaxTree then.
There was a problem hiding this comment.
Discussed offline, keeping it as is because we'd need a frozen partial doc otherwise
|
overall i'm totally fine with this. a nd i recognize you're moving existing code. but some parts are a bit confusing. so i'd love some docs/refinement. |
Co-authored-by: Cyrus Najmabadi <[email protected]>
* upstream/main: (123 commits) Fix SafeContext of Span-valued collection expressions to match specification (dotnet#80684) Improve detection of invalid references for implicitly typed expression variables declared within implicit object creation expressions. (dotnet#80546) Add test demonstrating behavior of ToMinimalDisplayString. (dotnet#80757) Only set DOTNET_HOST_PATH if something was installed (dotnet#80842) Clean up a Razor external access service (dotnet#80830) Remove unused statement (dotnet#80823) Allow foreach on typed null enumerables (dotnet#80783) Update documentation for DeclaringSyntaxReferences and Locations to clarify partial members behavior (dotnet#80704) Fix issue converting an auto prop to a full prop when 'field' and 'initializers' are involved Rename childIsSimple to innerExpressionHasPrimaryPrecedence and add more test cases Remove placeholder WorkItem attributes from new tests Fix RemoveUnnecessaryParentheses to detect simple expressions in bitwise operations [main] Update dependencies from dotnet/arcade (dotnet#80828) Fix ITypeSymbol.BaseType documentation for type parameters (dotnet#80770) soft-select select camelcase matched item if user might be typing an undefined type parameter (dotnet#80809) Allow semantic tokens in Razor to be better behaved (dotnet#80815) Rebase Remove using Update test Add fix all test ...
…undefined type parameter
Fix #75651