-
Notifications
You must be signed in to change notification settings - Fork 177
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Progress converting SwiftAST to SwiftSyntax.
- Loading branch information
1 parent
fa40b84
commit 4bc1a57
Showing
50 changed files
with
1,379 additions
and
1,118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
121 changes: 121 additions & 0 deletions
121
src/swift/SwiftAPIViewCore/Sources/Models/Declarations/ActorModel.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
// -------------------------------------------------------------------------- | ||
// | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// | ||
// The MIT License (MIT) | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the ""Software""), to | ||
// deal in the Software without restriction, including without limitation the | ||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or | ||
// sell copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | ||
// IN THE SOFTWARE. | ||
// | ||
// -------------------------------------------------------------------------- | ||
|
||
import Foundation | ||
import SwiftSyntax | ||
|
||
|
||
/// Grammar Summary: | ||
/// actor-declaration → attributes opt access-level-modifier opt actor actor-name generic-parameter-clause opt type-inheritance-clause opt generic-where-clause opt actor-body | ||
/// actor-name → identifier | ||
/// actor-body → { actor-members opt } | ||
/// actor-members → actor-member actor-members opt | ||
/// actor-member → declaration | compiler-control-statement | ||
class ActorModel: Tokenizable {//, Linkable, Commentable, Extensible, AccessLevelProtocol { | ||
// FIXME: Restore | ||
// var definitionId: String? | ||
// var lineId: String? | ||
// var parent: Linkable? | ||
// var attributes: AttributesModel | ||
// var accessLevel: AccessLevelModifier | ||
// var isFinal: Bool | ||
// var name: String | ||
// var genericParamClause: GenericParameterModel? | ||
// var typeInheritanceClause: TypeInheritanceModel? | ||
// var genericWhereClause: GenericWhereModel? | ||
// var members: [Tokenizable] | ||
// var extensions: [ExtensionModel] | ||
|
||
init(from decl: ActorDeclSyntax) {//, parent: Linkable) { | ||
// FIXME: Restore | ||
// self.parent = parent | ||
// let name = decl.name.textDescription | ||
// definitionId = identifier(forName: name, withPrefix: parent.definitionId) | ||
// lineId = nil | ||
// attributes = AttributesModel(from: decl.attributes) | ||
// accessLevel = decl.accessLevel ?? .internal | ||
// self.name = name | ||
// isFinal = decl.isFinal | ||
// genericParamClause = GenericParameterModel(from: decl.genericParameterClause) | ||
// typeInheritanceClause = TypeInheritanceModel(from: decl.typeInheritanceClause) | ||
// genericWhereClause = GenericWhereModel(from: decl.genericWhereClause) | ||
// extensions = [ExtensionModel]() | ||
// members = [Tokenizable]() | ||
// decl.members.forEach { member in | ||
// switch member { | ||
// case let .declaration(decl): | ||
// if let model = decl.toTokenizable(withParent: self) { | ||
// if let model = model as? ExtensionModel { | ||
// // TODO: Place the extension in the appropriate location | ||
// extensions.append(model) | ||
// } else { | ||
// members.append(model) | ||
// } | ||
// } | ||
// case let .compilerControl(statement): | ||
// SharedLogger.warn("Unsupported compiler control statement: \(statement)") | ||
// } | ||
// } | ||
} | ||
|
||
func tokenize(apiview a: APIViewModel) { | ||
// FIXME: Restore | ||
// guard APIViewModel.publicModifiers.contains(accessLevel) else { return } | ||
// attributes.tokenize(apiview: a) | ||
// a.keyword(accessLevel.textDescription, postfixSpace: true) | ||
// if isFinal { | ||
// a.keyword("final", postfixSpace: true) | ||
// } | ||
// a.keyword("class", postfixSpace: true) | ||
// a.typeDeclaration(name: name, definitionId: definitionId) | ||
// genericParamClause?.tokenize(apiview: a) | ||
// typeInheritanceClause?.tokenize(apiview: a) | ||
// genericWhereClause?.tokenize(apiview: a) | ||
// a.punctuation("{", prefixSpace: true) | ||
// a.newline() | ||
// a.indent { | ||
// members.forEach { member in | ||
// member.tokenize(apiview: a) | ||
// } | ||
// extensions.forEach { ext in | ||
// ext.tokenize(apiview: a) | ||
// } | ||
// } | ||
// a.punctuation("}") | ||
// a.newline() | ||
// a.blankLines(set: 1) | ||
} | ||
|
||
func navigationTokenize(apiview a: APIViewModel) { | ||
// FIXME: Restore | ||
// guard APIViewModel.publicModifiers.contains(accessLevel) else { return } | ||
// a.add(token: NavigationToken(name: name, prefix: parent?.name, typeKind: .class)) | ||
// for member in members { | ||
// guard let member = member as? Linkable else { continue } | ||
// member.navigationTokenize(apiview: a) | ||
// } | ||
} | ||
} |
Oops, something went wrong.