mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
LLVM has removed llvm::Optional, move over to std::optional. Also clang-format to fix up all the renamed #includes.
54 lines
1.8 KiB
C++
54 lines
1.8 KiB
C++
//===--- EditorPlaceholder.h - Handling for editor placeholders -*- C++ -*-===//
|
|
//
|
|
// This source file is part of the Swift.org open source project
|
|
//
|
|
// Copyright (c) 2014 - 2017 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
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
///
|
|
/// \file
|
|
/// Provides info about editor placeholders, <#such as this#>.
|
|
///
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef SWIFT_BASIC_EDITORPLACEHOLDER_H
|
|
#define SWIFT_BASIC_EDITORPLACEHOLDER_H
|
|
|
|
#include "llvm/ADT/StringRef.h"
|
|
#include <optional>
|
|
|
|
namespace swift {
|
|
|
|
enum class EditorPlaceholderKind {
|
|
Basic,
|
|
Typed,
|
|
};
|
|
|
|
struct EditorPlaceholderData {
|
|
/// Placeholder kind.
|
|
EditorPlaceholderKind Kind;
|
|
/// The part that is displayed in the editor.
|
|
llvm::StringRef Display;
|
|
/// If kind is \c Typed, this is the type string for the placeholder.
|
|
llvm::StringRef Type;
|
|
/// If kind is \c Typed, this is the type string to be considered for
|
|
/// placeholder expansion.
|
|
/// It can be same as \c Type or different if \c Type is a typealias.
|
|
llvm::StringRef TypeForExpansion;
|
|
};
|
|
|
|
/// Deconstructs a placeholder string and returns info about it.
|
|
/// \returns None if the \c PlaceholderText is not a valid placeholder string.
|
|
std::optional<EditorPlaceholderData>
|
|
parseEditorPlaceholder(llvm::StringRef PlaceholderText);
|
|
|
|
/// Checks if an identifier with the given text is an editor placeholder
|
|
bool isEditorPlaceholder(llvm::StringRef IdentifierText);
|
|
} // end namespace swift
|
|
|
|
#endif // SWIFT_BASIC_EDITORPLACEHOLDER_H
|