-
Notifications
You must be signed in to change notification settings - Fork 440
[SwiftLexicalLookup] Add ASTScope related fixes and lookInMembers result kind. #2852
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
Changes from 5 commits
d83af9c
7521e4e
fae4d0e
3de7208
433f14b
0f9b2bc
baf6a2f
fc1ab88
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 |
---|---|---|
|
@@ -12,14 +12,11 @@ | |
|
||
import SwiftSyntax | ||
|
||
@_spi(Experimental) public protocol TypeScopeSyntax: ScopeSyntax, DeclSyntaxProtocol {} | ||
|
||
extension TypeScopeSyntax { | ||
@_spi(Experimental) public var implicitInstanceAndTypeNames: [LookupName] { | ||
[.implicit(.self(self)), .implicit(.Self(self))] | ||
} | ||
|
||
@_spi(Experimental) public var introducedNames: [LookupName] { | ||
implicitInstanceAndTypeNames | ||
} | ||
protocol CanInterleaveResultsLaterScopeSyntax: ScopeSyntax { | ||
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. Could you add a comment explaining what it means to interleave results later? 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. Thanks for pointing this out! I added documentation comments to the definition of |
||
func lookupWithInterleavedResults( | ||
_ identifier: Identifier?, | ||
at lookUpPosition: AbsolutePosition, | ||
with config: LookupConfig, | ||
resultsToInterleave: [LookupResult] | ||
) -> [LookupResult] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This source file is part of the Swift.org open source project | ||
// | ||
// Copyright (c) 2014 - 2024 Apple Inc. and the Swift project authors | ||
// Licensed under Apache License v2.0 with Runtime Library Exception | ||
// | ||
// See https://swift.org/LICENSE.txt for license information | ||
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
import SwiftSyntax | ||
|
||
protocol FunctionScopeSyntax: DeclSyntaxProtocol, WithGenericParametersScopeSyntax { | ||
var signature: FunctionSignatureSyntax { get } | ||
} | ||
|
||
extension FunctionScopeSyntax { | ||
/// Function parameters introduced by this function's signature. | ||
@_spi(Experimental) public var introducedNames: [LookupName] { | ||
signature.parameterClause.parameters.flatMap { parameter in | ||
LookupName.getNames(from: parameter) | ||
} + (parentScope?.is(MemberBlockSyntax.self) ?? false ? [.implicit(.self(self))] : []) | ||
} | ||
|
||
/// Lookup results from this function scope. | ||
/// Routes to generic parameter clause scope if exists. | ||
@_spi(Experimental) public func lookup( | ||
_ identifier: Identifier?, | ||
at lookUpPosition: AbsolutePosition, | ||
with config: LookupConfig | ||
) -> [LookupResult] { | ||
var thisScopeResults: [LookupResult] = [] | ||
|
||
if !signature.range.contains(lookUpPosition) { | ||
thisScopeResults = defaultLookupImplementation( | ||
identifier, | ||
at: position, | ||
with: config, | ||
propagateToParent: false | ||
) | ||
} | ||
|
||
return thisScopeResults | ||
+ lookupThroughGenericParameterScope( | ||
identifier, | ||
at: lookUpPosition, | ||
with: config | ||
) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This source file is part of the Swift.org open source project | ||
// | ||
// Copyright (c) 2014 - 2024 Apple Inc. and the Swift project authors | ||
// Licensed under Apache License v2.0 with Runtime Library Exception | ||
// | ||
// See https://swift.org/LICENSE.txt for license information | ||
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
import SwiftSyntax | ||
|
||
@_spi(Experimental) public protocol LookInMembersScopeSyntax: ScopeSyntax { | ||
/// Position used for member lookup. | ||
var lookupMembersPosition: AbsolutePosition { get } | ||
} |
Uh oh!
There was an error while loading. Please reload this page.