Skip to content

Commit 53d1a2b

Browse files
committed
[Parse] Enable SwiftParser parisng for code completion
But disable roundtrip/validation testing. So that macro expansions are correctly performed in code completion, but avoid an assertion failure caused by existence of null character in the source buffer. rdar://107900870
1 parent 23f9749 commit 53d1a2b

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed

lib/Parse/ParseDecl.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,8 @@ void Parser::parseTopLevelItems(SmallVectorImpl<ASTNode> &items) {
269269
// Perform round-trip and/or validation checking.
270270
if ((Context.LangOpts.hasFeature(Feature::ParserRoundTrip) ||
271271
Context.LangOpts.hasFeature(Feature::ParserValidation)) &&
272-
SF.exportedSourceFile) {
272+
SF.exportedSourceFile &&
273+
!SourceMgr.hasIDEInspectionTargetBuffer()) {
273274
if (Context.LangOpts.hasFeature(Feature::ParserRoundTrip) &&
274275
swift_ASTGen_roundTripCheck(SF.exportedSourceFile)) {
275276
SourceLoc loc;
@@ -305,8 +306,7 @@ Parser::parseSourceFileViaASTGen(SmallVectorImpl<ASTNode> &items,
305306
bool suppressDiagnostics) {
306307
#if SWIFT_SWIFT_PARSER
307308
Optional<DiagnosticTransaction> existingParsingTransaction;
308-
if (!SourceMgr.hasIDEInspectionTargetBuffer() &&
309-
SF.Kind != SourceFileKind::SIL) {
309+
if (SF.Kind != SourceFileKind::SIL) {
310310
StringRef contents =
311311
SourceMgr.extractText(SourceMgr.getRangeForBuffer(L->getBufferID()));
312312

test/IDE/complete_optionset.swift

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// REQUIRES: swift_swift_parser
2+
// RUN: %empty-directory(%t)
3+
// RUN: %target-swift-ide-test -batch-code-completion -source-filename %s -filecheck %raw-FileCheck -completion-output-dir %t -plugin-path %swift-host-lib-dir/plugins
4+
5+
@OptionSet<UInt8>
6+
struct ShippingOptions {
7+
private enum Options: Int {
8+
case nextDay
9+
case secondDay
10+
case priority
11+
case standard
12+
}
13+
}
14+
15+
func foo() {
16+
ShippingOptions.#^MEMBER_STATIC^#
17+
}
18+
19+
// MEMBER_STATIC: Keyword[self]/CurrNominal: self[#ShippingOptions.Type#]; name=self
20+
// MEMBER_STATIC: Decl[TypeAlias]/CurrNominal: RawValue[#UInt8#]; name=RawValue
21+
// MEMBER_STATIC: Decl[Constructor]/CurrNominal: init({#rawValue: ShippingOptions.RawValue#})[#ShippingOptions#]; name=init(rawValue:)
22+
// MEMBER_STATIC: Decl[StaticVar]/CurrNominal: nextDay[#ShippingOptions#]; name=nextDay
23+
// MEMBER_STATIC: Decl[StaticVar]/CurrNominal: secondDay[#ShippingOptions#]; name=secondDay
24+
// MEMBER_STATIC: Decl[StaticVar]/CurrNominal: priority[#ShippingOptions#]; name=priority
25+
// MEMBER_STATIC: Decl[StaticVar]/CurrNominal: standard[#ShippingOptions#]; name=standard
26+
// MEMBER_STATIC: Decl[TypeAlias]/CurrNominal: Element[#ShippingOptions#]; name=Element
27+
// MEMBER_STATIC: Decl[TypeAlias]/CurrNominal: ArrayLiteralElement[#ShippingOptions#]; name=ArrayLiteralElement
28+
// MEMBER_STATIC: Decl[Constructor]/Super/IsSystem: init()[#ShippingOptions#]; name=init()
29+
// MEMBER_STATIC: Decl[Constructor]/Super/IsSystem: init({#(sequence): Sequence#})[#ShippingOptions#]; name=init(:)

0 commit comments

Comments
 (0)