mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
This will allow us to run two different completion kinds and deliver results from both of them. Also: Compute a unified type context for global lookup. Previously, we always used the expected type context of the last lookup. But really, we should be considering all possible types from all constraint system solutions when computing code completion results from the cache.
48 lines
1.5 KiB
C++
48 lines
1.5 KiB
C++
//===--- KeyPathCompletion.h ----------------------------------------------===//
|
|
//
|
|
// This source file is part of the Swift.org open source project
|
|
//
|
|
// Copyright (c) 2014 - 2022 Apple Inc. and the Swift project authors
|
|
// Licensed under Apache License v2.0 with Runtime Library Exception
|
|
//
|
|
// See https://swift.org/LICENSE.txt for license information
|
|
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef SWIFT_IDE_KEYPATHCOMPLETION_H
|
|
#define SWIFT_IDE_KEYPATHCOMPLETION_H
|
|
|
|
#include "swift/IDE/CodeCompletionConsumer.h"
|
|
#include "swift/IDE/CodeCompletionContext.h"
|
|
#include "swift/IDE/TypeCheckCompletionCallback.h"
|
|
|
|
namespace swift {
|
|
namespace ide {
|
|
|
|
class KeyPathTypeCheckCompletionCallback : public TypeCheckCompletionCallback {
|
|
struct Result {
|
|
/// The type on which completion should occur, i.e. a result type of the
|
|
/// previous component.
|
|
Type BaseType;
|
|
/// Whether code completion happens on the key path's root.
|
|
bool OnRoot;
|
|
};
|
|
|
|
KeyPathExpr *KeyPath;
|
|
SmallVector<Result, 4> Results;
|
|
|
|
void sawSolutionImpl(const constraints::Solution &solution) override;
|
|
|
|
public:
|
|
KeyPathTypeCheckCompletionCallback(KeyPathExpr *KeyPath) : KeyPath(KeyPath) {}
|
|
|
|
void collectResults(DeclContext *DC, SourceLoc DotLoc,
|
|
ide::CodeCompletionContext &CompletionCtx);
|
|
};
|
|
|
|
} // end namespace ide
|
|
} // end namespace swift
|
|
|
|
#endif // SWIFT_IDE_KEYPATHCOMPLETION_H
|