Skip to content

[IDE] Enable 'IgnoreSwiftSourceInfo' in code completion #28282

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions tools/SourceKit/lib/SwiftLang/SwiftCompletion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ static bool swiftCodeCompleteImpl(
return false;
}

// Disable source location resolutions from .swiftsourceinfo file because
// they are somewhat heavy operations and are not needed for completions.
Invocation.getFrontendOptions().IgnoreSwiftSourceInfo = true;

const char *Position = InputFile->getBufferStart() + CodeCompletionOffset;
std::unique_ptr<llvm::WritableMemoryBuffer> NewBuffer =
llvm::WritableMemoryBuffer::getNewUninitMemBuffer(
Expand Down
4 changes: 4 additions & 0 deletions tools/SourceKit/lib/SwiftLang/SwiftConformingMethodList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ static bool swiftConformingMethodListImpl(
return false;
}

// Disable source location resolutions from .swiftsourceinfo file because
// they are somewhat heavy operations and are not needed for completions.
Invocation.getFrontendOptions().IgnoreSwiftSourceInfo = true;

Invocation.setCodeCompletionPoint(newBuffer.get(), Offset);

// Create a factory for code completion callbacks that will feed the
Expand Down
4 changes: 4 additions & 0 deletions tools/SourceKit/lib/SwiftLang/SwiftTypeContextInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ static bool swiftTypeContextInfoImpl(SwiftLangSupport &Lang,
return false;
}

// Disable source location resolutions from .swiftsourceinfo file because
// they are somewhat heavy operations and are not needed for completions.
Invocation.getFrontendOptions().IgnoreSwiftSourceInfo = true;

Invocation.setCodeCompletionPoint(newBuffer.get(), Offset);

// Create a factory for code completion callbacks that will feed the
Expand Down
12 changes: 12 additions & 0 deletions tools/swift-ide-test/swift-ide-test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,10 @@ static int doTypeContextInfo(const CompilerInvocation &InitInvok,

CompilerInvocation Invocation(InitInvok);

// Disable source location resolutions from .swiftsourceinfo file because
// they are somewhat heavy operations and are not needed for completions.
Invocation.getFrontendOptions().IgnoreSwiftSourceInfo = true;

Invocation.setCodeCompletionPoint(CleanFile.get(), Offset);

// Create a CodeCompletionConsumer.
Expand Down Expand Up @@ -801,6 +805,10 @@ doConformingMethodList(const CompilerInvocation &InitInvok,

CompilerInvocation Invocation(InitInvok);

// Disable source location resolutions from .swiftsourceinfo file because
// they are somewhat heavy operations and are not needed for completions.
Invocation.getFrontendOptions().IgnoreSwiftSourceInfo = true;

Invocation.setCodeCompletionPoint(CleanFile.get(), Offset);

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

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

// Disable source location resolutions from .swiftsourceinfo file because
// they are somewhat heavy operations and are not needed for completions.
Invocation.getFrontendOptions().IgnoreSwiftSourceInfo = true;

// Disable to build syntax tree because code-completion skips some portion of
// source text. That breaks an invariant of syntax tree building.
Invocation.getLangOptions().BuildSyntaxTree = false;
Expand Down