swiftdocorg / swiftsemantics Goto Github PK
View Code? Open in Web Editor NEWUses SwiftSyntax to parse Swift code into its constituent declarations
License: MIT License
Uses SwiftSyntax to parse Swift code into its constituent declarations
License: MIT License
I found typeAnnotation
is nil when a variable is declared with type inference
func makeSession() -> Session
class MediaPlayer {
let session = makeSession()
}
result:
name: session, typeAnnotation: nil
expected result
name: session, typeAnnotation: Session
I think this might be an issue in SwiftSyntax, but I am not sure if this is by design.
when parsing symbols, variables with inferred types don't get a typeAnnotation.
class SomeClass {
let scheduler = DispatchQueue.global(qos: .background)
}
See printout below of a symbol as Variable
result: typeAnnotation
is nil
▿ let scheduler = DispatchQueue.global(qos: .background)
- attributes : 0 elements
▿ modifiers : 1 element
▿ 0 : private
- name : "private"
- detail : nil
- keyword : "let"
- name : "scheduler"
- typeAnnotation : nil
▿ initializedValue : Optional<String>
- some : "DispatchQueue.global(qos: .userInitiated)"
- accessors : 0 elements
Is this intentional to only show explicit types?
When setting an explicit type it works fine:
class SomeClass {
let scheduler: DispatchQueue = .global(qos: .background)
}
If you create a new swift package, open it in Xcode, and add the dependencies and sample code, it fails to run successfully:
dyld: Library not loaded: @rpath/lib_InternalSwiftSyntaxParser.dylib
Referenced from: /Users/chris/Library/Developer/Xcode/DerivedData/swiftmodulevis-dsdxeurkiqwybuaykcssnhgivnum/Build/Products/Debug/swiftmodulevis
Reason: image not found
I forgot what causes this bug. Running/building from the terminal works fine. Maybe good to either add a notice or fix this? (I don't have time but wanted to let you know anyway).
This is Xcode 11.3 on Mojave.
Hi,
First, thanks for this library which saved me days learning SwiftSyntax 😁
Second, I am having a problem updating SwiftSemantics from version 0.2.0
to 0.3.2
in my project's Package.swift
The error shown in XCode is
Dependencies could not be resolved because root depends on 'SwiftSemantics' 0.3.2..<1.0.0.
'SwiftSemantics' >= 0.3.2 cannot be used because no versions of 'SwiftSemantics' match the requirement 0.3.3..<1.0.0 and package 'swiftsemantics' is required using a stable-version but 'swiftsemantics' depends on an unstable-version package 'swift-syntax'.
Has anyone encountered this problem ?
Thanks
My Package.swift
file is:
// swift-tools-version:5.3
import PackageDescription
let package = Package(
name: "ModelGenerator",
platforms: [ .macOS(.v10_15) ],
products: [
.executable(name: "ModelGenerator", targets: ["ModelGenerator"])
],
dependencies: [
.package(
url: "https://github.com/apple/swift-argument-parser",
from: "0.4.3"
),
.package(
name: "SwiftSemantics",
url: "https://github.com/SwiftDocOrg/SwiftSemantics",
from: "0.3.2"
),
],
targets: [
.target(
name: "ModelGenerator",
dependencies: [
"ModelGeneratorCore",
.product(name: "ArgumentParser", package: "swift-argument-parser"),
]
),
.target(
name: "ModelGeneratorCore",
dependencies: [
"SwiftSemantics",
]
)
]
)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.