SourceKit document structure request used to crash if if there's inititalizer
with single named parameter with `@IBAction` attribute.
This used to happen because
ConstructorDecl::isObjCZeroParameterWithLongSelector() requires
interface type of the parameter but the constructor doesn't have it at
this stage.
This change fixes that by not vending ObjC name for
constructor or destructors.
rdar://problem/47426948
Instead of creating syntax nodes directly, modify the parser to invoke an abstract interface 'SyntaxParseActions' while it is parsing the source code.
This decouples the act of parsing from the act of forming a syntax tree representation.
'SyntaxTreeCreator' is an implementation of SyntaxParseActions that handles the logic of creating a syntax tree.
To enforce the layering separation of parsing and syntax tree creation, a static library swiftSyntaxParse is introduced to compose the two.
This decoupling is important for introducing a syntax parser library for SwiftSyntax to directly access parsing.
Addressing review feedback: this avoids calling shared_from_this() from
outside the implementation. Note: it is not possible to use private
inheritance of enable_shared_from_this to prevent this issue in general,
because enabled_shared_from_this relies on the shared_ptr constructor
being able to detect that the type has this inheritance, which means it
must be public.
While I'm not aware of this causing an issue in practice it was just
begging to trigger a use-after-free if we ever used this reference in a
new method since the editor document is accessed asynchronously.
While the SwiftLangSupport doesn't currently outlive the global context
it clarifies the ownership to just store the weak reference we care
about instead of referencing the owning context. In the future we may
want to ref-count the lang support, in which case we'd need to do this
to avoid a cycle anyway.
When the server shuts down we may still have outstanding async work to
build an AST, so use a shared_ptr + weak_ptr instead of unique_ptr +
unowned references.
When the server shuts down we may still have outstanding async work that
can attempt to trigger a notification, so use a shared_ptr + weak_ptr
instead of unique_ptr + unowned references.
When triggering replaceText we were locking the EditorDocument then the
ASTProducer, but during AST building we do the reverse. This would cause
a deadlock if these two bits of code raced. Break the cycle by dropping
the editor lock when calling the ASTManager.
Thank you TSan!
When a document is opened twice without closing it we re-initialize its
internal data. Make sure we don't race with code that accesses that data.
Found by TSan!
Having this be a single buffer hardcoded in the SourceManager and set
by all clients is silly. SourceFiles with the 'Main' kind are allowed
to have hashbang lines (`#!`), other files are not. And anyone
manually setting up a Lexer can decide for themselves.
No intended behavioral change.
We were always returning true from those functions in SKEditorConsumer
and false in the test consumers. On the client side we would then ignore
the return value. So it's clearer to have the functions not return
anything.
Otherwise, hits assertion, or crashes in no-assertion build.
Added 'EditableTextBuffer::getSize()' for getting size after previous updates
without actually applying them.
rdar://problem/34206143
The recommended way forward is to use the SyntaxClassifier on the Swift
side.
By removing the C++ SyntaxClassifier, we can also eliminate the
-force-libsyntax-based-processing option that was used to bootstrap
incremental parsing and would generate the syntax map from a syntax
tree.