mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
ASTContexts This introduces swift::ide::CodeCompletionCache, which is a persistent code completion result cache. Right now REPL happens to use it (try importing Cocoa and doing code completion), and the difference is noticeable. But completion in REPL is still slow, because Cocoa goes through the AST Verifier on every completion (for unknown reasons). This commit does not implement cache invalidation yet, and it does not use libcache to evict cache entries under memory pressure. This commit also introduces two regressions: - We get fewer Cocoa results that expected. Module::isModuleVisible in Clang does not incorrectly reports that that ObjectiveC.NSObject submodule is not visible from Cocoa. - We are not implementing the decl hiding rules correctly. We used to rely on visible decl lookup to do it for us, but now we have a different data structure we have real decls from the current module and we have a text-only cache, so we are forced to reimplement this part of name lookup in code completion. Swift SVN r9633
50 lines
1.9 KiB
C++
50 lines
1.9 KiB
C++
//===--- ModuleNameLookup.cpp - Name lookup within a module ----*- c++ -*--===//
|
|
//
|
|
// This source file is part of the Swift.org open source project
|
|
//
|
|
// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
|
|
// Licensed under Apache License v2.0 with Runtime Library Exception
|
|
//
|
|
// See http://swift.org/LICENSE.txt for license information
|
|
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef SWIFT_AST_MODULENAMELOOKUP_H
|
|
#define SWIFT_AST_MODULENAMELOOKUP_H
|
|
|
|
#include "swift/Basic/SourceManager.h"
|
|
#include "swift/AST/NameLookup.h"
|
|
#include "swift/AST/AST.h"
|
|
#include "swift/AST/ASTVisitor.h"
|
|
#include "swift/Basic/Fallthrough.h"
|
|
#include "swift/Basic/STLExtras.h"
|
|
#include "llvm/ADT/DenseMap.h"
|
|
#include "llvm/ADT/TinyPtrVector.h"
|
|
|
|
namespace swift {
|
|
namespace namelookup {
|
|
|
|
/// Performs a lookup into the given module and, if necessary, its
|
|
/// reexports, observing proper shadowing rules.
|
|
///
|
|
/// \param module The module that will contain the name.
|
|
/// \param accessPath The import scope on \p module.
|
|
/// \param name The name to look up.
|
|
/// \param[out] decls Any found decls will be added to this vector.
|
|
/// \param lookupKind Whether this lookup is qualified or unqualified.
|
|
/// \param resolutionKind What sort of decl is expected.
|
|
/// \param typeResolver The type resolver for decls that need to be
|
|
/// type-checked. This is needed for shadowing resolution.
|
|
/// \param topLevel If \p module should be treated as a top-level source file,
|
|
/// e.g. its private imports should be included in the search.
|
|
void lookupInModule(Module *module, Module::AccessPathTy accessPath,
|
|
Identifier name, SmallVectorImpl<ValueDecl *> &decls,
|
|
NLKind lookupKind, ResolutionKind resolutionKind,
|
|
LazyResolver *typeResolver, bool topLevel);
|
|
|
|
} // end namespace namelookup
|
|
} // end namespace swift
|
|
|
|
#endif
|