Skip to content

Commit 815bf31

Browse files
committed
[IDE] Enable 'IgnoreSwiftSourceInfo' in code completion
Get source locations from '.swiftsourceinfo' is currently expensive. Since they are not necessary for code completion, set 'IgnoreSwiftSourceInfo' to 'true'. rdar://problem/57194358 https://bugs.swift.org/browse/SR-11767
1 parent 2fbb0c1 commit 815bf31

File tree

4 files changed

+24
-0
lines changed

4 files changed

+24
-0
lines changed

tools/SourceKit/lib/SwiftLang/SwiftCompletion.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,10 @@ static bool swiftCodeCompleteImpl(
172172
return false;
173173
}
174174

175+
// Disable source location resolutions from .swiftsourceinfo file because
176+
// they are somewhat heavy operations and are not needed for completions.
177+
Invocation.getFrontendOptions().IgnoreSwiftSourceInfo = true;
178+
175179
const char *Position = InputFile->getBufferStart() + CodeCompletionOffset;
176180
std::unique_ptr<llvm::WritableMemoryBuffer> NewBuffer =
177181
llvm::WritableMemoryBuffer::getNewUninitMemBuffer(

tools/SourceKit/lib/SwiftLang/SwiftConformingMethodList.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ static bool swiftConformingMethodListImpl(
6767
return false;
6868
}
6969

70+
// Disable source location resolutions from .swiftsourceinfo file because
71+
// they are somewhat heavy operations and are not needed for completions.
72+
Invocation.getFrontendOptions().IgnoreSwiftSourceInfo = true;
73+
7074
Invocation.setCodeCompletionPoint(newBuffer.get(), Offset);
7175

7276
// Create a factory for code completion callbacks that will feed the

tools/SourceKit/lib/SwiftLang/SwiftTypeContextInfo.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ static bool swiftTypeContextInfoImpl(SwiftLangSupport &Lang,
6767
return false;
6868
}
6969

70+
// Disable source location resolutions from .swiftsourceinfo file because
71+
// they are somewhat heavy operations and are not needed for completions.
72+
Invocation.getFrontendOptions().IgnoreSwiftSourceInfo = true;
73+
7074
Invocation.setCodeCompletionPoint(newBuffer.get(), Offset);
7175

7276
// Create a factory for code completion callbacks that will feed the

tools/swift-ide-test/swift-ide-test.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -740,6 +740,10 @@ static int doTypeContextInfo(const CompilerInvocation &InitInvok,
740740

741741
CompilerInvocation Invocation(InitInvok);
742742

743+
// Disable source location resolutions from .swiftsourceinfo file because
744+
// they are somewhat heavy operations and are not needed for completions.
745+
Invocation.getFrontendOptions().IgnoreSwiftSourceInfo = true;
746+
743747
Invocation.setCodeCompletionPoint(CleanFile.get(), Offset);
744748

745749
// Create a CodeCompletionConsumer.
@@ -801,6 +805,10 @@ doConformingMethodList(const CompilerInvocation &InitInvok,
801805

802806
CompilerInvocation Invocation(InitInvok);
803807

808+
// Disable source location resolutions from .swiftsourceinfo file because
809+
// they are somewhat heavy operations and are not needed for completions.
810+
Invocation.getFrontendOptions().IgnoreSwiftSourceInfo = true;
811+
804812
Invocation.setCodeCompletionPoint(CleanFile.get(), Offset);
805813

806814
SmallVector<const char *, 4> typeNames;
@@ -870,6 +878,10 @@ static int doCodeCompletion(const CompilerInvocation &InitInvok,
870878

871879
Invocation.setCodeCompletionPoint(CleanFile.get(), CodeCompletionOffset);
872880

881+
// Disable source location resolutions from .swiftsourceinfo file because
882+
// they are somewhat heavy operations and are not needed for completions.
883+
Invocation.getFrontendOptions().IgnoreSwiftSourceInfo = true;
884+
873885
// Disable to build syntax tree because code-completion skips some portion of
874886
// source text. That breaks an invariant of syntax tree building.
875887
Invocation.getLangOptions().BuildSyntaxTree = false;

0 commit comments

Comments
 (0)