Skip to content

Commit d8995c1

Browse files
committed
---
yaml --- r: 345566 b: refs/heads/master c: 401b876 h: refs/heads/master
1 parent e651198 commit d8995c1

File tree

4 files changed

+29
-16
lines changed

4 files changed

+29
-16
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 14fb887eb9cb54211efd0e221e03250fba341f75
2+
refs/heads/master: 401b876f4bd302f744f7cad0a21ad5e597a5922c
33
refs/heads/master-next: 203b3026584ecad859eb328b2e12490099409cd5
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea

trunk/test/SourceKit/CompileNotifications/diagnostics.swift

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,22 @@
6868
// FIXME: invalid arguments cause us to early-exit and not send the notifications
6969
// RUN_DISABLED: %sourcekitd-test -req=track-compiles == -req=sema %s -- %s -invalid-arg | %FileCheck %s -check-prefix=INVALID_ARG
7070

71-
// RUN: %sourcekitd-test -req=track-compiles == -req=sema %s -- %s -Xcc -invalid-arg | %FileCheck %s -check-prefix=INVALID_ARG_CLANG
72-
// INVALID_ARG_CLANG: key.notification: source.notification.compile-did-finish,
73-
// INVALID_ARG_CLANG-NEXT: key.diagnostics: [
74-
// INVALID_ARG_CLANG-NEXT: {
75-
// INVALID_ARG_CLANG-NEXT: key.filepath: "<unknown>"
76-
// INVALID_ARG_CLANG-NEXT: key.severity: source.diagnostic.severity.error,
77-
// INVALID_ARG_CLANG-NEXT: key.offset: 0
78-
// INVALID_ARG_CLANG-NEXT: key.description: "unknown argument
71+
// RUN: %sourcekitd-test -req=track-compiles == -req=sema %s -- %s -Xcc -invalid-arg | %FileCheck %s -check-prefix=INVALID_ARG
72+
// INVALID_ARG: key.notification: source.notification.compile-did-finish,
73+
// INVALID_ARG-NEXT: key.diagnostics: [
74+
// INVALID_ARG-NEXT: {
75+
// INVALID_ARG-NEXT: key.filepath: "<unknown>"
76+
// INVALID_ARG-NEXT: key.severity: source.diagnostic.severity.error,
77+
// INVALID_ARG-NEXT: key.offset: 0
78+
// INVALID_ARG-NEXT: key.description: "unknown argument
7979

8080
// Ignore the spurious -wmo + -enable-batch-mode warning.
8181
// RUN: %sourcekitd-test -req=track-compiles == -req=sema %s -- %s -enable-batch-mode | %FileCheck %s -check-prefix=NODIAGS
8282
// RUN: %sourcekitd-test -req=track-compiles == -req=complete -offset=0 %s -- %s -enable-batch-mode | %FileCheck %s -check-prefix=NODIAGS
83+
84+
// Report syntactic-only requests that have arguments.
85+
// RUN: %sourcekitd-test -req=track-compiles == -req=syntax-map %s -- %s -invalid-arg | %FileCheck %s -check-prefix=INVALID_ARG
86+
// But ignore syntactic-only requests with no arguments.
87+
// RUN: %sourcekitd-test -req=track-compiles == -req=syntax-map %s | %FileCheck %s -check-prefix=SYNTACTIC
88+
// SYNTACTIC: key.syntaxmap:
89+
// SYNTACTIC_NOT: key.notification: source.notification.compile-did-finish

trunk/tools/SourceKit/lib/SwiftLang/SwiftEditor.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1625,7 +1625,8 @@ SwiftEditorDocument::~SwiftEditorDocument()
16251625
}
16261626

16271627
ImmutableTextSnapshotRef SwiftEditorDocument::initializeText(
1628-
llvm::MemoryBuffer *Buf, ArrayRef<const char *> Args) {
1628+
llvm::MemoryBuffer *Buf, ArrayRef<const char *> Args,
1629+
bool ProvideSemanticInfo) {
16291630

16301631
llvm::sys::ScopedLock L(Impl.AccessMtx);
16311632

@@ -1637,9 +1638,13 @@ ImmutableTextSnapshotRef SwiftEditorDocument::initializeText(
16371638
Impl.SyntaxMap.Tokens.clear();
16381639
Impl.AffectedRange = {0, static_cast<unsigned>(Buf->getBufferSize())};
16391640

1640-
Impl.SemanticInfo = new SwiftDocumentSemanticInfo(Impl.FilePath, Impl.ASTMgr,
1641-
Impl.NotificationCtr);
1642-
Impl.SemanticInfo->setCompilerArgs(Args);
1641+
// Try to create a compiler invocation object if needing semantic info
1642+
// or it's syntactic-only but with passed-in compiler arguments.
1643+
if (ProvideSemanticInfo || !Args.empty()) {
1644+
Impl.SemanticInfo = new SwiftDocumentSemanticInfo(Impl.FilePath, Impl.ASTMgr,
1645+
Impl.NotificationCtr);
1646+
Impl.SemanticInfo->setCompilerArgs(Args);
1647+
}
16431648
return Impl.EditableBuffer->getSnapshot();
16441649
}
16451650

@@ -2038,7 +2043,7 @@ void SwiftLangSupport::editorOpen(StringRef Name, llvm::MemoryBuffer *Buf,
20382043
auto EditorDoc = EditorDocuments->getByUnresolvedName(Name);
20392044
if (!EditorDoc) {
20402045
EditorDoc = new SwiftEditorDocument(Name, *this);
2041-
Snapshot = EditorDoc->initializeText(Buf, Args);
2046+
Snapshot = EditorDoc->initializeText(Buf, Args, Consumer.needsSemanticInfo());
20422047
EditorDoc->parse(Snapshot, *this, Consumer.syntaxTreeEnabled());
20432048
if (EditorDocuments->getOrUpdate(Name, *this, EditorDoc)) {
20442049
// Document already exists, re-initialize it. This should only happen
@@ -2051,7 +2056,7 @@ void SwiftLangSupport::editorOpen(StringRef Name, llvm::MemoryBuffer *Buf,
20512056
}
20522057

20532058
if (!Snapshot) {
2054-
Snapshot = EditorDoc->initializeText(Buf, Args);
2059+
Snapshot = EditorDoc->initializeText(Buf, Args, Consumer.needsSemanticInfo());
20552060
EditorDoc->parse(Snapshot, *this, Consumer.syntaxTreeEnabled());
20562061
}
20572062

trunk/tools/SourceKit/lib/SwiftLang/SwiftLangSupport.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ class SwiftEditorDocument :
8282
~SwiftEditorDocument();
8383

8484
ImmutableTextSnapshotRef initializeText(llvm::MemoryBuffer *Buf,
85-
ArrayRef<const char *> Args);
85+
ArrayRef<const char *> Args,
86+
bool ProvideSemanticInfo);
8687
ImmutableTextSnapshotRef replaceText(unsigned Offset, unsigned Length,
8788
llvm::MemoryBuffer *Buf,
8889
bool ProvideSemanticInfo,

0 commit comments

Comments
 (0)