@eclipse-cdt-cloud/clangd-contexts
Version:
CDT.cloud - Support for multiple configuration contexts in clangd.
89 lines • 5.05 kB
TypeScript
/********************************************************************************
* Copyright (c) 2021 STMicroelectronics and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the Eclipse
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
* with the GNU Classpath Exception which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*******************************************************************************/
import { ClangdConfig } from './clangd-config';
import { ClangdContextsConfig } from './clangd-contexts-config';
/** Description of a clangd context. */
export interface ClangdContext {
name: string;
compilationDatabase: string;
}
/**
* Set the context selected in a project. The `.clangd` file will be updated to
* refer to the given context's compilation database.
*
* @param configurationInput the clangd configuration to update, either the `.clangd` file's path or its content
* @param contextDirectory the directory that contains the compilation database file
* @throws {@link ClangdConfigException} on error in saving the updated configuration file
*/
export declare function setContext(configurationInput: string | ClangdConfig, contextDirectory: string): void;
/**
* Retrieve the active context of the given `.clangd` configuration file.
*
* @param configPath the clangd context file to read
* @return the context-relevant content of the file, or `undefined` if the file does not exist
* @throws {@link ClangdConfigException} on error in loading an existing configuration file
*/
export declare function getContext(configPath: string): ClangdContext | undefined;
/**
* In the given `.clangd` file, specify flags to add to and/or remove from invocations of the `clang` compiler
* in clangd's analysis.
*
* @param configurationInput the clangd configuration to update, either the `.clangd` file path or its content
* @param addFlags an optional array of flags to add to the list of flags added to the `clang` command-line
* @param removeFlags an optional array of flags to add to the list of flags removed from the `clang` command-line
* @throws {@link ClangdConfigException} on error in saving the updated configuration file
*/
export declare function setCompileFlags(configurationInput: string | ClangdConfig, addFlags?: string[], removeFlags?: string[]): void;
/**
* Remove from the given `.clangd` file some flags that are currently added or removed from invocations of the `clang` compiler
* in clangd's analysis. In the `.clangd` file, any given flag will generally be either in the `Add` list or the `Remove` list.
* This function ensures that the flags specified will not appear in either list in the updated `.clangd` file.
*
* @param configurationInput the clangd configuration to update, either the `.clangd` file path or its content
* @param flags an optional array of flags to remove from the lists of flags added to and removed from the `clang` command-line
* @throws {@link ClangdConfigException} on error in saving the updated configuration file
*/
export declare function unsetCompileFlags(configurationInput: string | ClangdConfig, flags?: string[]): void;
/**
* Activate a named context in all of the projects that have a context of that name.
* Any project that does not have the context is left unchanged.
*
* @param contextsConfig the projects from the `.clangd-contexts` file
* @param contextName the context to active in the projects
*/
export declare function selectContext(contextsConfig: ClangdContextsConfig, contextName: string): void;
/**
* List the distinct context names across all projects.
*
* @param contextsConfig the clangd workspace configuration from the `.clangd-contexts` file
*/
export declare function listContexts(contextsConfig: ClangdContextsConfig): void;
/**
* List the projects in the workspace.
*
* @param contextsConfig the clangd workspace configuration from the `.clangd-contexts` file
* @param baseDir a directory relative to which the output directory paths are deresolved. For example, in a
* CLI tool this might be the current working directory. If omitted, absolute paths are output
*/
export declare function listProjects(contextsConfig: ClangdContextsConfig, baseDir?: string): void;
/**
* Perform some action on all valid project directories.
*
* @param contextsConfig the clangd workspace configuration from the `.clangd-contexts` file
* @param action an action to perform on each project directory
*/
export declare function forAllProjects(contextsConfig: ClangdContextsConfig, action: (configurationInput: string | ClangdConfig) => void): void;
//# sourceMappingURL=clangd-context.d.ts.map