зеркало из https://github.com/Azure/autorest.git
Update external APIs+documentation. (#2692)
* uncomment loader! * fixing checkout/install * new inline interface pullthru * cleanups and build changes * API refactoring and documentation * merged, moved to node 8.9 * removed unused critical section stuff * quoted parameters in package.json * someone added new stuff
This commit is contained in:
Родитель
e7b1e36d4d
Коммит
d2505fcbcd
|
@ -102,9 +102,6 @@ task 'autorest', 'Runs AutoRest', (done)->
|
|||
task 'init', "" ,(done)->
|
||||
Fail "YOU MUST HAVE NODEJS VERSION GREATER THAN 7.10.0" if semver.lt( process.versions.node , "7.10.0" )
|
||||
|
||||
# we no longer need this symlinked in place. remove it if it is there.
|
||||
unlink "#{basefolder}/src/core/AutoRest/bin/netcoreapp1.0/node_modules/autorest-core" if test "-d", "#{basefolder}/src/core/AutoRest/bin/netcoreapp1.0/node_modules/autorest-core"
|
||||
|
||||
if (! test "-d","#{basefolder}/src/autorest-core")
|
||||
echo warning "\n#{ error 'NOTE:' } #{ info 'src/autorest-core'} appears to be missing \n fixing with #{ info 'git checkout src/autorest-core'}"
|
||||
echo warning " in the future do a #{ info 'gulp clean'} before using #{ info 'git clean'} .\n"
|
||||
|
@ -114,27 +111,17 @@ task 'init', "" ,(done)->
|
|||
global.initialized = true
|
||||
# if the node_modules isn't created, do it.
|
||||
if fileExists "#{basefolder}/package-lock.json"
|
||||
doit = true if (newer "#{basefolder}/package.json", "#{basefolder}/package-lock.json")
|
||||
else
|
||||
doit = true if (newer "#{basefolder}/package.json", "#{basefolder}/node_modules")
|
||||
|
||||
if (newer "#{basefolder}/package.json", "#{basefolder}/package-lock.json") or (newer "#{basefolder}/package.json", "#{basefolder}/node_modules")
|
||||
echo warning "\n#{ info 'NOTE:' } '#{basefolder}/node_modules' may be out of date #{ info "- consider running 'npm install'" }\n"
|
||||
|
||||
typescriptProjectFolders()
|
||||
.on 'end', ->
|
||||
if doit || force
|
||||
rm "#{basefolder}/package-lock.json" if fileExists "#{basefolder}/package-lock.json"
|
||||
echo warning "\n#{ info 'NOTE:' } 'node_modules' may be out of date - running 'npm install' for you.\n"
|
||||
echo "Running npm install for all project folders."
|
||||
exec "npm install", {cwd:basefolder,silent:true},(c,o,e)->
|
||||
echo "Completed Running npm install for project folder."
|
||||
done null
|
||||
else
|
||||
done null
|
||||
done null
|
||||
|
||||
.pipe foreach (each,next) ->
|
||||
# is any of the TS projects node_modules out of date?
|
||||
if (! test "-d", "#{each.path}/node_modules") or (newer "#{each.path}/package.json", "#{each.path}/package-lock.json")
|
||||
echo warning "#{ info 'NOTE:' } '#{each.path}/node_modules' may be out of date."
|
||||
doit = true
|
||||
echo warning "#{ info 'NOTE:' } '#{each.path}/node_modules' may be out of date. #{ info "- consider running 'npm install'" }\n"
|
||||
next null
|
||||
|
||||
return null
|
||||
|
|
|
@ -1,22 +1,3 @@
|
|||
task 'copy-dts-files', '', (done)->
|
||||
# this needs to run multiple times.
|
||||
global.completed['copy-dts-files'] = false
|
||||
copyDtsFiles(done)
|
||||
return null
|
||||
|
||||
copyDtsFiles = (done) =>
|
||||
# copy *.d.ts files
|
||||
source ["#{basefolder}/src/autorest-core/dist/**/*.d.ts","!#{basefolder}/src/autorest-core/dist/test/**" ]
|
||||
.pipe destination "#{basefolder}/src/autorest/lib/core"
|
||||
.on 'end', () =>
|
||||
source ["#{basefolder}/src/autorest-core/dist/**/*.d.ts","!#{basefolder}/src/autorest-core/dist/test/**" ]
|
||||
.pipe destination "#{basefolder}/src/autorest/dist/lib/core"
|
||||
.on 'end', () =>
|
||||
source ["#{basefolder}/src/autorest/vscode/**/*.d.ts" ]
|
||||
.pipe destination "#{basefolder}/src/autorest/dist/vscode"
|
||||
.on 'end', done
|
||||
return null
|
||||
|
||||
task 'fix-line-endings', 'typescript', ->
|
||||
typescriptFiles()
|
||||
.pipe eol {eolc: 'LF', encoding:'utf8'}
|
||||
|
@ -49,13 +30,9 @@ task "compile/typescript", '' , (done)->
|
|||
done()
|
||||
|
||||
task 'build', 'typescript', (done)->
|
||||
# watch for changes to these files and propogate them to the right spot.
|
||||
watcher = watchFiles ["#{basefolder}/src/autorest-core/dist/**/*.d.ts"], ["copy-dts-files"]
|
||||
|
||||
typescriptProjectFolders()
|
||||
.on 'end', ->
|
||||
run 'compile/typescript', ->
|
||||
watcher._watcher.close() if !watch
|
||||
done()
|
||||
|
||||
.pipe where (each ) ->
|
||||
|
@ -66,14 +43,9 @@ task 'build', 'typescript', (done)->
|
|||
deps = ("compile/typescript/#{d.substring(d.indexOf('/')+1)}" for d in (global.Dependencies[fn] || []))
|
||||
|
||||
task 'compile/typescript', fn, deps, (fin) ->
|
||||
copyDtsFiles ->
|
||||
execute "npm run build", {cwd: each.path }, (code,stdout,stderr) ->
|
||||
if watch
|
||||
execute "npm run watch", {cwd: each.path }, (c,o,e) ->
|
||||
echo "watching #{fn}"
|
||||
, (d) -> echo d.replace(/^src\//mig, "#{basefolder}/src/")
|
||||
fin()
|
||||
return null;
|
||||
execute "npm run build", {cwd: each.path }, (code,stdout,stderr) ->
|
||||
fin()
|
||||
return null;
|
||||
next null
|
||||
return null
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
components: [Object] } } }
|
||||
info: [Object],
|
||||
paths: [Object],
|
||||
schemes: [Object],
|
||||
servers: [Object],
|
||||
schemes: [Array],
|
||||
servers: [Array],
|
||||
{ openapi: '3.0.0',
|
||||
cache: {},
|
||||
externals: [],
|
||||
|
@ -12,8 +12,8 @@
|
|||
at ...
|
||||
at ...
|
||||
--- End of stack trace from previous location where exception was thrown ---
|
||||
(node) DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
|
||||
(node) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 7): Error: Could not resolve reference #/definitions/Cowball
|
||||
(node) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
|
||||
(node) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 10): Error: Could not resolve reference #/definitions/Cowball
|
||||
(node) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 8): Error: Could not resolve reference #/definitions/Cowball
|
||||
(node) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 9): Error: Could not resolve reference #/definitions/Cowball
|
||||
{ Error: Could not resolve reference #/definitions/Cowball
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
"devDependencies": {
|
||||
"chalk": "^1.1.2",
|
||||
"coffee-script": "^1.11.1",
|
||||
"dts-generator": "^2.1.0",
|
||||
"gulp": "^3.9.1",
|
||||
"gulp-dependencies-changed": "^1.0.2",
|
||||
"gulp-eol": "^0.1.2",
|
||||
|
@ -43,12 +44,12 @@
|
|||
"marked-terminal": "^2.0.0",
|
||||
"moment": "^2.17.1",
|
||||
"run-sequence": "*",
|
||||
"semver": "^5.3.0",
|
||||
"shelljs": "^0.7.6",
|
||||
"through2-parallel": "^0.1.3",
|
||||
"typescript": "2.5.3",
|
||||
"vinyl-fs": "^2.4.4",
|
||||
"yargs": "^6.6.0",
|
||||
"semver": "^5.3.0"
|
||||
"yargs": "^6.6.0"
|
||||
},
|
||||
"dependencies": {}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ import { AutoRestConfigurationImpl, MergeConfigurations } from './lib/configurat
|
|||
import { Parse, Stringify } from "./lib/ref/yaml";
|
||||
import { CreateObject, nodes } from "./lib/ref/jsonpath";
|
||||
import { OutstandingTaskAwaiter } from "./lib/outstanding-task-awaiter";
|
||||
import { AutoRest, ConfigurationView } from './lib/autorest-core';
|
||||
import { AutoRest, ConfigurationView, IsOpenApiDocument } from './lib/autorest-core';
|
||||
import { ShallowCopy } from "./lib/source-map/merging";
|
||||
import { Message, Channel } from "./lib/message";
|
||||
import { resolve as currentDirectory } from "path";
|
||||
|
@ -334,7 +334,7 @@ async function resourceSchemaBatch(api: AutoRest): Promise<number> {
|
|||
for (const eachFile of batchConfig["input-file"]) {
|
||||
const path = ResolveUri(config.configFileFolderUri, eachFile);
|
||||
const content = await ReadUri(path);
|
||||
if (!AutoRest.IsSwaggerFile(content)) {
|
||||
if (!await IsOpenApiDocument(content)) {
|
||||
exitcode++;
|
||||
console.error(`File ${path} is not a OpenAPI file.`);
|
||||
continue;
|
||||
|
|
|
@ -0,0 +1,96 @@
|
|||
fs = require("fs");
|
||||
gen = require('./node_modules/dts-generator/').default
|
||||
|
||||
async function main() {
|
||||
await gen({
|
||||
name: 'autorest-core',
|
||||
|
||||
baseDir: './',
|
||||
exclude: ['test/**/*','node_modules/**/*.d.ts',
|
||||
//'lib/artifact.ts',
|
||||
//'lib/autorest-core.ts',
|
||||
// 'lib/configuration.ts',
|
||||
'lib/constants.ts',
|
||||
//'lib/document-type.ts',
|
||||
// 'lib/events.ts',
|
||||
'lib/exception.ts',
|
||||
// 'lib/file-system.ts',
|
||||
'lib/lazy.ts',
|
||||
//'lib/message.ts',
|
||||
'lib/outstanding-task-awaiter.ts',
|
||||
'lib/sleep.ts',
|
||||
'lib/data-store/data-store.ts',
|
||||
'lib/parsing/literate-yaml.ts',
|
||||
'lib/parsing/literate.ts',
|
||||
'lib/parsing/stable-object.ts',
|
||||
'lib/parsing/text-utility.ts',
|
||||
'lib/parsing/yaml.ts',
|
||||
'lib/pipeline/artifact-emitter.ts',
|
||||
'lib/pipeline/commonmark-documentation.ts',
|
||||
'lib/pipeline/manipulation.ts',
|
||||
'lib/pipeline/object-manipulator.ts',
|
||||
'lib/pipeline/pipeline.ts',
|
||||
'lib/pipeline/plugin-api.ts',
|
||||
'lib/pipeline/plugin-endpoint.ts',
|
||||
'lib/pipeline/suppression.ts',
|
||||
'lib/pipeline/swagger-loader.ts',
|
||||
'lib/ref/async.ts',
|
||||
'lib/ref/cancellation.ts',
|
||||
'lib/ref/commonmark.ts',
|
||||
// 'lib/ref/jsonpath.ts',
|
||||
'lib/ref/jsonrpc.ts',
|
||||
'lib/ref/linq.ts',
|
||||
'lib/ref/safe-eval.ts',
|
||||
//'lib/ref/source-map.ts',
|
||||
'lib/ref/uri.ts',
|
||||
'lib/ref/yaml.ts',
|
||||
'lib/source-map/blaming.ts',
|
||||
'lib/source-map/merging.ts',
|
||||
'lib/source-map/source-map.ts',
|
||||
],
|
||||
|
||||
|
||||
|
||||
|
||||
out: './a.d.ts',
|
||||
files: ['main.ts', 'lib/file-system.ts']
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
/* let lsp = fs.readFileSync("vscode-languageserver-protocol.d.ts",'utf8').replace(/'.\//g,"'vscode-languageserver-protocol/").replace("vscode-languageserver-protocol/main","vscode-languageserver-protocol");
|
||||
|
||||
let vscj = fs.readFileSync("vscode-jsonrpc.d.ts",'utf8').replace(/'.\//g,"'vscode-jsonrpc/").replace("vscode-jsonrpc/main","vscode-jsonrpc");
|
||||
|
||||
|
||||
let client = fs.readFileSync("vscode-languageclient.d.ts",'utf8').replace(/'.\//g,"'vscode-languageclient/").replace("vscode-languageclient/main","vscode-languageclient");
|
||||
|
||||
|
||||
|
||||
let vscode = fs.readFileSync("vscode.d.ts",'utf8');
|
||||
|
||||
let lspt = fs.readFileSync("vscode-languageserver-types.d.ts",'utf8').replace("vscode-languageserver-types/main","vscode-languageserver-types");
|
||||
|
||||
let f = vscode+ '\n' + vscj + '\n' + client + "\n" + lsp +"\n" + lspt;
|
||||
|
||||
fs.writeFileSync("vscode-languageclient.d.ts", f );
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
await gen({
|
||||
name: 'foo-core',
|
||||
|
||||
baseDir: './dist',
|
||||
exclude: ['test/**/*','node_modules/**/*.d.ts' ],
|
||||
out: './b.d.ts',
|
||||
files: ['main.d.ts']
|
||||
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
main();
|
|
@ -9,6 +9,7 @@ import { Location, Position } from 'vscode-languageserver';
|
|||
import { value, stringify, parse, nodes, paths, } from "jsonpath";
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* This class provides complex analysis for a document in relation to its peers, i.e.
|
||||
* the other documents involved in one AutoRest/validation run (configuration file, OpenAPI documents).
|
||||
* As such, it offers operations like:
|
||||
|
@ -18,26 +19,6 @@ import { value, stringify, parse, nodes, paths, } from "jsonpath";
|
|||
* Essentially, it provides useful mappings between logical (JSON path) and physical (line/column) locations in both directions.
|
||||
*/
|
||||
export class DocumentAnalysis {
|
||||
/*
|
||||
public static async Create(host: OpenApiDocumentManager, documentUri: string): Promise<DocumentAnalysis | null> {
|
||||
|
||||
const document = await host.GetFileContent(documentUri);
|
||||
if (!document) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const fullyResolvedAndMergedDefinition = host.GetFullyResolvedAndMergedDefinitionOf(documentUri);
|
||||
if (!fullyResolvedAndMergedDefinition) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new DocumentAnalysis(
|
||||
documentUri,
|
||||
document,
|
||||
fullyResolvedAndMergedDefinition.openapiDefinition,
|
||||
new SourceMap(fullyResolvedAndMergedDefinition.openapiDefinitionMap));
|
||||
}*/
|
||||
|
||||
public constructor(
|
||||
private documentUri: string,
|
||||
private document: string,
|
||||
|
|
|
@ -6,11 +6,9 @@ require('../static-loader.js').load(`${__dirname}/../static_modules.fs`)
|
|||
process.env['ELECTRON_RUN_AS_NODE'] = "1";
|
||||
delete process.env['ELECTRON_NO_ATTACH_CONSOLE'];
|
||||
|
||||
import { AutoRest } from "../lib/autorest-core";
|
||||
import { Message, Channel } from "../lib/message"
|
||||
import { Message, Channel, IFileSystem, AutoRest, Artifact, IsConfigurationExtension, IdentifyDocument, IsConfigurationDocument, IsOpenApiExtension, IsOpenApiDocument, LiterateToJson, DocumentType } from "../main"
|
||||
import { JsonPath, SourceMap } from './source-map';
|
||||
import { IFileSystem } from "../lib/file-system";
|
||||
import { Artifact } from "../lib/artifact";
|
||||
|
||||
import { ResolveUri, FileUriToPath, GetExtension, IsUri, ParentFolderUri } from '../lib/ref/uri';
|
||||
import { From } from "linq-es2015";
|
||||
import { safeDump } from "js-yaml";
|
||||
|
@ -36,11 +34,12 @@ const azureValidatorRulesDocUrl = "https://github.com/Azure/azure-rest-api-specs
|
|||
|
||||
const md5 = (content: any) => content ? createHash('md5').update(JSON.stringify(content)).digest("hex") : null;
|
||||
|
||||
/** private per-configuration run state */
|
||||
class Result {
|
||||
private readonly onDispose = new Array<() => void>();
|
||||
private files = new Array<string>();
|
||||
private busy: Promise<void> = Promise.resolve();
|
||||
|
||||
public files = new Array<string>();
|
||||
public busy: Promise<void> = Promise.resolve();
|
||||
private queued = false;
|
||||
public readonly artifacts: Array<Artifact> = new Array<Artifact>();
|
||||
private readonly AutoRest: AutoRest;
|
||||
private static active = 0;
|
||||
|
@ -88,36 +87,45 @@ class Result {
|
|||
}));
|
||||
|
||||
this.onDispose.push(this.AutoRest.Finished.Subscribe((a, success) => {
|
||||
this.cancel = async () => { };
|
||||
// anything after it's done?
|
||||
service.debug(`Finished Autorest ${success}`);
|
||||
service.debug(`Finished Autorest ${success}\n`);
|
||||
|
||||
// clear diagnostics for next run
|
||||
for (const f of this.files) {
|
||||
const diagnostics = this.service.getDiagnosticCollection(f);
|
||||
// make sure that the last of the last is sent
|
||||
diagnostics.send();
|
||||
this.clearDiagnostics();
|
||||
|
||||
// then clear the collection it since we're sure this is the end of the run.
|
||||
diagnostics.clear();
|
||||
}
|
||||
// and mark us done!
|
||||
Result.active--;
|
||||
this.updateStatus();
|
||||
this.ready();
|
||||
}));
|
||||
}
|
||||
|
||||
public clearDiagnostics(send: boolean = false) {
|
||||
for (const f of this.files) {
|
||||
const diagnostics = this.service.getDiagnosticCollection(f);
|
||||
// make sure that the last of the last is sent
|
||||
diagnostics.send();
|
||||
|
||||
// then clear the collection it since we're sure this is the end of the run.
|
||||
diagnostics.clear(send);
|
||||
}
|
||||
}
|
||||
|
||||
private updateStatus() {
|
||||
if (Result.active === 0) {
|
||||
this.service.setStatus("idle");
|
||||
this.service.endActivity("autorest")
|
||||
return;
|
||||
}
|
||||
this.service.setStatus(`active:${Result.active}`);
|
||||
this.service.startActivity("autorest", "AutoRest is running", this.service.settings.debug ? `Validating ${Result.active} ` : "Validating");
|
||||
}
|
||||
|
||||
public async process() {
|
||||
Result.active++;
|
||||
this.updateStatus();
|
||||
|
||||
if (this.queued) {
|
||||
// we're already waiting to start a run, no sense on going again.
|
||||
return;
|
||||
}
|
||||
this.queued = true;
|
||||
// make sure we're clear to start
|
||||
await this.busy;
|
||||
|
||||
|
@ -127,6 +135,10 @@ class Result {
|
|||
// ensure that we have nothing left over from before
|
||||
this.clear();
|
||||
|
||||
// now, update the status
|
||||
Result.active++;
|
||||
this.updateStatus();
|
||||
|
||||
// set configuration
|
||||
await this.resetConfiguration(this.service.settings.configuration)
|
||||
|
||||
|
@ -135,6 +147,7 @@ class Result {
|
|||
|
||||
// start it up!
|
||||
const processResult = this.AutoRest.Process();
|
||||
this.queued = false;
|
||||
|
||||
this.cancel = async () => {
|
||||
// cancel only once!
|
||||
|
@ -142,6 +155,8 @@ class Result {
|
|||
|
||||
// cancel the current process if running.
|
||||
processResult.cancel();
|
||||
|
||||
await this.busy;
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -198,12 +213,29 @@ class Diagnostics {
|
|||
}
|
||||
|
||||
|
||||
export interface generated {
|
||||
/**
|
||||
* The results from calling the 'generate' method via the {@link AutoRestLanguageService/generate}
|
||||
*
|
||||
*/
|
||||
export interface GenerationResults {
|
||||
/** the array of messages produced from the run. */
|
||||
|
||||
messages: Array<string>;
|
||||
/** the collection of outputted files.
|
||||
*
|
||||
* Member keys are the file names
|
||||
* Member values are the file contents
|
||||
*
|
||||
* To Access the files:
|
||||
* for( const filename in generated.files ) {
|
||||
* const content = generated.files[filename];
|
||||
* /// ...
|
||||
* }
|
||||
*/
|
||||
files: Map<string, string>;
|
||||
}
|
||||
|
||||
export class OpenApiLanugageService extends TextDocuments implements IFileSystem {
|
||||
class OpenApiLanugageService extends TextDocuments implements IFileSystem {
|
||||
private results = new Map</*configfile*/string, Result>();
|
||||
private diagnostics = new Map</*file*/string, Diagnostics>();
|
||||
private virtualFile = new Map<string, TextDocument>();
|
||||
|
@ -228,7 +260,7 @@ export class OpenApiLanugageService extends TextDocuments implements IFileSystem
|
|||
// track opened, changed, saved, and closed files
|
||||
this.onDidOpen((p) => this.onDocumentChanged(p.document));
|
||||
this.onDidChangeContent((p) => this.onDocumentChanged(p.document));
|
||||
this.onDidClose((p) => this.getDiagnosticCollection(p.document.uri).clear(true));
|
||||
this.onDidClose((p) => this.onClosed(p.document.uri));
|
||||
this.onDidSave((p) => this.onSaving(p.document));
|
||||
|
||||
// subscribe to client settings changes
|
||||
|
@ -243,22 +275,52 @@ export class OpenApiLanugageService extends TextDocuments implements IFileSystem
|
|||
|
||||
connection.onInitialize(params => this.onInitialize(params));
|
||||
|
||||
// connection.onRequest("generate", generateArgs => onGenerate(generateArgs))
|
||||
this.setStatus("Starting Up.");
|
||||
|
||||
// expose the features that we want to give to the client
|
||||
connection.onRequest("generate", (p) => this.generate(p.documentUri, p.language, p.configuration));
|
||||
connection.onRequest("isOpenApiDocument", (p) => this.isOpenApiDocument(p.contentOrUri));
|
||||
connection.onRequest("isConfigurationFile", (p) => this.isConfigurationFile(p.contentOrUri));
|
||||
connection.onRequest("isSupportedFile", (p) => this.isSupportedFile(p.languageId, p.contentOrUri));
|
||||
connection.onRequest("identifyDocument", (p) => this.identifyDocument(p.contentOrUri));
|
||||
connection.onRequest("isConfigurationDocument", (p) => this.isConfigurationDocument(p.contentOrUri));
|
||||
connection.onRequest("isSupportedDocument", (p) => this.isSupportedDocument(p.languageId, p.contentOrUri));
|
||||
connection.onRequest("toJSON", (p) => this.toJSON(p.contentOrUri));
|
||||
connection.onRequest("findConfigurationFile", p => this.findConfigurationFile(p.documentUri));
|
||||
|
||||
connection.onRequest("detectConfigurationFile", p => this.detectConfigurationFile(p.documentUri));
|
||||
|
||||
this.listen(connection);
|
||||
}
|
||||
|
||||
public async generate(documentUri: string, language: string, configuration: any): Promise<generated> {
|
||||
private async onClosed(documentUri: string): Promise<void> {
|
||||
|
||||
if (await this.isConfigurationDocument(documentUri)) {
|
||||
// if this is a configuration, clear it's own errors
|
||||
this.getDiagnosticCollection(documentUri).clear(true);
|
||||
|
||||
// and if there are no input-files open, then clear theirs too.
|
||||
const result = this.results.get(documentUri);
|
||||
if (result) {
|
||||
// make sure it's not doing anything...
|
||||
await result.busy;
|
||||
|
||||
// check if any files are still open
|
||||
for (const each of result.files) {
|
||||
if (this.get(each)) {
|
||||
return; // yes, some file was still open, just quit from here.
|
||||
}
|
||||
}
|
||||
result.clearDiagnostics(true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// just closing a file.
|
||||
const configuration = await this.getConfiguration(documentUri, false);
|
||||
if (!this.get(configuration)) {
|
||||
// is the configuration file for this closed?
|
||||
this.getDiagnosticCollection(documentUri).clear(true);
|
||||
}
|
||||
}
|
||||
|
||||
public async generate(documentUri: string, language: string, configuration: any): Promise<GenerationResults> {
|
||||
const cfgFile = await this.getConfiguration(documentUri);
|
||||
const autorest = new AutoRest(this, cfgFile);
|
||||
const cfg: any = {};
|
||||
|
@ -282,23 +344,30 @@ export class OpenApiLanugageService extends TextDocuments implements IFileSystem
|
|||
}
|
||||
public async isOpenApiDocument(contentOrUri: string): Promise<boolean> {
|
||||
try {
|
||||
return IsUri(contentOrUri) ? await AutoRest.IsSwaggerFile(await this.ReadFile(contentOrUri)) : await AutoRest.IsSwaggerFile(contentOrUri);
|
||||
return IsUri(contentOrUri) ? await IsOpenApiDocument(await this.ReadFile(contentOrUri)) : await IsOpenApiDocument(contentOrUri);
|
||||
} catch { }
|
||||
return false;
|
||||
}
|
||||
public async isConfigurationFile(contentOrUri: string): Promise<boolean> {
|
||||
|
||||
public async identifyDocument(contentOrUri: string): Promise<DocumentType> {
|
||||
try {
|
||||
return IsUri(contentOrUri) ? await AutoRest.IsConfigurationFile(await this.ReadFile(contentOrUri)) : await AutoRest.IsConfigurationFile(contentOrUri);
|
||||
return IsUri(contentOrUri) ? await IdentifyDocument(await this.ReadFile(contentOrUri)) : await IdentifyDocument(contentOrUri);
|
||||
} catch { }
|
||||
return DocumentType.Unknown;
|
||||
}
|
||||
public async isConfigurationDocument(contentOrUri: string): Promise<boolean> {
|
||||
try {
|
||||
return IsUri(contentOrUri) ? await IsConfigurationDocument(await this.ReadFile(contentOrUri)) : await IsConfigurationDocument(contentOrUri);
|
||||
} catch { }
|
||||
return false;
|
||||
}
|
||||
public async isSupportedFile(languageId: string, contentOrUri: string): Promise<boolean> {
|
||||
public async isSupportedDocument(languageId: string, contentOrUri: string): Promise<boolean> {
|
||||
try {
|
||||
if (AutoRest.IsSwaggerExtension(languageId) || AutoRest.IsConfigurationExtension(languageId)) {
|
||||
if (IsOpenApiExtension(languageId) || IsConfigurationExtension(languageId)) {
|
||||
// so far, so good.
|
||||
const content = IsUri(contentOrUri) ? await this.ReadFile(contentOrUri) : contentOrUri;
|
||||
const isSwag = AutoRest.IsSwaggerFile(content);
|
||||
const isConf = AutoRest.IsConfigurationFile(content);
|
||||
const isSwag = IsOpenApiDocument(content);
|
||||
const isConf = IsConfigurationDocument(content);
|
||||
return await isSwag || await isConf;
|
||||
}
|
||||
} catch { }
|
||||
|
@ -307,18 +376,26 @@ export class OpenApiLanugageService extends TextDocuments implements IFileSystem
|
|||
}
|
||||
public async toJSON(contentOrUri: string): Promise<string> {
|
||||
try {
|
||||
return IsUri(contentOrUri) ? await AutoRest.LiterateToJson(await this.ReadFile(contentOrUri)) : await AutoRest.LiterateToJson(contentOrUri);
|
||||
return IsUri(contentOrUri) ? await LiterateToJson(await this.ReadFile(contentOrUri)) : await LiterateToJson(contentOrUri);
|
||||
} catch { }
|
||||
return "";
|
||||
}
|
||||
public async findConfigurationFile(documentUri: string): Promise<string> {
|
||||
return await AutoRest.DetectConfigurationFile(this, documentUri, true) || "";
|
||||
|
||||
public async detectConfigurationFile(documentUri: string): Promise<string> {
|
||||
return await this.getConfiguration(documentUri, false);
|
||||
}
|
||||
|
||||
public setStatus(message: string) {
|
||||
this.connection.sendNotification("status", message);
|
||||
}
|
||||
|
||||
public startActivity(id: string, title: string, message: string) {
|
||||
this.connection.sendNotification("startActivity", { id: id, title: title, message: message });
|
||||
}
|
||||
|
||||
public endActivity(id: string) {
|
||||
this.connection.sendNotification("endActivity", id);
|
||||
}
|
||||
private async onSettingsChanged(serviceSettings: any) {
|
||||
// snapshot the current autorest configuration from the client
|
||||
const hash = md5(this.settings.configuration);
|
||||
|
@ -355,7 +432,7 @@ export class OpenApiLanugageService extends TextDocuments implements IFileSystem
|
|||
const config = await this.getConfiguration(documentUri);
|
||||
const result = this.results.get(config);
|
||||
if (result) {
|
||||
await result.ready; // wait for any current process to finish.
|
||||
await result.busy; // wait for any current process to finish.
|
||||
const outputs = result.artifacts;
|
||||
const openapiDefinition = From(outputs).Where(x => x.type === "swagger-document.json").Select(x => JSON.parse(x.content)).FirstOrDefault();
|
||||
const openapiDefinitionMap = From(outputs).Where(x => x.type === "swagger-document.json.map").Select(x => JSON.parse(x.content)).FirstOrDefault();
|
||||
|
@ -467,7 +544,7 @@ export class OpenApiLanugageService extends TextDocuments implements IFileSystem
|
|||
}
|
||||
|
||||
private async onFileEvents(changes: FileEvent[]) {
|
||||
this.debug(`onFileEvents: ${changes}`);
|
||||
this.debug(`onFileEvents: ${JSON.stringify(changes, null, " ")}`);
|
||||
for (const each of changes) {
|
||||
|
||||
const doc = this.get(each.uri);
|
||||
|
@ -498,7 +575,13 @@ export class OpenApiLanugageService extends TextDocuments implements IFileSystem
|
|||
const folderPath = FileUriToPath(folderUri);
|
||||
if (await isDirectory(folderPath)) {
|
||||
const items = await readdir(folderPath);
|
||||
return From<string>(items).Where(each => AutoRest.IsConfigurationExtension(GetExtension(each))).Select(each => ResolveUri(folderUri, each)).ToArray();
|
||||
const results = new Array<string>();
|
||||
for (const each of items) {
|
||||
if (await IsConfigurationExtension(GetExtension(each))) {
|
||||
results.push(ResolveUri(folderUri, each));
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -511,7 +594,7 @@ export class OpenApiLanugageService extends TextDocuments implements IFileSystem
|
|||
if (doc) {
|
||||
return doc.getText();
|
||||
}
|
||||
const content = await readFile(FileUriToPath(fileUri));
|
||||
const content = await readFile(decodeURIComponent(FileUriToPath(fileUri)));
|
||||
return content;
|
||||
} catch {
|
||||
}
|
||||
|
@ -529,7 +612,7 @@ export class OpenApiLanugageService extends TextDocuments implements IFileSystem
|
|||
await result.process();
|
||||
}
|
||||
|
||||
private async getConfiguration(documentUri: string): Promise<string> {
|
||||
private async getConfiguration(documentUri: string, generateFake: boolean = true): Promise<string> {
|
||||
// let folder = ResolveUri(documentUri, ".");
|
||||
let configFiles = await Configuration.DetectConfigurationFiles(this, documentUri, undefined, true);
|
||||
|
||||
|
@ -575,14 +658,15 @@ export class OpenApiLanugageService extends TextDocuments implements IFileSystem
|
|||
private async onDocumentChanged(document: TextDocument) {
|
||||
this.debug(`onDocumentChanged: ${document.uri}`);
|
||||
|
||||
if (AutoRest.IsSwaggerExtension(document.languageId) && await AutoRest.IsSwaggerFile(document.getText())) {
|
||||
|
||||
if (await IsOpenApiExtension(document.languageId) && await IsOpenApiDocument(document.getText())) {
|
||||
// find the configuration file and activate that.
|
||||
this.process(await this.getConfiguration(document.uri));
|
||||
return;
|
||||
}
|
||||
|
||||
// is this a config file?
|
||||
if (AutoRest.IsConfigurationExtension(document.languageId) && await AutoRest.IsConfigurationFile(document.getText())) {
|
||||
if (await IsConfigurationExtension(document.languageId) && await IsConfigurationDocument(document.getText())) {
|
||||
this.process(document.uri);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
|
||||
import { RawSourceMap, SourceMapConsumer } from "source-map";
|
||||
|
||||
export type JsonPath = (number | string)[];
|
||||
/* @internal */ export type JsonPath = (number | string)[];
|
||||
|
||||
export class SourceMap {
|
||||
/* @internal */ export class SourceMap {
|
||||
private consumer: SourceMapConsumer;
|
||||
|
||||
public constructor(map: RawSourceMap) {
|
||||
|
|
|
@ -10,7 +10,7 @@ import { AutoRestConfigurationImpl } from "./lib/configuration";
|
|||
|
||||
const regexLegacyArg = /^-[^-]/;
|
||||
|
||||
export function isLegacy(args: string[]): boolean {
|
||||
/* @internal */ export function isLegacy(args: string[]): boolean {
|
||||
return args.some(arg => regexLegacyArg.test(arg));
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ async function ParseCompositeSwagger(inputScope: DataSource, uri: string, target
|
|||
targetConfig["override-info"] = data.info;
|
||||
}
|
||||
|
||||
export async function CreateConfiguration(baseFolderUri: string, inputScope: DataSource, args: string[]): Promise<AutoRestConfigurationImpl> {
|
||||
/* @internal */ export async function CreateConfiguration(baseFolderUri: string, inputScope: DataSource, args: string[]): Promise<AutoRestConfigurationImpl> {
|
||||
let result: AutoRestConfigurationImpl = {
|
||||
"input-file": []
|
||||
};
|
||||
|
|
|
@ -14,84 +14,14 @@ import { Message, Channel } from "./message";
|
|||
import * as Constants from "./constants";
|
||||
import { Artifact } from "./artifact";
|
||||
import { homedir } from "os"
|
||||
import { DocumentType } from "./document-type";
|
||||
|
||||
/**
|
||||
* An instance of the AutoRest generator.
|
||||
*
|
||||
* Note: to create an instance of autore
|
||||
*/
|
||||
export class AutoRest extends EventEmitter {
|
||||
/**
|
||||
* Given a file's content, does this represent a swagger file of some sort?
|
||||
*
|
||||
* @param content - the file content to evaluate
|
||||
*/
|
||||
public static async IsSwaggerFile(content: string): Promise<boolean> {
|
||||
// this checks to see if the document is a swagger document
|
||||
try {
|
||||
// quick check to see if it's json already
|
||||
let doc = JSON.parse(content);
|
||||
return (doc && doc.swagger && doc.swagger === "2.0")
|
||||
} catch (e) {
|
||||
try {
|
||||
// maybe it's yaml or literate swagger
|
||||
let doc = JSON.parse(await AutoRest.LiterateToJson(content));
|
||||
return (doc && doc.swagger && doc.swagger === "2.0")
|
||||
} catch (e) {
|
||||
// nope
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static async LiterateToJson(content: string): Promise<string> {
|
||||
try {
|
||||
let autorest = new AutoRest({
|
||||
EnumerateFileUris: async function (folderUri: string): Promise<Array<string>> { return []; },
|
||||
ReadFile: async (f: string): Promise<string> => f == "none:///empty-file.md" ? content || "# empty file" : "# empty file"
|
||||
});
|
||||
let result = "";
|
||||
autorest.AddConfiguration({ "input-file": "none:///empty-file.md", "output-artifact": ["swagger-document"] });
|
||||
autorest.GeneratedFile.Subscribe((source, artifact) => {
|
||||
result = artifact.content;
|
||||
});
|
||||
// run autorest and wait.
|
||||
|
||||
await (await autorest.Process()).finish;
|
||||
return result;
|
||||
} catch (x) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public static async IsConfigurationFile(content: string): Promise<boolean> {
|
||||
// this checks to see if the document is an autorest markdown configuration file
|
||||
return content.indexOf(Constants.MagicString) > -1;
|
||||
}
|
||||
|
||||
public static IsConfigurationExtension(extension: string): boolean {
|
||||
switch (extension) {
|
||||
case "markdown":
|
||||
case "md":
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static IsSwaggerExtension(extension: string): boolean {
|
||||
switch (extension) {
|
||||
case "yaml":
|
||||
case "yml":
|
||||
case "markdown":
|
||||
case "md":
|
||||
case "json":
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static async DetectConfigurationFile(fileSystem: IFileSystem, documentPath?: string, walkUpFolders?: boolean): Promise<string | null> {
|
||||
return Configuration.DetectConfigurationFile(fileSystem, (documentPath || null), undefined, walkUpFolders);
|
||||
}
|
||||
|
||||
/**
|
||||
* Event: Signals when a Process() finishes.
|
||||
*/
|
||||
|
@ -116,7 +46,7 @@ export class AutoRest extends EventEmitter {
|
|||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @internal
|
||||
* @param fileSystem The implementation of the filesystem to load and save files from the host application.
|
||||
* @param configFileOrFolderUri The URI of the configuration file or folder containing the configuration file. Is null if no configuration file should be looked for.
|
||||
*/
|
||||
|
@ -126,9 +56,6 @@ export class AutoRest extends EventEmitter {
|
|||
process.env["autorest.home"] = process.env["autorest.home"] || homedir();
|
||||
}
|
||||
|
||||
public static create(fileSystem?: IFileSystem, configFileOrFolderUri?: string) {
|
||||
return new AutoRest(fileSystem, configFileOrFolderUri);
|
||||
}
|
||||
public async RegenerateView(includeDefault: boolean = false): Promise<ConfigurationView> {
|
||||
this.Invalidate();
|
||||
const messageEmitter = new MessageEmitter();
|
||||
|
@ -141,10 +68,6 @@ export class AutoRest extends EventEmitter {
|
|||
return this._view = await new Configuration(this.fileSystem, this.configFileOrFolderUri).CreateView(messageEmitter, includeDefault, ...this._configurations);
|
||||
}
|
||||
|
||||
public static async Shutdown() {
|
||||
await Configuration.shutdown();
|
||||
}
|
||||
|
||||
public Invalidate() {
|
||||
if (this._view) {
|
||||
this._view.messageEmitter.removeAllListeners();
|
||||
|
@ -163,13 +86,6 @@ export class AutoRest extends EventEmitter {
|
|||
this.Invalidate();
|
||||
}
|
||||
|
||||
public get HasConfiguration(): Promise<boolean> {
|
||||
return new Promise<boolean>(async (r, f) => {
|
||||
await this.view;
|
||||
r(false);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Called to start processing of the files.
|
||||
*/
|
||||
|
@ -237,3 +153,132 @@ export class AutoRest extends EventEmitter {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Determines the document type based on the content of the document
|
||||
*
|
||||
* @returns Promise<DocumentType> one of:
|
||||
* - DocumentType.LiterateConfiguration - contains the magic string '\n> see https://aka.ms/autorest'
|
||||
* - DocumentType.OpenAPI2 - $.swagger === "2.0"
|
||||
* - DocumentType.OpenAPI3 - $.openapi === "3.0"
|
||||
* - DocumentType.Unknown - content does not match a known document type
|
||||
*
|
||||
* @see {@link DocumentType}
|
||||
*/
|
||||
export async function IdentifyDocument(content: string): Promise<DocumentType> {
|
||||
if (content) {
|
||||
|
||||
// check for configuratuion
|
||||
if (await IsConfigurationDocument(content)) {
|
||||
return DocumentType.LiterateConfiguration;
|
||||
}
|
||||
|
||||
// check for openapi document
|
||||
let doc: any;
|
||||
try {
|
||||
// quick check to see if it's json already
|
||||
doc = JSON.parse(content);
|
||||
} catch (e) {
|
||||
try {
|
||||
// maybe it's yaml or literate openapip
|
||||
doc = JSON.parse(await LiterateToJson(content));
|
||||
|
||||
} catch (e) {
|
||||
// nope
|
||||
}
|
||||
}
|
||||
if (doc) {
|
||||
return (doc.swagger && doc.swagger === "2.0") ? DocumentType.OpenAPI2 :
|
||||
(doc.openapi && doc.openapi === "3.0") ? DocumentType.OpenAPI3 :
|
||||
DocumentType.Unknown;
|
||||
}
|
||||
}
|
||||
return DocumentType.Unknown;
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes a document (yaml, markdown or JSON) and returns the document as a JSON-encoded document text
|
||||
* @param content - the document content
|
||||
*
|
||||
* @returns the content as a JSON string (not a JSON DOM)
|
||||
*/
|
||||
export async function LiterateToJson(content: string): Promise<string> {
|
||||
try {
|
||||
let autorest = new AutoRest({
|
||||
EnumerateFileUris: async function (folderUri: string): Promise<Array<string>> { return []; },
|
||||
ReadFile: async (f: string): Promise<string> => f == "none:///empty-file.md" ? content || "# empty file" : "# empty file"
|
||||
});
|
||||
let result = "";
|
||||
autorest.AddConfiguration({ "input-file": "none:///empty-file.md", "output-artifact": ["swagger-document"] });
|
||||
autorest.GeneratedFile.Subscribe((source, artifact) => {
|
||||
result = artifact.content;
|
||||
});
|
||||
// run autorest and wait.
|
||||
|
||||
await (await autorest.Process()).finish;
|
||||
return result;
|
||||
} catch (x) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if the document is a literate configuation document.
|
||||
*
|
||||
* @param content the document content to check
|
||||
*/
|
||||
export async function IsConfigurationDocument(content: string): Promise<boolean> {
|
||||
// this checks to see if the document is an autorest markdown configuration document
|
||||
return content.indexOf(Constants.MagicString) > -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a document's content, does this represent a openapi document of some sort?
|
||||
*
|
||||
* @param content - the document content to evaluate
|
||||
*/
|
||||
export async function IsOpenApiDocument(content: string): Promise<boolean> {
|
||||
switch (await IdentifyDocument(content)) {
|
||||
case DocumentType.OpenAPI2:
|
||||
case DocumentType.OpenAPI3:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shuts down any active autorest extension processes.
|
||||
*/
|
||||
export async function Shutdown() {
|
||||
await Configuration.shutdown();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the file extension is a known file extension for a literate configuration document.
|
||||
* @param extension the extension to check (no leading dot)
|
||||
*/
|
||||
export async function IsConfigurationExtension(extension: string): Promise<boolean> {
|
||||
switch (extension) {
|
||||
case "markdown":
|
||||
case "md":
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the file extension is a known file extension for a OpenAPI document (yaml/json/literate markdown).
|
||||
* @param extension the extension to check (no leading dot)
|
||||
*/
|
||||
export async function IsOpenApiExtension(extension: string): Promise<boolean> {
|
||||
switch (extension) {
|
||||
case "yaml":
|
||||
case "yml":
|
||||
case "markdown":
|
||||
case "md":
|
||||
case "json":
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -189,7 +189,7 @@ function ProxifyConfigurationView(cfgView: any) {
|
|||
}
|
||||
|
||||
const loadedExtensions: { [fullyQualified: string]: { extension: Extension, autorestExtension: LazyPromise<AutoRestExtension> } } = {};
|
||||
export async function GetExtension(fullyQualified: string): Promise<AutoRestExtension> {
|
||||
/*@internal*/ export async function GetExtension(fullyQualified: string): Promise<AutoRestExtension> {
|
||||
return await loadedExtensions[fullyQualified].autorestExtension;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,13 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
export enum DocumentType {
|
||||
OpenAPI2 = <any>"OpenAPI2",
|
||||
OpenAPI3 = <any>"OpenAPI3",
|
||||
LiterateConfiguration = <any>"LiterateConfiguration",
|
||||
Unknown = <any>"Unknown"
|
||||
}
|
||||
|
||||
export enum DocumentFormat {
|
||||
Markdown = <any>"markdown",
|
||||
Yaml = <any>"yaml",
|
||||
Json = <any>"json",
|
||||
|
@ -11,11 +18,11 @@ export enum DocumentType {
|
|||
}
|
||||
|
||||
export const DocumentExtension = {
|
||||
"yaml": DocumentType.Yaml,
|
||||
"yml": DocumentType.Yaml,
|
||||
"json": DocumentType.Json,
|
||||
"md": DocumentType.Markdown,
|
||||
"markdown": DocumentType.Markdown
|
||||
"yaml": DocumentFormat.Yaml,
|
||||
"yml": DocumentFormat.Yaml,
|
||||
"json": DocumentFormat.Json,
|
||||
"md": DocumentFormat.Markdown,
|
||||
"markdown": DocumentFormat.Markdown
|
||||
}
|
||||
|
||||
export const DocumentPatterns = {
|
||||
|
|
|
@ -5,13 +5,30 @@
|
|||
|
||||
import { EnhancedPosition, Position } from "./ref/source-map";
|
||||
|
||||
|
||||
/**
|
||||
* The Channel that a message is registered with.
|
||||
*/
|
||||
export enum Channel {
|
||||
/** Information is considered the mildest of responses; not necesarily actionable. */
|
||||
Information = <any>"information",
|
||||
|
||||
/** Warnings are considered important for best practices, but not catastrophic in nature. */
|
||||
Warning = <any>"warning",
|
||||
|
||||
/** Errors are considered blocking issues that block a successful operation. */
|
||||
Error = <any>"error",
|
||||
|
||||
/** Debug messages are designed for the developer to communicate internal autorest implementation details. */
|
||||
Debug = <any>"debug",
|
||||
|
||||
/** Verbose messages give the user additional clarity on the process. */
|
||||
Verbose = <any>"verbose",
|
||||
|
||||
/** Catastrophic failure, likely abending the process. */
|
||||
Fatal = <any>"fatal",
|
||||
|
||||
/** Hint messages offer guidance or support without forcing action. */
|
||||
Hint = <any>"hint",
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
import { DataHandle, DataSink } from '../data-store/data-store';
|
||||
const convertOAI2toOAI3 = async (oa2def: OpenApi2Definition): Promise<OpenApi3Definition> => (await require("swagger2openapi").convert(oa2def, { patch: true })).openapi;
|
||||
|
||||
export async function ConvertOAI2toOAI3(input: DataHandle, sink: DataSink): Promise<DataHandle> {
|
||||
/* @internal */ export async function ConvertOAI2toOAI3(input: DataHandle, sink: DataSink): Promise<DataHandle> {
|
||||
const oa2 = input.ReadObject<OpenApi2Definition>();
|
||||
const oa3 = await convertOAI2toOAI3(oa2);
|
||||
return await sink.WriteObject("OpenAPI", oa3);
|
||||
|
|
|
@ -61,9 +61,6 @@ function* ParseCodeblocks(markdown: string): Iterable<commonmark.Node> {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
const commonmarkHeadingNodeType = "heading";
|
||||
const commonmarkHeadingMaxLevel = 1000;
|
||||
|
||||
|
|
|
@ -2,15 +2,22 @@
|
|||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as fs from "fs";
|
||||
import * as path from "path";
|
||||
import * as promisify from "pify";
|
||||
|
||||
export const mkdir: (path: string | Buffer) => Promise<void> = promisify(fs.mkdir);
|
||||
export const exists: (path: string | Buffer) => Promise<boolean> = path => Promise.resolve(fs.existsSync(path)); // async one deprecated! (TODO: replace with call to stat)
|
||||
export const readdir: (path: string | Buffer) => Promise<Array<string>> = promisify(fs.readdir);
|
||||
export const close: (fd: number) => Promise<void> = promisify(fs.close);
|
||||
export const readFile: (filename: string) => Promise<string> = promisify(fs.readFile);
|
||||
export const writeFile: (filename: string, content: string) => Promise<void> = (filename, content) => Promise.resolve(fs.writeFileSync(filename, content)); // for some reason writeFile only produced empty files
|
||||
export function mkdir(path: string | Buffer): Promise<void> {
|
||||
return new Promise((r, j) => fs.mkdir(path, (err) => err ? j(err) : r()))
|
||||
}
|
||||
export const exists: (path: string | Buffer) => Promise<boolean> = path => new Promise<boolean>((r, j) => fs.stat(path, (err: NodeJS.ErrnoException, stats: fs.Stats) => err ? r(false) : r(true)));
|
||||
|
||||
export function readdir(path: string): Promise<Array<string>> {
|
||||
return new Promise((r, j) => fs.readdir(path, (err, files) => err ? j(err) : r(files)));
|
||||
}
|
||||
export function close(fd: number): Promise<void> {
|
||||
return new Promise((r, j) => fs.close(fd, (err) => err ? j(err) : r()));
|
||||
}
|
||||
export function readFile(path: string, options?: { encoding?: string | null; flag?: string; }): Promise<string | Buffer> {
|
||||
return new Promise((r, j) => fs.readFile(path, options, (err, data) => err ? j(err) : r(data)));
|
||||
}
|
||||
export function writeFile(filename: string, content: string): Promise<void> {
|
||||
return new Promise((r, j) => fs.writeFile(filename, content, (err) => err ? j(err) : r()))
|
||||
}
|
|
@ -3,9 +3,9 @@
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
export { Enumerable, Enumerable as IEnumerable, From } from "linq-es2015";
|
||||
/* @internal */ export { Enumerable, Enumerable as IEnumerable, From } from "linq-es2015";
|
||||
|
||||
export function Push<T>(destination: Array<T>, source: any) {
|
||||
/* @internal */ export function Push<T>(destination: Array<T>, source: any) {
|
||||
if (source) {
|
||||
if (IsIterable(source)) {
|
||||
destination.push(...source);
|
||||
|
@ -15,6 +15,6 @@ export function Push<T>(destination: Array<T>, source: any) {
|
|||
}
|
||||
}
|
||||
|
||||
export function IsIterable(target: any) {
|
||||
/* @internal */ export function IsIterable(target: any) {
|
||||
return target && target[Symbol.iterator] && typeof target !== "string";
|
||||
}
|
|
@ -10,14 +10,16 @@ export function IsUri(uri: string): boolean {
|
|||
/***********************
|
||||
* Data aquisition
|
||||
***********************/
|
||||
import * as promisify from "pify";
|
||||
import { Readable } from "stream";
|
||||
import { parse } from "url";
|
||||
import { sep, extname } from "path";
|
||||
|
||||
const stripBom: (text: string) => string = require("strip-bom");
|
||||
const getUri = require("get-uri");
|
||||
const getUriAsync: (uri: string, options: { headers: { [key: string]: string } }) => Promise<Readable> = promisify(getUri);
|
||||
|
||||
function getUriAsync(uri: string, options: { headers: { [key: string]: string } }): Promise<Readable> {
|
||||
return new Promise((r, j) => getUri(uri, options, (err: any, rs: Readable) => err ? j(err) : r(rs)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads a UTF8 string from given URI.
|
||||
|
|
|
@ -3,10 +3,14 @@
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
// load static module: ${__dirname }/static_modules.fs
|
||||
// load static module: ${__dirname }/static_modules.fs
|
||||
require('./static-loader.js').load(`${__dirname}/static_modules.fs`)
|
||||
|
||||
export { IFileSystem } from "./lib/file-system"
|
||||
export { Message, Channel } from "./lib/message"
|
||||
export { AutoRest, ConfigurationView } from "./lib/autorest-core"
|
||||
export { DocumentType, DocumentExtension, DocumentPatterns } from "./lib/document-type"
|
||||
export { Artifact } from "./lib/artifact"
|
||||
export { AutoRest, ConfigurationView, IdentifyDocument, IsConfigurationExtension, IsConfigurationDocument, IsOpenApiExtension, LiterateToJson, IsOpenApiDocument } from "./lib/autorest-core"
|
||||
export { DocumentFormat, DocumentExtension, DocumentPatterns, DocumentType } from "./lib/document-type"
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -24,11 +24,12 @@
|
|||
"autorest-language-service": "dist/language-service/language-service.js"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "./node_modules/.bin/mocha ./dist/test --timeout 0",
|
||||
"build": "tsc -p .",
|
||||
"test": "./node_modules/.bin/mocha ./dist/test --timeout 500000",
|
||||
"build": "tsc -p . & dts-generator --name autorest-core --project . --out ../autorest/interfaces/autorest-core.d.ts --exclude \"test/**/*\" --exclude \"node_modules/**/*.d.ts\" --exclude \"lib/source-map/**\" --exclude \"lib/pipeline/**\" --exclude \"lib/parsing/**\" --exclude \"lib/data-store/**\" --exclude \"lib/ref/yaml.ts\" --extern ./source-maps.d.ts",
|
||||
"static-link": "static-link",
|
||||
"postinstall": "node ./post-install --force",
|
||||
"prepublishonly": "static-link --force & gulp build"
|
||||
"reinstall": "shx rm ./package-lock.json && shx rm -rf ./node_modules && npm install",
|
||||
"prepack": "static-link & npm run build"
|
||||
},
|
||||
"typings": "./dist/main.d.ts",
|
||||
"devDependencies": {
|
||||
|
@ -36,12 +37,13 @@
|
|||
"@types/js-yaml": "^3.5.31",
|
||||
"@types/jsonpath": "^0.1.29",
|
||||
"@types/node": "^8.0.28",
|
||||
"@types/pify": "0.0.28",
|
||||
"@types/source-map": "^0.5.0",
|
||||
"@types/yargs": "^8.0.2",
|
||||
"dts-generator": "^2.1.0",
|
||||
"mocha": "^4.0.1",
|
||||
"shx": "0.2.2",
|
||||
"mocha-typescript": "^1.1.7",
|
||||
"static-link": "^0.2.0"
|
||||
"static-link": "^0.2.2"
|
||||
},
|
||||
"static-link": {
|
||||
"entrypoints": [],
|
||||
|
@ -55,7 +57,6 @@
|
|||
"get-uri": "^2.0.0",
|
||||
"jsonpath": "1.0.0",
|
||||
"linq-es2015": "^2.4.25",
|
||||
"pify": "^3.0.0",
|
||||
"safe-eval": "^0.3.0",
|
||||
"source-map": "^0.5.6",
|
||||
"strip-bom": "^3.0.0",
|
||||
|
|
|
@ -13,7 +13,7 @@ if (process.argv.indexOf("--no-upgrade-check") != -1) {
|
|||
import { isFile } from "@microsoft.azure/async-io";
|
||||
import { cli, enhanceConsole } from "@microsoft.azure/console";
|
||||
import { Exception, LazyPromise } from "@microsoft.azure/polyfill";
|
||||
import { Enumerable as IEnumerable, From } from "./lib/ref/linq";
|
||||
import { Enumerable as IEnumerable, From } from "linq-es2015";
|
||||
import { networkEnabled, rootFolder, extensionManager, availableVersions, corePackage, installedCores, tryRequire, resolvePathForLocalVersion, ensureAutorestHome, selectVersion, pkgVersion } from "./autorest-as-a-service"
|
||||
import { gt } from "semver";
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ import { lookup } from "dns";
|
|||
import { Extension, ExtensionManager } from "@microsoft.azure/extension";
|
||||
import { homedir } from "os";
|
||||
import { dirname, join, resolve } from "path";
|
||||
import { Enumerable as IEnumerable, From } from "./lib/ref/linq";
|
||||
import { Enumerable as IEnumerable, From } from "linq-es2015";
|
||||
import { Exception, LazyPromise } from "@microsoft.azure/polyfill";
|
||||
|
||||
import * as semver from "semver";
|
||||
|
|
|
@ -0,0 +1,554 @@
|
|||
/// <reference path="./source-maps.d.ts" />
|
||||
declare module 'autorest-core/lib/artifact' {
|
||||
export interface Artifact {
|
||||
uri: string;
|
||||
type: string;
|
||||
content: string;
|
||||
}
|
||||
|
||||
}
|
||||
declare module 'autorest-core/lib/constants' {
|
||||
export const MagicString: string;
|
||||
export const DefaultConfiguration: string;
|
||||
|
||||
}
|
||||
declare module 'autorest-core/lib/ref/safe-eval' {
|
||||
export const safeEval: <T>(expression: string, context?: any) => T;
|
||||
|
||||
}
|
||||
declare module 'autorest-core/lib/ref/jsonpath' {
|
||||
import * as jsonpath from "jsonpath";
|
||||
export type JsonPathComponent = jsonpath.PathComponent;
|
||||
export type JsonPath = JsonPathComponent[];
|
||||
export function parse(jsonPath: string): JsonPath;
|
||||
export function stringify(jsonPath: JsonPath): string;
|
||||
export function paths<T>(obj: T, jsonQuery: string): JsonPath[];
|
||||
export function nodes<T>(obj: T, jsonQuery: string): {
|
||||
path: JsonPath;
|
||||
value: any;
|
||||
}[];
|
||||
export function IsPrefix(prefix: JsonPath, path: JsonPath): boolean;
|
||||
export function CreateObject(jsonPath: JsonPath, leafObject: any): any;
|
||||
export function matches(jsonQuery: string, jsonPath: JsonPath): boolean;
|
||||
|
||||
}
|
||||
declare module 'autorest-core/lib/lazy' {
|
||||
export class Lazy<T> {
|
||||
private factory;
|
||||
private promise;
|
||||
constructor(factory: () => T);
|
||||
readonly Value: T;
|
||||
}
|
||||
export class LazyPromise<T> implements PromiseLike<T> {
|
||||
private factory;
|
||||
private promise;
|
||||
constructor(factory: () => Promise<T>);
|
||||
private readonly Value;
|
||||
readonly hasValue: boolean;
|
||||
then<TResult1, TResult2>(onfulfilled: (value: T) => TResult1 | PromiseLike<TResult1>, onrejected: (reason: any) => TResult2 | PromiseLike<TResult2>): PromiseLike<TResult1 | TResult2>;
|
||||
}
|
||||
|
||||
}
|
||||
declare module 'autorest-core/lib/exception' {
|
||||
export class Exception extends Error {
|
||||
exitCode: number;
|
||||
constructor(message: string, exitCode?: number);
|
||||
}
|
||||
export class OperationCanceledException extends Exception {
|
||||
exitCode: number;
|
||||
constructor(message?: string, exitCode?: number);
|
||||
}
|
||||
export class OutstandingTaskAlreadyCompletedException extends Exception {
|
||||
constructor();
|
||||
}
|
||||
export class OperationAbortedException extends Exception {
|
||||
constructor();
|
||||
}
|
||||
|
||||
}
|
||||
declare module 'autorest-core/lib/outstanding-task-awaiter' {
|
||||
export class OutstandingTaskAwaiter {
|
||||
private locked;
|
||||
private outstandingTasks;
|
||||
Wait(): Promise<void>;
|
||||
Await<T>(task: Promise<T>): Promise<T>;
|
||||
}
|
||||
|
||||
}
|
||||
declare module 'autorest-core/lib/events' {
|
||||
/// <reference types="node" />
|
||||
import * as events from "events";
|
||||
export interface IEvent<TSender extends events.EventEmitter, TArgs> {
|
||||
Subscribe(fn: (sender: TSender, args: TArgs) => void): () => void;
|
||||
Unsubscribe(fn: (sender: TSender, args: TArgs) => void): void;
|
||||
Dispatch(args: TArgs): void;
|
||||
}
|
||||
export class EventDispatcher<TSender extends EventEmitter, TArgs> implements IEvent<TSender, TArgs> {
|
||||
private _instance;
|
||||
private _name;
|
||||
private _subscriptions;
|
||||
constructor(instance: TSender, name: string);
|
||||
UnsubscribeAll(): void;
|
||||
Subscribe(fn: (sender: TSender, args: TArgs) => void): () => void;
|
||||
Unsubscribe(fn: (sender: TSender, args: TArgs) => void): void;
|
||||
Dispatch(args: TArgs): void;
|
||||
}
|
||||
export class EventEmitter extends events.EventEmitter {
|
||||
private _subscriptions;
|
||||
constructor();
|
||||
protected static Event<TSender extends EventEmitter, TArgs>(target: TSender, propertyKey: string): void;
|
||||
protected _init(t: EventEmitter): void;
|
||||
}
|
||||
|
||||
}
|
||||
declare module 'autorest-core/lib/ref/source-map' {
|
||||
export { Position } from "source-map";
|
||||
import { Position } from "source-map";
|
||||
export { RawSourceMap } from "source-map";
|
||||
import { JsonPath } from 'autorest-core/lib/ref/jsonpath';
|
||||
export interface PositionEnhancements {
|
||||
path?: JsonPath;
|
||||
length?: number;
|
||||
valueOffset?: number;
|
||||
valueLength?: number;
|
||||
}
|
||||
export type EnhancedPosition = Position & PositionEnhancements;
|
||||
export type SmartPosition = Position | {
|
||||
path: JsonPath;
|
||||
};
|
||||
export interface Mapping {
|
||||
generated: SmartPosition;
|
||||
original: SmartPosition;
|
||||
source: string;
|
||||
name?: string;
|
||||
}
|
||||
export type Mappings = Array<Mapping>;
|
||||
|
||||
}
|
||||
declare module 'autorest-core/lib/ref/cancellation' {
|
||||
export { CancellationToken, CancellationTokenSource } from "vscode-jsonrpc";
|
||||
|
||||
}
|
||||
declare module 'autorest-core/lib/ref/jsonrpc' {
|
||||
export * from "vscode-jsonrpc";
|
||||
|
||||
}
|
||||
declare module 'autorest-core/lib/message' {
|
||||
import { EnhancedPosition, Position } from 'autorest-core/lib/ref/source-map';
|
||||
/**
|
||||
* The Channel that a message is registered with.
|
||||
*/
|
||||
export enum Channel {
|
||||
/** Information is considered the mildest of responses; not necesarily actionable. */
|
||||
Information,
|
||||
/** Warnings are considered important for best practices, but not catastrophic in nature. */
|
||||
Warning,
|
||||
/** Errors are considered blocking issues that block a successful operation. */
|
||||
Error,
|
||||
/** Debug messages are designed for the developer to communicate internal autorest implementation details. */
|
||||
Debug,
|
||||
/** Verbose messages give the user additional clarity on the process. */
|
||||
Verbose,
|
||||
/** Catastrophic failure, likely abending the process. */
|
||||
Fatal,
|
||||
/** Hint messages offer guidance or support without forcing action. */
|
||||
Hint,
|
||||
}
|
||||
export interface SourceLocation {
|
||||
document: string;
|
||||
Position: EnhancedPosition;
|
||||
}
|
||||
export interface Range {
|
||||
document: string;
|
||||
start: Position;
|
||||
end: Position;
|
||||
}
|
||||
export interface Message {
|
||||
Channel: Channel;
|
||||
Key?: Iterable<string>;
|
||||
Details?: any;
|
||||
Text: string;
|
||||
Source?: Array<SourceLocation>;
|
||||
Range?: Iterable<Range>;
|
||||
Plugin?: string;
|
||||
FormattedMessage?: string;
|
||||
}
|
||||
|
||||
}
|
||||
declare module 'autorest-core/lib/ref/array' {
|
||||
export function pushAll<T>(target: T[], source: T[]): void;
|
||||
|
||||
}
|
||||
declare module 'autorest-core/lib/ref/commonmark' {
|
||||
export { Node, Parser } from "commonmark";
|
||||
|
||||
}
|
||||
declare module 'autorest-core/lib/ref/async' {
|
||||
/// <reference types="node" />
|
||||
export function mkdir(path: string | Buffer): Promise<void>;
|
||||
export const exists: (path: string | Buffer) => Promise<boolean>;
|
||||
export function readdir(path: string): Promise<Array<string>>;
|
||||
export function close(fd: number): Promise<void>;
|
||||
export function readFile(path: string, options?: {
|
||||
encoding?: string | null;
|
||||
flag?: string;
|
||||
}): Promise<string | Buffer>;
|
||||
export function writeFile(filename: string, content: string): Promise<void>;
|
||||
|
||||
}
|
||||
declare module 'autorest-core/lib/ref/uri' {
|
||||
export function IsUri(uri: string): boolean;
|
||||
/**
|
||||
* Loads a UTF8 string from given URI.
|
||||
*/
|
||||
export function ReadUri(uri: string, headers?: {
|
||||
[key: string]: string;
|
||||
}): Promise<string>;
|
||||
export function ExistsUri(uri: string): Promise<boolean>;
|
||||
/**
|
||||
* Create a 'file:///' URI from given absolute path.
|
||||
* Examples:
|
||||
* - "C:\swagger\storage.yaml" -> "file:///C:/swagger/storage.yaml"
|
||||
* - "/input/swagger.yaml" -> "file:///input/swagger.yaml"
|
||||
*/
|
||||
export function CreateFileOrFolderUri(absolutePath: string): string;
|
||||
export function CreateFileUri(absolutePath: string): string;
|
||||
export function CreateFolderUri(absolutePath: string): string;
|
||||
export function EnsureIsFolderUri(uri: string): string;
|
||||
export function EnsureIsFileUri(uri: string): string;
|
||||
export function GetFilename(uri: string): string;
|
||||
export function GetFilenameWithoutExtension(uri: string): string;
|
||||
export function ToRawDataUrl(uri: string): string;
|
||||
/**
|
||||
* The singularity of all resolving.
|
||||
* With URI as our one data type of truth, this method maps an absolute or relative path or URI to a URI using given base URI.
|
||||
* @param baseUri Absolute base URI
|
||||
* @param pathOrUri Relative/absolute path/URI
|
||||
* @returns Absolute URI
|
||||
*/
|
||||
export function ResolveUri(baseUri: string, pathOrUri: string): string;
|
||||
export function ParentFolderUri(uri: string): string | null;
|
||||
export function MakeRelativeUri(baseUri: string, absoluteUri: string): string;
|
||||
export function EnumerateFiles(folderUri: string, probeFiles?: string[]): Promise<string[]>;
|
||||
/**
|
||||
* Writes string to local file system.
|
||||
* @param fileUri Target file uri.
|
||||
* @param data String to write (encoding: UTF8).
|
||||
*/
|
||||
export function WriteString(fileUri: string, data: string): Promise<void>;
|
||||
export function ClearFolder(folderUri: string): Promise<void>;
|
||||
export function FileUriToPath(fileUri: string): string;
|
||||
export function GetExtension(name: string): string;
|
||||
|
||||
}
|
||||
declare module 'autorest-core/lib/file-system' {
|
||||
export interface IFileSystem {
|
||||
EnumerateFileUris(folderUri: string): Promise<Array<string>>;
|
||||
ReadFile(uri: string): Promise<string>;
|
||||
}
|
||||
export class MemoryFileSystem implements IFileSystem {
|
||||
static readonly DefaultVirtualRootUri: string;
|
||||
private filesByUri;
|
||||
constructor(files: Map<string, string>);
|
||||
readonly Outputs: Map<string, string>;
|
||||
ReadFile(uri: string): Promise<string>;
|
||||
EnumerateFileUris(folderUri?: string): Promise<Array<string>>;
|
||||
WriteFile(uri: string, content: string): Promise<void>;
|
||||
}
|
||||
export class RealFileSystem implements IFileSystem {
|
||||
constructor();
|
||||
EnumerateFileUris(folderUri: string): Promise<string[]>;
|
||||
ReadFile(uri: string): Promise<string>;
|
||||
WriteFile(uri: string, content: string): Promise<void>;
|
||||
}
|
||||
export class EnhancedFileSystem implements IFileSystem {
|
||||
private githubAuthToken;
|
||||
constructor(githubAuthToken?: string | undefined);
|
||||
EnumerateFileUris(folderUri: string): Promise<string[]>;
|
||||
ReadFile(uri: string): Promise<string>;
|
||||
WriteFile(uri: string, content: string): Promise<void>;
|
||||
}
|
||||
|
||||
}
|
||||
declare module 'autorest-core/lib/document-type' {
|
||||
export enum DocumentType {
|
||||
OpenAPI2,
|
||||
OpenAPI3,
|
||||
LiterateConfiguration,
|
||||
Unknown,
|
||||
}
|
||||
export enum DocumentFormat {
|
||||
Markdown,
|
||||
Yaml,
|
||||
Json,
|
||||
Unknown,
|
||||
}
|
||||
export const DocumentExtension: {
|
||||
"yaml": DocumentFormat;
|
||||
"yml": DocumentFormat;
|
||||
"json": DocumentFormat;
|
||||
"md": DocumentFormat;
|
||||
"markdown": DocumentFormat;
|
||||
};
|
||||
export const DocumentPatterns: {
|
||||
yaml: string[];
|
||||
json: string[];
|
||||
markdown: string[];
|
||||
all: string[];
|
||||
};
|
||||
|
||||
}
|
||||
declare module 'autorest-core/lib/autorest-core' {
|
||||
import { IEvent, EventEmitter } from 'autorest-core/lib/events';
|
||||
import { ConfigurationView } from 'autorest-core/lib/configuration';
|
||||
export { ConfigurationView } from 'autorest-core/lib/configuration';
|
||||
import { Message } from 'autorest-core/lib/message';
|
||||
import { Artifact } from 'autorest-core/lib/artifact';
|
||||
import { DocumentType } from 'autorest-core/lib/document-type';
|
||||
/**
|
||||
* An instance of the AutoRest generator.
|
||||
*
|
||||
* Note: to create an instance of autore
|
||||
*/
|
||||
export class AutoRest extends EventEmitter {
|
||||
private fileSystem;
|
||||
configFileOrFolderUri: string | undefined;
|
||||
/**
|
||||
* Event: Signals when a Process() finishes.
|
||||
*/
|
||||
Finished: IEvent<AutoRest, boolean | Error>;
|
||||
/**
|
||||
* Event: Signals when a File is generated
|
||||
*/
|
||||
GeneratedFile: IEvent<AutoRest, Artifact>;
|
||||
/**
|
||||
* Event: Signals when a Folder is supposed to be cleared
|
||||
*/
|
||||
ClearFolder: IEvent<AutoRest, string>;
|
||||
/**
|
||||
* Event: Signals when a message is generated
|
||||
*/
|
||||
Message: IEvent<AutoRest, Message>;
|
||||
private _configurations;
|
||||
private _view;
|
||||
readonly view: Promise<ConfigurationView>;
|
||||
RegenerateView(includeDefault?: boolean): Promise<ConfigurationView>;
|
||||
Invalidate(): void;
|
||||
AddConfiguration(configuration: any): void;
|
||||
ResetConfiguration(): Promise<void>;
|
||||
/**
|
||||
* Called to start processing of the files.
|
||||
*/
|
||||
Process(): {
|
||||
finish: Promise<boolean | Error>;
|
||||
cancel: () => void;
|
||||
};
|
||||
}
|
||||
/** Determines the document type based on the content of the document
|
||||
*
|
||||
* @returns Promise<DocumentType> one of:
|
||||
* - DocumentType.LiterateConfiguration - contains the magic string '\n> see https://aka.ms/autorest'
|
||||
* - DocumentType.OpenAPI2 - $.swagger === "2.0"
|
||||
* - DocumentType.OpenAPI3 - $.openapi === "3.0"
|
||||
* - DocumentType.Unknown - content does not match a known document type
|
||||
*
|
||||
* @see {@link DocumentType}
|
||||
*/
|
||||
export function IdentifyDocument(content: string): Promise<DocumentType>;
|
||||
/**
|
||||
* Processes a document (yaml, markdown or JSON) and returns the document as a JSON-encoded document text
|
||||
* @param content - the document content
|
||||
*
|
||||
* @returns the content as a JSON string (not a JSON DOM)
|
||||
*/
|
||||
export function LiterateToJson(content: string): Promise<string>;
|
||||
/**
|
||||
* Checks to see if the document is a literate configuation document.
|
||||
*
|
||||
* @param content the document content to check
|
||||
*/
|
||||
export function IsConfigurationDocument(content: string): Promise<boolean>;
|
||||
/**
|
||||
* Given a document's content, does this represent a openapi document of some sort?
|
||||
*
|
||||
* @param content - the document content to evaluate
|
||||
*/
|
||||
export function IsOpenApiDocument(content: string): Promise<boolean>;
|
||||
/**
|
||||
* Shuts down any active autorest extension processes.
|
||||
*/
|
||||
export function Shutdown(): Promise<void>;
|
||||
/**
|
||||
* Checks if the file extension is a known file extension for a literate configuration document.
|
||||
* @param extension the extension to check (no leading dot)
|
||||
*/
|
||||
export function IsConfigurationExtension(extension: string): Promise<boolean>;
|
||||
/**
|
||||
* Checks if the file extension is a known file extension for a OpenAPI document (yaml/json/literate markdown).
|
||||
* @param extension the extension to check (no leading dot)
|
||||
*/
|
||||
export function IsOpenApiExtension(extension: string): Promise<boolean>;
|
||||
|
||||
}
|
||||
declare module 'autorest-core/lib/configuration' {
|
||||
import { Artifact } from 'autorest-core/lib/artifact';
|
||||
import { EventEmitter, IEvent } from 'autorest-core/lib/events';
|
||||
import { IFileSystem } from 'autorest-core/lib/file-system';
|
||||
import { Message } from 'autorest-core/lib/message';
|
||||
export interface AutoRestConfigurationImpl {
|
||||
__info?: string | null;
|
||||
"allow-no-input"?: boolean;
|
||||
"input-file"?: string[] | string;
|
||||
"base-folder"?: string;
|
||||
"directive"?: Directive[] | Directive;
|
||||
"declare-directive"?: {
|
||||
[name: string]: string;
|
||||
};
|
||||
"output-artifact"?: string[] | string;
|
||||
"message-format"?: "json";
|
||||
"use-extension"?: {
|
||||
[extensionName: string]: string;
|
||||
};
|
||||
"require"?: string[] | string;
|
||||
"help"?: any;
|
||||
"vscode"?: any;
|
||||
"override-info"?: any;
|
||||
"title"?: any;
|
||||
"description"?: any;
|
||||
"debug"?: boolean;
|
||||
"verbose"?: boolean;
|
||||
"output-file"?: string;
|
||||
"output-folder"?: string;
|
||||
"client-side-validation"?: boolean;
|
||||
"fluent"?: boolean;
|
||||
"azure-arm"?: boolean;
|
||||
"namespace"?: string;
|
||||
"license-header"?: string;
|
||||
"add-credentials"?: boolean;
|
||||
"package-name"?: string;
|
||||
"package-version"?: string;
|
||||
"sync-methods"?: "all" | "essential" | "none";
|
||||
"payload-flattening-threshold"?: number;
|
||||
"openapi-type"?: string;
|
||||
}
|
||||
export function MergeConfigurations(...configs: AutoRestConfigurationImpl[]): AutoRestConfigurationImpl;
|
||||
export interface Directive {
|
||||
from?: string[] | string;
|
||||
where?: string[] | string;
|
||||
reason?: string;
|
||||
suppress?: string[] | string;
|
||||
set?: string[] | string;
|
||||
transform?: string[] | string;
|
||||
test?: string[] | string;
|
||||
}
|
||||
export class DirectiveView {
|
||||
private directive;
|
||||
constructor(directive: Directive);
|
||||
readonly from: Iterable<string>;
|
||||
readonly where: Iterable<string>;
|
||||
readonly reason: string | null;
|
||||
readonly suppress: Iterable<string>;
|
||||
readonly set: Iterable<string>;
|
||||
readonly transform: Iterable<string>;
|
||||
readonly test: Iterable<string>;
|
||||
}
|
||||
export class MessageEmitter extends EventEmitter {
|
||||
/**
|
||||
* Event: Signals when a File is generated
|
||||
*/
|
||||
GeneratedFile: IEvent<MessageEmitter, Artifact>;
|
||||
/**
|
||||
* Event: Signals when a Folder is supposed to be cleared
|
||||
*/
|
||||
ClearFolder: IEvent<MessageEmitter, string>;
|
||||
/**
|
||||
* Event: Signals when a message is generated
|
||||
*/
|
||||
Message: IEvent<MessageEmitter, Message>;
|
||||
private cancellationTokenSource;
|
||||
constructor();
|
||||
}
|
||||
export class ConfigurationView {
|
||||
messageEmitter: MessageEmitter;
|
||||
configFileFolderUri: string;
|
||||
[name: string]: any;
|
||||
private suppressor;
|
||||
readonly Keys: Array<string>;
|
||||
Dump(title?: string): void;
|
||||
private config;
|
||||
private rawConfig;
|
||||
private ResolveAsFolder(path);
|
||||
private ResolveAsPath(path);
|
||||
private readonly BaseFolderUri;
|
||||
readonly UseExtensions: Array<{
|
||||
name: string;
|
||||
source: string;
|
||||
fullyQualified: string;
|
||||
}>;
|
||||
readonly IncludedConfigurationFiles: string[];
|
||||
readonly Directives: DirectiveView[];
|
||||
readonly InputFileUris: string[];
|
||||
readonly OutputFolderUri: string;
|
||||
IsOutputArtifactRequested(artifact: string): boolean;
|
||||
GetEntry(key: keyof AutoRestConfigurationImpl): any;
|
||||
readonly Raw: AutoRestConfigurationImpl;
|
||||
readonly DebugMode: boolean;
|
||||
readonly VerboseMode: boolean;
|
||||
GetNestedConfiguration(pluginName: string): Iterable<ConfigurationView>;
|
||||
GetNestedConfigurationImmediate(...scope: any[]): ConfigurationView;
|
||||
Message(m: Message): void;
|
||||
}
|
||||
export class Configuration {
|
||||
private fileSystem;
|
||||
private configFileOrFolderUri;
|
||||
constructor(fileSystem?: IFileSystem, configFileOrFolderUri?: string | undefined);
|
||||
private ParseCodeBlocks(configFile, contextConfig, scope);
|
||||
private extensionManager;
|
||||
private DesugarRawConfig(configs);
|
||||
private DesugarRawConfigs(configs);
|
||||
static shutdown(): Promise<void>;
|
||||
CreateView(messageEmitter: MessageEmitter, includeDefault: boolean, ...configs: Array<any>): Promise<ConfigurationView>;
|
||||
static DetectConfigurationFile(fileSystem: IFileSystem, configFileOrFolderUri: string | null, messageEmitter?: MessageEmitter, walkUpFolders?: boolean): Promise<string | null>;
|
||||
static DetectConfigurationFiles(fileSystem: IFileSystem, configFileOrFolderUri: string | null, messageEmitter?: MessageEmitter, walkUpFolders?: boolean): Promise<Array<string>>;
|
||||
}
|
||||
|
||||
}
|
||||
declare module 'autorest-core/main' {
|
||||
export { IFileSystem } from 'autorest-core/lib/file-system';
|
||||
export { Message, Channel } from 'autorest-core/lib/message';
|
||||
export { Artifact } from 'autorest-core/lib/artifact';
|
||||
export { AutoRest, ConfigurationView, IdentifyDocument, IsConfigurationExtension, IsConfigurationDocument, IsOpenApiExtension, LiterateToJson, IsOpenApiDocument } from 'autorest-core/lib/autorest-core';
|
||||
export { DocumentFormat, DocumentExtension, DocumentPatterns, DocumentType } from 'autorest-core/lib/document-type';
|
||||
|
||||
}
|
||||
declare module 'autorest-core/language-service/language-service' {
|
||||
/**
|
||||
* The results from calling the 'generate' method via the {@link AutoRestLanguageService/generate}
|
||||
*
|
||||
*/
|
||||
export interface GenerationResults {
|
||||
/** the array of messages produced from the run. */
|
||||
messages: Array<string>;
|
||||
/** the collection of outputted files.
|
||||
*
|
||||
* Member keys are the file names
|
||||
* Member values are the file contents
|
||||
*
|
||||
* To Access the files:
|
||||
* for( const filename in generated.files ) {
|
||||
* const content = generated.files[filename];
|
||||
* /// ...
|
||||
* }
|
||||
*/
|
||||
files: Map<string, string>;
|
||||
}
|
||||
|
||||
}
|
||||
declare module 'autorest-core/lib/sleep' {
|
||||
export function Delay(delayMS: number): Promise<void>;
|
||||
|
||||
}
|
||||
interface OpenApi2Definition {
|
||||
}
|
||||
interface OpenApi3Definition {
|
||||
}
|
|
@ -0,0 +1,571 @@
|
|||
declare module "jsonpath" {
|
||||
|
||||
type PathComponent = string | number;
|
||||
|
||||
export function query(obj: any, pathExpression: string): any[];
|
||||
export function paths(obj: any, pathExpression: string): PathComponent[][];
|
||||
export function nodes(obj: any, pathExpression: string): { path: PathComponent[]; value: any; }[];
|
||||
export function value(obj: any, pathExpression: string): any;
|
||||
export function value(obj: any, pathExpression: string, newValue: any): any;
|
||||
export function parent(obj: any, pathExpression: string): any;
|
||||
export function apply(obj: any, pathExpression: string, fn: (x: any) => any): { path: PathComponent[]; value: any; }[];
|
||||
export function parse(pathExpression: string): any[];
|
||||
export function stringify(path: PathComponent[]): string;
|
||||
|
||||
}
|
||||
|
||||
declare module "source-map" {
|
||||
|
||||
export type SourceMapUrl = string;
|
||||
|
||||
export interface StartOfSourceMap {
|
||||
file?: string;
|
||||
sourceRoot?: string;
|
||||
skipValidation?: boolean;
|
||||
}
|
||||
|
||||
export interface RawSourceMap {
|
||||
version: number;
|
||||
sources: string[];
|
||||
names: string[];
|
||||
sourceRoot?: string;
|
||||
sourcesContent?: string[];
|
||||
mappings: string;
|
||||
file: string;
|
||||
}
|
||||
|
||||
export interface RawIndexMap extends StartOfSourceMap {
|
||||
version: number;
|
||||
sections: RawSection[];
|
||||
}
|
||||
|
||||
export interface RawSection {
|
||||
offset: Position;
|
||||
map: RawSourceMap;
|
||||
}
|
||||
|
||||
export interface Position {
|
||||
line: number;
|
||||
column: number;
|
||||
}
|
||||
|
||||
export interface NullablePosition {
|
||||
line: number | null;
|
||||
column: number | null;
|
||||
lastColumn: number | null;
|
||||
}
|
||||
|
||||
export interface MappedPosition {
|
||||
source: string;
|
||||
line: number;
|
||||
column: number;
|
||||
name?: string;
|
||||
}
|
||||
|
||||
export interface NullableMappedPosition {
|
||||
source: string | null;
|
||||
line: number | null;
|
||||
column: number | null;
|
||||
name: string | null;
|
||||
}
|
||||
|
||||
export interface MappingItem {
|
||||
source: string;
|
||||
generatedLine: number;
|
||||
generatedColumn: number;
|
||||
originalLine: number;
|
||||
originalColumn: number;
|
||||
name: string;
|
||||
}
|
||||
|
||||
export interface Mapping {
|
||||
generated: Position;
|
||||
original: Position;
|
||||
source: string;
|
||||
name?: string;
|
||||
}
|
||||
|
||||
export interface CodeWithSourceMap {
|
||||
code: string;
|
||||
map: SourceMapGenerator;
|
||||
}
|
||||
|
||||
export interface SourceMapConsumer {
|
||||
/**
|
||||
* Compute the last column for each generated mapping. The last column is
|
||||
* inclusive.
|
||||
*/
|
||||
computeColumnSpans(): void;
|
||||
|
||||
/**
|
||||
* Returns the original source, line, and column information for the generated
|
||||
* source's line and column positions provided. The only argument is an object
|
||||
* with the following properties:
|
||||
*
|
||||
* - line: The line number in the generated source.
|
||||
* - column: The column number in the generated source.
|
||||
* - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or
|
||||
* 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the
|
||||
* closest element that is smaller than or greater than the one we are
|
||||
* searching for, respectively, if the exact element cannot be found.
|
||||
* Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'.
|
||||
*
|
||||
* and an object is returned with the following properties:
|
||||
*
|
||||
* - source: The original source file, or null.
|
||||
* - line: The line number in the original source, or null.
|
||||
* - column: The column number in the original source, or null.
|
||||
* - name: The original identifier, or null.
|
||||
*/
|
||||
originalPositionFor(generatedPosition: Position & { bias?: number }): NullableMappedPosition;
|
||||
|
||||
/**
|
||||
* Returns the generated line and column information for the original source,
|
||||
* line, and column positions provided. The only argument is an object with
|
||||
* the following properties:
|
||||
*
|
||||
* - source: The filename of the original source.
|
||||
* - line: The line number in the original source.
|
||||
* - column: The column number in the original source.
|
||||
* - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or
|
||||
* 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the
|
||||
* closest element that is smaller than or greater than the one we are
|
||||
* searching for, respectively, if the exact element cannot be found.
|
||||
* Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'.
|
||||
*
|
||||
* and an object is returned with the following properties:
|
||||
*
|
||||
* - line: The line number in the generated source, or null.
|
||||
* - column: The column number in the generated source, or null.
|
||||
*/
|
||||
generatedPositionFor(originalPosition: MappedPosition & { bias?: number }): NullablePosition;
|
||||
|
||||
/**
|
||||
* Returns all generated line and column information for the original source,
|
||||
* line, and column provided. If no column is provided, returns all mappings
|
||||
* corresponding to a either the line we are searching for or the next
|
||||
* closest line that has any mappings. Otherwise, returns all mappings
|
||||
* corresponding to the given line and either the column we are searching for
|
||||
* or the next closest column that has any offsets.
|
||||
*
|
||||
* The only argument is an object with the following properties:
|
||||
*
|
||||
* - source: The filename of the original source.
|
||||
* - line: The line number in the original source.
|
||||
* - column: Optional. the column number in the original source.
|
||||
*
|
||||
* and an array of objects is returned, each with the following properties:
|
||||
*
|
||||
* - line: The line number in the generated source, or null.
|
||||
* - column: The column number in the generated source, or null.
|
||||
*/
|
||||
allGeneratedPositionsFor(originalPosition: MappedPosition): NullablePosition[];
|
||||
|
||||
/**
|
||||
* Return true if we have the source content for every source in the source
|
||||
* map, false otherwise.
|
||||
*/
|
||||
hasContentsOfAllSources(): boolean;
|
||||
|
||||
/**
|
||||
* Returns the original source content. The only argument is the url of the
|
||||
* original source file. Returns null if no original source content is
|
||||
* available.
|
||||
*/
|
||||
sourceContentFor(source: string, returnNullOnMissing?: boolean): string | null;
|
||||
|
||||
/**
|
||||
* Iterate over each mapping between an original source/line/column and a
|
||||
* generated line/column in this source map.
|
||||
*
|
||||
* @param callback
|
||||
* The function that is called with each mapping.
|
||||
* @param context
|
||||
* Optional. If specified, this object will be the value of `this` every
|
||||
* time that `aCallback` is called.
|
||||
* @param order
|
||||
* Either `SourceMapConsumer.GENERATED_ORDER` or
|
||||
* `SourceMapConsumer.ORIGINAL_ORDER`. Specifies whether you want to
|
||||
* iterate over the mappings sorted by the generated file's line/column
|
||||
* order or the original's source/line/column order, respectively. Defaults to
|
||||
* `SourceMapConsumer.GENERATED_ORDER`.
|
||||
*/
|
||||
eachMapping(callback: (mapping: MappingItem) => void, context?: any, order?: number): void;
|
||||
}
|
||||
|
||||
export interface SourceMapConsumerConstructor {
|
||||
prototype: SourceMapConsumer;
|
||||
|
||||
GENERATED_ORDER: number;
|
||||
ORIGINAL_ORDER: number;
|
||||
GREATEST_LOWER_BOUND: number;
|
||||
LEAST_UPPER_BOUND: number;
|
||||
|
||||
new(rawSourceMap: RawSourceMap, sourceMapUrl?: SourceMapUrl): BasicSourceMapConsumer;
|
||||
new(rawSourceMap: RawIndexMap, sourceMapUrl?: SourceMapUrl): IndexedSourceMapConsumer;
|
||||
new(rawSourceMap: RawSourceMap | RawIndexMap | string, sourceMapUrl?: SourceMapUrl): BasicSourceMapConsumer | IndexedSourceMapConsumer;
|
||||
|
||||
/**
|
||||
* Create a BasicSourceMapConsumer from a SourceMapGenerator.
|
||||
*
|
||||
* @param sourceMap
|
||||
* The source map that will be consumed.
|
||||
*/
|
||||
fromSourceMap(sourceMap: SourceMapGenerator, sourceMapUrl?: SourceMapUrl): BasicSourceMapConsumer;
|
||||
}
|
||||
|
||||
export const SourceMapConsumer: SourceMapConsumerConstructor;
|
||||
|
||||
export interface BasicSourceMapConsumer extends SourceMapConsumer {
|
||||
file: string;
|
||||
sourceRoot: string;
|
||||
sources: string[];
|
||||
sourcesContent: string[];
|
||||
}
|
||||
|
||||
export interface BasicSourceMapConsumerConstructor {
|
||||
prototype: BasicSourceMapConsumer;
|
||||
|
||||
new(rawSourceMap: RawSourceMap | string): BasicSourceMapConsumer;
|
||||
|
||||
/**
|
||||
* Create a BasicSourceMapConsumer from a SourceMapGenerator.
|
||||
*
|
||||
* @param sourceMap
|
||||
* The source map that will be consumed.
|
||||
*/
|
||||
fromSourceMap(sourceMap: SourceMapGenerator): BasicSourceMapConsumer;
|
||||
}
|
||||
|
||||
export const BasicSourceMapConsumer: BasicSourceMapConsumerConstructor;
|
||||
|
||||
export interface IndexedSourceMapConsumer extends SourceMapConsumer {
|
||||
sources: string[];
|
||||
}
|
||||
|
||||
export interface IndexedSourceMapConsumerConstructor {
|
||||
prototype: IndexedSourceMapConsumer;
|
||||
|
||||
new(rawSourceMap: RawIndexMap | string): IndexedSourceMapConsumer;
|
||||
}
|
||||
|
||||
export const IndexedSourceMapConsumer: IndexedSourceMapConsumerConstructor;
|
||||
|
||||
export class SourceMapGenerator {
|
||||
constructor(startOfSourceMap?: StartOfSourceMap);
|
||||
|
||||
/**
|
||||
* Creates a new SourceMapGenerator based on a SourceMapConsumer
|
||||
*
|
||||
* @param sourceMapConsumer The SourceMap.
|
||||
*/
|
||||
static fromSourceMap(sourceMapConsumer: SourceMapConsumer): SourceMapGenerator;
|
||||
|
||||
/**
|
||||
* Add a single mapping from original source line and column to the generated
|
||||
* source's line and column for this source map being created. The mapping
|
||||
* object should have the following properties:
|
||||
*
|
||||
* - generated: An object with the generated line and column positions.
|
||||
* - original: An object with the original line and column positions.
|
||||
* - source: The original source file (relative to the sourceRoot).
|
||||
* - name: An optional original token name for this mapping.
|
||||
*/
|
||||
addMapping(mapping: Mapping): void;
|
||||
|
||||
/**
|
||||
* Set the source content for a source file.
|
||||
*/
|
||||
setSourceContent(sourceFile: string, sourceContent: string): void;
|
||||
|
||||
/**
|
||||
* Applies the mappings of a sub-source-map for a specific source file to the
|
||||
* source map being generated. Each mapping to the supplied source file is
|
||||
* rewritten using the supplied source map. Note: The resolution for the
|
||||
* resulting mappings is the minimium of this map and the supplied map.
|
||||
*
|
||||
* @param sourceMapConsumer The source map to be applied.
|
||||
* @param sourceFile Optional. The filename of the source file.
|
||||
* If omitted, SourceMapConsumer's file property will be used.
|
||||
* @param sourceMapPath Optional. The dirname of the path to the source map
|
||||
* to be applied. If relative, it is relative to the SourceMapConsumer.
|
||||
* This parameter is needed when the two source maps aren't in the same
|
||||
* directory, and the source map to be applied contains relative source
|
||||
* paths. If so, those relative source paths need to be rewritten
|
||||
* relative to the SourceMapGenerator.
|
||||
*/
|
||||
applySourceMap(sourceMapConsumer: SourceMapConsumer, sourceFile?: string, sourceMapPath?: string): void;
|
||||
|
||||
toString(): string;
|
||||
|
||||
toJSON(): RawSourceMap;
|
||||
}
|
||||
|
||||
export class SourceNode {
|
||||
children: SourceNode[];
|
||||
sourceContents: any;
|
||||
line: number;
|
||||
column: number;
|
||||
source: string;
|
||||
name: string;
|
||||
|
||||
constructor();
|
||||
constructor(
|
||||
line: number | null,
|
||||
column: number | null,
|
||||
source: string | null,
|
||||
chunks?: Array<(string | SourceNode)> | SourceNode | string,
|
||||
name?: string
|
||||
);
|
||||
|
||||
static fromStringWithSourceMap(
|
||||
code: string,
|
||||
sourceMapConsumer: SourceMapConsumer,
|
||||
relativePath?: string
|
||||
): SourceNode;
|
||||
|
||||
add(chunk: Array<(string | SourceNode)> | SourceNode | string): SourceNode;
|
||||
|
||||
prepend(chunk: Array<(string | SourceNode)> | SourceNode | string): SourceNode;
|
||||
|
||||
setSourceContent(sourceFile: string, sourceContent: string): void;
|
||||
|
||||
walk(fn: (chunk: string, mapping: MappedPosition) => void): void;
|
||||
|
||||
walkSourceContents(fn: (file: string, content: string) => void): void;
|
||||
|
||||
join(sep: string): SourceNode;
|
||||
|
||||
replaceRight(pattern: string, replacement: string): SourceNode;
|
||||
|
||||
toString(): string;
|
||||
|
||||
toStringWithSourceMap(startOfSourceMap?: StartOfSourceMap): CodeWithSourceMap;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
declare module "commonmark" {
|
||||
// Type definitions for commonmark.js 0.27
|
||||
// Project: https://github.com/jgm/commonmark.js
|
||||
// Definitions by: Nico Jansen <https://github.com/nicojs>
|
||||
// Leonard Thieu <https://github.com/leonard-thieu>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export class Node {
|
||||
constructor(nodeType: string, sourcepos?: Position);
|
||||
|
||||
/**
|
||||
* (read-only): a String, one of text, softbreak, linebreak, emph, strong, html_inline, link, image, code, document, paragraph,
|
||||
* block_quote, item, list, heading, code_block, html_block, thematic_break.
|
||||
*/
|
||||
readonly type: 'text' | 'softbreak' | 'linebreak' | 'emph' | 'strong' | 'html_inline' | 'link' | 'image' | 'code' | 'document' | 'paragraph' |
|
||||
'block_quote' | 'item' | 'list' | 'heading' | 'code_block' | 'html_block' | 'thematic_break' | 'custom_inline' | 'custom_block';
|
||||
/**
|
||||
* (read-only): a Node or null.
|
||||
*/
|
||||
readonly firstChild: Node | null;
|
||||
/**
|
||||
* (read-only): a Node or null.
|
||||
*/
|
||||
readonly lastChild: Node | null;
|
||||
/**
|
||||
* (read-only): a Node or null.
|
||||
*/
|
||||
readonly next: Node | null;
|
||||
/**
|
||||
* (read-only): a Node or null.
|
||||
*/
|
||||
readonly prev: Node | null;
|
||||
/**
|
||||
* (read-only): a Node or null.
|
||||
*/
|
||||
readonly parent: Node | null;
|
||||
/**
|
||||
* (read-only): an Array with the following form: [[startline, startcolumn], [endline, endcolumn]]
|
||||
*/
|
||||
readonly sourcepos: Position;
|
||||
/**
|
||||
* (read-only): true if the Node can contain other Nodes as children.
|
||||
*/
|
||||
readonly isContainer: boolean;
|
||||
/**
|
||||
* the literal String content of the node or null.
|
||||
*/
|
||||
literal: string | null;
|
||||
/**
|
||||
* link or image destination (String) or null.
|
||||
*/
|
||||
destination: string | null;
|
||||
/**
|
||||
* link or image title (String) or null.
|
||||
*/
|
||||
title: string | null;
|
||||
/**
|
||||
* fenced code block info string (String) or null.
|
||||
*/
|
||||
info: string | null;
|
||||
/**
|
||||
* heading level (Number).
|
||||
*/
|
||||
level: number;
|
||||
/**
|
||||
* either Bullet or Ordered (or undefined).
|
||||
*/
|
||||
listType: 'Bullet' | 'Ordered';
|
||||
/**
|
||||
* true if list is tight
|
||||
*/
|
||||
listTight: boolean;
|
||||
/**
|
||||
* a Number, the starting number of an ordered list.
|
||||
*/
|
||||
listStart: number;
|
||||
/**
|
||||
* a String, either ) or . for an ordered list.
|
||||
*/
|
||||
listDelimiter: ')' | '.';
|
||||
/**
|
||||
* used only for CustomBlock or CustomInline.
|
||||
*/
|
||||
onEnter: string;
|
||||
/**
|
||||
* used only for CustomBlock or CustomInline.
|
||||
*/
|
||||
onExit: string;
|
||||
|
||||
/**
|
||||
* Append a Node child to the end of the Node's children.
|
||||
*/
|
||||
appendChild(child: Node): void;
|
||||
|
||||
/**
|
||||
* Prepend a Node child to the beginning of the Node's children.
|
||||
*/
|
||||
prependChild(child: Node): void;
|
||||
|
||||
/**
|
||||
* Remove the Node from the tree, severing its links with siblings and parents, and closing up gaps as needed.
|
||||
*/
|
||||
unlink(): void;
|
||||
|
||||
/**
|
||||
* Insert a Node sibling after the Node.
|
||||
*/
|
||||
insertAfter(sibling: Node): void;
|
||||
|
||||
/**
|
||||
* Insert a Node sibling before the Node.
|
||||
*/
|
||||
insertBefore(sibling: Node): void;
|
||||
|
||||
/**
|
||||
* Returns a NodeWalker that can be used to iterate through the Node tree rooted in the Node
|
||||
*/
|
||||
walker(): NodeWalker;
|
||||
|
||||
/**
|
||||
* Setting the backing object of listType, listTight, listStat and listDelimiter directly.
|
||||
* Not needed unless creating list nodes directly. Should be fixed from v>0.22.1
|
||||
* https://github.com/jgm/commonmark.js/issues/74
|
||||
*/
|
||||
_listData: ListData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instead of converting Markdown directly to HTML, as most converters do, commonmark.js parses Markdown to an AST (abstract syntax tree), and then renders this AST as HTML.
|
||||
* This opens up the possibility of manipulating the AST between parsing and rendering. For example, one could transform emphasis into ALL CAPS.
|
||||
*/
|
||||
export class Parser {
|
||||
/**
|
||||
* Constructs a new Parser
|
||||
*/
|
||||
constructor(options?: ParserOptions);
|
||||
|
||||
parse(input: string): Node;
|
||||
}
|
||||
|
||||
export class HtmlRenderer {
|
||||
constructor(options?: HtmlRenderingOptions)
|
||||
|
||||
render(root: Node): string;
|
||||
|
||||
/**
|
||||
* Let's you override the softbreak properties of a renderer. So, to make soft breaks render as hard breaks in HTML:
|
||||
* writer.softbreak = "<br />";
|
||||
*/
|
||||
softbreak: string;
|
||||
/**
|
||||
* Override the function that will be used to escape (sanitize) the html output. Return value is used to add to the html output
|
||||
* @param input the input to escape
|
||||
* @param isAttributeValue indicates wheter or not the input value will be used as value of an html attribute.
|
||||
*/
|
||||
escape: (input: string, isAttributeValue: boolean) => string;
|
||||
}
|
||||
|
||||
export class XmlRenderer {
|
||||
constructor(options?: XmlRenderingOptions)
|
||||
|
||||
render(root: Node): string;
|
||||
}
|
||||
export interface NodeWalkingStep {
|
||||
/**
|
||||
* a boolean, which is true when we enter a Node from a parent or sibling, and false when we reenter it from a child
|
||||
*/
|
||||
entering: boolean;
|
||||
/**
|
||||
* The node belonging to this step
|
||||
*/
|
||||
node: Node;
|
||||
}
|
||||
|
||||
export interface NodeWalker {
|
||||
/**
|
||||
* Returns an object with properties entering and node. Returns null when we have finished walking the tree.
|
||||
*/
|
||||
next(): NodeWalkingStep;
|
||||
/**
|
||||
* Resets the iterator to resume at the specified node and setting for entering. (Normally this isn't needed unless you do destructive updates to the Node tree.)
|
||||
*/
|
||||
resumeAt(node: Node, entering?: boolean): void;
|
||||
}
|
||||
|
||||
export type Position = [[number, number], [number, number]];
|
||||
|
||||
export interface ListData {
|
||||
type?: string;
|
||||
tight?: boolean;
|
||||
delimiter?: string;
|
||||
bulletChar?: string;
|
||||
}
|
||||
|
||||
export interface ParserOptions {
|
||||
/**
|
||||
* if true, straight quotes will be made curly, -- will be changed to an en dash, --- will be changed to an em dash, and ... will be changed to ellipses.
|
||||
*/
|
||||
smart?: boolean;
|
||||
time?: boolean;
|
||||
}
|
||||
|
||||
export interface HtmlRenderingOptions extends XmlRenderingOptions {
|
||||
/**
|
||||
* if true, raw HTML will not be passed through to HTML output (it will be replaced by comments), and potentially unsafe URLs in links and images
|
||||
* (those beginning with javascript:, vbscript:, file:, and with a few exceptions data:) will be replaced with empty strings.
|
||||
*/
|
||||
safe?: boolean;
|
||||
/**
|
||||
* if true, straight quotes will be made curly, -- will be changed to an en dash, --- will be changed to an em dash, and ... will be changed to ellipses.
|
||||
*/
|
||||
smart?: boolean;
|
||||
/**
|
||||
* if true, source position information for block-level elements will be rendered in the data-sourcepos attribute (for HTML) or the sourcepos attribute (for XML).
|
||||
*/
|
||||
sourcepos?: boolean;
|
||||
}
|
||||
|
||||
export interface XmlRenderingOptions {
|
||||
time?: boolean;
|
||||
sourcepos?: boolean;
|
||||
}
|
||||
|
||||
}
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,6 +0,0 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import { Enumerable as IEnumerable, From } from "linq-es2015";
|
||||
export { Enumerable, Enumerable as IEnumerable, From } from "linq-es2015";
|
|
@ -1,25 +1,53 @@
|
|||
/// <reference path="interfaces/autorest-core.d.ts" />
|
||||
|
||||
// load static module: ${__dirname }/static_modules.fs
|
||||
require('./static-loader.js').load(`${__dirname}/static_modules.fs`)
|
||||
|
||||
// everything else.
|
||||
import { networkEnabled, rootFolder, extensionManager, availableVersions, corePackage, installedCores, tryRequire, resolveEntrypoint, resolvePathForLocalVersion, ensureAutorestHome, selectVersion, pkgVersion } from "./autorest-as-a-service"
|
||||
import { DocumentPatterns } from './lib/core/lib/document-type';
|
||||
import { resolve } from 'path';
|
||||
import { BaseLanguageClient as LanguageClient, TextDocument } from "./vscode/client";
|
||||
|
||||
import { LanguageClient } from "vscode-languageclient"
|
||||
|
||||
// exports the public AutoRest definitions
|
||||
export { IFileSystem, Message } from './lib/core/main';
|
||||
export { IFileSystem, Message, Artifact } from 'autorest-core/main';
|
||||
export { GenerationResults } from 'autorest-core/language-service/language-service'
|
||||
import { GenerationResults } from 'autorest-core/language-service/language-service'
|
||||
|
||||
// the local class definition of the AutoRest Interface and the EventEmitter signatures
|
||||
import { AutoRest as IAutoRest, Channel as IChannel, IFileSystem } from './lib/core/main';
|
||||
import { AutoRest as IAutoRest, IFileSystem } from 'autorest-core/main';
|
||||
|
||||
/**
|
||||
* The Channel that a message is registered with.
|
||||
*/
|
||||
export enum Channel {
|
||||
/** Information is considered the mildest of responses; not necesarily actionable. */
|
||||
Information = <any>"information",
|
||||
|
||||
/** Warnings are considered important for best practices, but not catastrophic in nature. */
|
||||
Warning = <any>"warning",
|
||||
|
||||
/** Errors are considered blocking issues that block a successful operation. */
|
||||
Error = <any>"error",
|
||||
|
||||
/** Debug messages are designed for the developer to communicate internal autorest implementation details. */
|
||||
Debug = <any>"debug",
|
||||
|
||||
/** Verbose messages give the user additional clarity on the process. */
|
||||
Verbose = <any>"verbose",
|
||||
|
||||
/** Catastrophic failure, likely abending the process. */
|
||||
Fatal = <any>"fatal",
|
||||
|
||||
/** Hint messages offer guidance or support without forcing action. */
|
||||
Hint = <any>"hint",
|
||||
}
|
||||
|
||||
export enum DocumentType {
|
||||
OpenAPI2 = <any>"OpenAPI2",
|
||||
OpenAPI3 = <any>"OpenAPI3",
|
||||
LiterateConfiguration = <any>"LiterateConfiguration",
|
||||
Unknown = <any>"Unknown"
|
||||
}
|
||||
|
||||
let resolve_autorest: (value?: typeof IAutoRest | PromiseLike<typeof IAutoRest>) => void;
|
||||
|
@ -36,6 +64,17 @@ let coreModule: any = undefined;
|
|||
let busy = false;
|
||||
let modulePath: string | undefined = undefined;
|
||||
|
||||
/**
|
||||
* Returns the language service entrypoint for autorest-core, bootstrapping the core if necessary
|
||||
*
|
||||
* If initialize has already been called, then it returns the version that was initialized, regardless of parameters
|
||||
*
|
||||
* @param requestedVersion an npm package reference for the version requested @see {@link https://docs.npmjs.com/cli/install#description}
|
||||
*
|
||||
* @param minimumVersion - a semver string representing the lowest autorest- core version that is considered acceptable.
|
||||
*
|
||||
* @see { @link initialize }
|
||||
*/
|
||||
export async function getLanguageServiceEntrypoint(requestedVersion: string = "latest-installed", minimumVersion?: string): Promise<string> {
|
||||
if (!modulePath && !busy) {
|
||||
// if we haven't already got autorest-core, let's do that now with the default settings.
|
||||
|
@ -44,6 +83,17 @@ export async function getLanguageServiceEntrypoint(requestedVersion: string = "l
|
|||
return resolveEntrypoint(modulePath, "language-service");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the command-line application entrypoint for autorest-core, bootstrapping the core if necessary
|
||||
*
|
||||
* If initialize has already been called, then it returns the version that was initialized, regardless of parameters
|
||||
*
|
||||
* @param requestedVersion an npm package reference for the version requested @see {@link https://docs.npmjs.com/cli/install#description}
|
||||
*
|
||||
* @param minimumVersion - a semver string representing the lowest autorest-core version that is considered acceptable.
|
||||
*
|
||||
* @see {@link initialize}
|
||||
* */
|
||||
export async function getApplicationEntrypoint(requestedVersion: string = "latest-installed", minimumVersion?: string): Promise<string> {
|
||||
if (!modulePath && !busy) {
|
||||
// if we haven't already got autorest-core, let's do that now with the default settings.
|
||||
|
@ -52,6 +102,21 @@ export async function getApplicationEntrypoint(requestedVersion: string = "lates
|
|||
return resolveEntrypoint(modulePath, "app");
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the AutoRest-core module, bootstrapping the core from npm if required.
|
||||
*
|
||||
* @param requestedVersion an npm package reference for the version requested @see {@link https://docs.npmjs.com/cli/install#description}
|
||||
*
|
||||
* a) a folder containing a program described by a package.json file
|
||||
* b) a gzipped tarball containing (a)
|
||||
* c) a url that resolves to (b)
|
||||
* d) a <name>@<version> that is published on the registry {@link https://docs.npmjs.com/misc/registry}) with (c)
|
||||
* e) a <name>@<tag> (see npm-dist-tag) that points to (d)
|
||||
* f) a <name> that has a "latest" tag satisfying (e)
|
||||
* g) a <git remote url> that resolves to (a)
|
||||
*
|
||||
* @param minimumVersion - a semver string representing the lowest autorest-core version that is considered acceptable.
|
||||
*/
|
||||
export async function initialize(requestedVersion: string = "latest-installed", minimumVersion?: string) {
|
||||
if (modulePath) {
|
||||
return;
|
||||
|
@ -92,6 +157,37 @@ export async function initialize(requestedVersion: string = "latest-installed",
|
|||
}
|
||||
}
|
||||
|
||||
/** Bootstraps the core module if it's not already done and returns the AutoRest class. */
|
||||
async function ensureCoreLoaded(): Promise<typeof IAutoRest> {
|
||||
|
||||
if (!modulePath && !busy) {
|
||||
// if we haven't already got autorest-core, let's do that now with the default settings.
|
||||
await initialize();
|
||||
}
|
||||
|
||||
if (modulePath && !coreModule) {
|
||||
// get the library entrypoint
|
||||
coreModule = tryRequire(modulePath, "main");
|
||||
|
||||
// assign the type to the Async Class Identity
|
||||
resolve_autorest(coreModule.AutoRest)
|
||||
}
|
||||
|
||||
// wait for class definition
|
||||
return <any>(await AutoRest);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an instance of the AutoRest engine. Will call {@link initialize} with default values to bootstrap AutoRest core if necessary.
|
||||
*
|
||||
* @param fileSystem - the {@link IFileSystem} implementation that will be used to acquire files
|
||||
*
|
||||
* Note: http:/https:/mem: schemes are handled internally in AutoRest and the IFilesystem will not call
|
||||
* the IFileSystem methods.
|
||||
*
|
||||
*
|
||||
* @param configFileOrFolderUri - a URI pointing to the folder or autorest configuration file
|
||||
*/
|
||||
export async function create(fileSystem?: IFileSystem, configFileOrFolderUri?: string): Promise<AutoRest> {
|
||||
if (!modulePath && !busy) {
|
||||
// if we haven't already got autorest-core, let's do that now with the default settings.
|
||||
|
@ -113,23 +209,95 @@ export async function create(fileSystem?: IFileSystem, configFileOrFolderUri?: s
|
|||
return new CAutoRest(fileSystem, configFileOrFolderUri);
|
||||
}
|
||||
|
||||
export interface generated {
|
||||
messages: Array<string>;
|
||||
files: any;
|
||||
/**
|
||||
* Given a document's content, does this represent a openapi document of some sort?
|
||||
*
|
||||
* @param content - the document content to evaluate
|
||||
*/
|
||||
export async function isOpenApiDocument(content: string): Promise<boolean> {
|
||||
await ensureCoreLoaded();
|
||||
return coreModule.IsOpenApiDocument(content);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if the document is a literate configuation document.
|
||||
*
|
||||
* @param content the document content to check
|
||||
*/
|
||||
export async function isConfigurationDocument(content: string): Promise<boolean> {
|
||||
await ensureCoreLoaded();
|
||||
return coreModule.IsConfigurationDocument(content);
|
||||
}
|
||||
|
||||
/** Determines the document type based on the content of the document
|
||||
*
|
||||
* @returns Promise<DocumentType> one of:
|
||||
* - DocumentType.LiterateConfiguration - contains the magic string '\n> see https://aka.ms/autorest'
|
||||
* - DocumentType.OpenAPI2 - $.swagger === "2.0"
|
||||
* - DocumentType.OpenAPI3 - $.openapi === "3.0"
|
||||
* - DocumentType.Unknown - content does not match a known document type
|
||||
*
|
||||
* @see {@link DocumentType}
|
||||
*/
|
||||
export async function identifyDocument(content: string): Promise<DocumentType> {
|
||||
await ensureCoreLoaded();
|
||||
return await coreModule.IdentifyDocument(content);
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes a document (yaml, markdown or JSON) and returns the document as a JSON-encoded document text
|
||||
* @param content - the document content
|
||||
*
|
||||
* @returns the content as a JSON string (not a JSON DOM)
|
||||
*/
|
||||
export async function toJSON(content: string): Promise<string> {
|
||||
await ensureCoreLoaded();
|
||||
return await coreModule.LiterateToJson(content);
|
||||
}
|
||||
|
||||
|
||||
/** This is a convenience class for accessing the requests supported by AutoRest when used as a language service */
|
||||
export class AutoRestLanguageService {
|
||||
|
||||
/**
|
||||
* Represents a convenience layer on the remote language service functions (on top of LSP-defined functions)
|
||||
*
|
||||
* @constructor
|
||||
*
|
||||
* this requires a reference to the language client so that the methods can await the onReady signal
|
||||
* before attempting to send requests.
|
||||
*/
|
||||
public constructor(private languageClient: LanguageClient) {
|
||||
|
||||
}
|
||||
|
||||
public async generate(documentUri: string, language: string, configuration: any): Promise<generated> {
|
||||
/**
|
||||
* Runs autorest to process a file
|
||||
*
|
||||
* @param documentUri The OpenApi document or AutoRest configuration file to use for the generation
|
||||
*
|
||||
* @param language The language to generate code for. (This is a convenience; it could have been expressed in the configuration)
|
||||
*
|
||||
* @param configuration Additional configuration to pass to AutoRest -- this overrides any defaults or content in the configuration file
|
||||
* @returns async: a 'generated' object containg the output from the generation run.
|
||||
* @see generated
|
||||
*
|
||||
*/
|
||||
|
||||
public async generate(documentUri: string, language: string, configuration: any): Promise<GenerationResults> {
|
||||
// don't call before the client is ready.
|
||||
await this.languageClient.onReady();
|
||||
return await this.languageClient.sendRequest<generated>("generate", { documentUri: documentUri, language: language, configuration: configuration });
|
||||
return await this.languageClient.sendRequest<GenerationResults>("generate", { documentUri: documentUri, language: language, configuration: configuration });
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if a file is an OpenAPI document (2.0)
|
||||
*
|
||||
* @param contentOrUri either a URL to a file on disk or http/s, or the content of a file itself.
|
||||
* @returns async:
|
||||
* true - the file is an OpenAPI 2.0 document
|
||||
* false - the file was not recognized.
|
||||
*/
|
||||
public async isOpenApiDocument(contentOrUri: string): Promise<boolean> {
|
||||
// don't call before the client is ready.
|
||||
await this.languageClient.onReady();
|
||||
|
@ -137,13 +305,27 @@ export class AutoRestLanguageService {
|
|||
return await this.languageClient.sendRequest<boolean>("isOpenApiDocument", { contentOrUri: contentOrUri });
|
||||
}
|
||||
|
||||
public async isConfigurationFile(contentOrUri: string): Promise<boolean> {
|
||||
/**
|
||||
* Determines if a file is an AutoRest configuration file (checks for the magic string `\n> see https://aka.ms/autorest` )
|
||||
*
|
||||
* @param contentOrUri either a URL to a file on disk or http/s, or the content of a file itself.
|
||||
* @returns async:
|
||||
* true - the file is an autorest configuration file
|
||||
* false - the file was not recognized.
|
||||
*/
|
||||
public async isConfigurationDocument(contentOrUri: string): Promise<boolean> {
|
||||
// don't call before the client is ready.
|
||||
await this.languageClient.onReady();
|
||||
|
||||
return await this.languageClient.sendRequest<boolean>("isConfigurationFile", { contentOrUri: contentOrUri });
|
||||
return await this.languageClient.sendRequest<boolean>("isConfigurationDocument", { contentOrUri: contentOrUri });
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the file as a JSON string. This can be a .YAML, .MD or .JSON file to begin with.
|
||||
*
|
||||
* @param contentOrUri either a URL to a file on disk or http/s, or the content of a file itself.
|
||||
* @returns async: string containing the file as JSON
|
||||
*/
|
||||
public async toJSON(contentOrUri: string): Promise<string> {
|
||||
// don't call before the client is ready.
|
||||
await this.languageClient.onReady();
|
||||
|
@ -151,17 +333,38 @@ export class AutoRestLanguageService {
|
|||
return await this.languageClient.sendRequest<string>("toJSON", { contentOrUri: contentOrUri });
|
||||
}
|
||||
|
||||
public async findConfigurationFile(documentUri: string): Promise<string> {
|
||||
/**
|
||||
* Finds the configuration file for a given document URI.
|
||||
*
|
||||
* @param documentUri the URL to a file on disk or http/s. The passed in file can be an OpenAPI file or an AutoRest configuration file.
|
||||
* @returns async: the URI to the configuration file or an empty string if no configuration could be found.
|
||||
*
|
||||
*/
|
||||
public async detectConfigurationFile(documentUri: string): Promise<string> {
|
||||
// don't call before the client is ready.
|
||||
await this.languageClient.onReady();
|
||||
|
||||
return await this.languageClient.sendRequest<string>("findConfigurationFile", { documentUri: documentUri });
|
||||
return await this.languageClient.sendRequest<string>("detectConfigurationFile", { documentUri: documentUri });
|
||||
}
|
||||
|
||||
public async isSupportedFile(languageId: string, contentOrUri: string): Promise<boolean> {
|
||||
/**
|
||||
* Determines if a file is an OpenAPI document or a configuration file in one attempt.
|
||||
*
|
||||
* @param contentOrUri either a URL to a file on disk or http/s, or the content of a file itself.
|
||||
* @returns async:
|
||||
* true - the file is a configuration file or OpenAPI (2.0) file
|
||||
* false - the file was not recognized.
|
||||
*/
|
||||
public async isSupportedDocument(languageId: string, contentOrUri: string): Promise<boolean> {
|
||||
// don't call before the client is ready.
|
||||
await this.languageClient.onReady();
|
||||
|
||||
return await this.languageClient.sendRequest<boolean>("isSupportedFile", { languageId: languageId, contentOrUri: contentOrUri });
|
||||
return await this.languageClient.sendRequest<boolean>("isSupportedDocument", { languageId: languageId, contentOrUri: contentOrUri });
|
||||
}
|
||||
|
||||
public async identifyDocument(contentOrUri: string): Promise<DocumentType> {
|
||||
// don't call before the client is ready.
|
||||
await this.languageClient.onReady();
|
||||
return await this.languageClient.sendRequest<DocumentType>("identifyDocument", { contentOrUri: contentOrUri });
|
||||
}
|
||||
}
|
|
@ -28,30 +28,24 @@
|
|||
"scripts": {
|
||||
"start": "node ./dist/app.js",
|
||||
"test": "./node_modules/.bin/mocha ./dist/test",
|
||||
"build": "tsc -p .",
|
||||
"build": "cd .. && cd autorest-core && npm run build && cd .. && cd autorest && tsc -p .&& shx mkdir -p ./dist/interfaces && shx cp -r ./interfaces/*.d.ts ./dist/interfaces ",
|
||||
"static-link": "static-link",
|
||||
"postinstall": "node ./post-install --force",
|
||||
"preinstall": "node ./preinstall-check",
|
||||
"prepublishonly": "static-link --force & gulp build"
|
||||
"reinstall": "shx rm ./package-lock.json && shx rm -rf ./node_modules && npm install",
|
||||
"prepack": "static-link & npm run build"
|
||||
},
|
||||
"typings": "./dist/main.d.ts",
|
||||
"devDependencies": {
|
||||
"@types/commonmark": "^0.22.29",
|
||||
"@types/node": "^7.0.5",
|
||||
"@types/semver": "^5.3.30",
|
||||
"@types/source-map": "^0.5.0",
|
||||
"@types/yargs": "^6.6.0",
|
||||
"mocha": "3.2.0",
|
||||
"mocha-typescript": "1.0.22",
|
||||
"source-map": "^0.5.6",
|
||||
"source-map-support": "^0.4.14",
|
||||
"typescript": "2.5.3",
|
||||
"@types/jsonpath": "^0.1.29",
|
||||
"vscode-languageserver-protocol": "3.4.4",
|
||||
"vscode-jsonrpc": "^3.1.0",
|
||||
"linq-es2015": "^2.4.24",
|
||||
"static-link": "^0.2.1",
|
||||
"yaml-ast-parser": "https://github.com/olydis/yaml-ast-parser/releases/download/0.0.34/yaml-ast-parser-0.0.34.tgz"
|
||||
"static-link": "^0.2.2",
|
||||
"shx": "0.2.2"
|
||||
},
|
||||
"static-link": {
|
||||
"entrypoints": [],
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
try {
|
||||
// if this installed for development
|
||||
// static-link should be installed.
|
||||
// if we require it, it should build the static fs.
|
||||
require("./node_modules/static-link/dist/static-link")
|
||||
} catch(E) {
|
||||
// if this installed for development
|
||||
|
||||
// static-link should be installed.
|
||||
// if we require it, it should build the static fs.
|
||||
require("./node_modules/static-link/dist/static-link");
|
||||
} catch(E) { }
|
||||
|
||||
}
|
|
@ -13,6 +13,9 @@
|
|||
"types": [
|
||||
"node"
|
||||
],
|
||||
"typeRoots": [
|
||||
"./node_modules/@types"
|
||||
],
|
||||
"lib": [
|
||||
"esnext"
|
||||
]
|
||||
|
@ -20,6 +23,7 @@
|
|||
"exclude": [
|
||||
"dist",
|
||||
"node_modules",
|
||||
"_lib",
|
||||
"lib/core/language-service"
|
||||
]
|
||||
}
|
|
@ -1,359 +0,0 @@
|
|||
import { TextDocumentChangeEvent, TextDocument, Disposable, OutputChannel, FileSystemWatcher as VFileSystemWatcher, DiagnosticCollection, ProviderResult, CancellationToken, Position as VPosition, Location as VLocation, Range as VRange, CompletionItem as VCompletionItem, CompletionList as VCompletionList, SignatureHelp as VSignatureHelp, Definition as VDefinition, DocumentHighlight as VDocumentHighlight, SymbolInformation as VSymbolInformation, CodeActionContext as VCodeActionContext, Command as VCommand, CodeLens as VCodeLens, FormattingOptions as VFormattingOptions, TextEdit as VTextEdit, WorkspaceEdit as VWorkspaceEdit, Hover as VHover, DocumentLink as VDocumentLink, TextDocumentWillSaveEvent, WorkspaceFolder as VWorkspaceFolder } from './vscode';
|
||||
import { Message, RPCMessageType, ResponseError, RequestType, RequestType0, RequestHandler, RequestHandler0, GenericRequestHandler, NotificationType, NotificationType0, NotificationHandler, NotificationHandler0, GenericNotificationHandler, MessageReader, MessageWriter, Trace, Event, ClientCapabilities, InitializeParams, InitializeResult, InitializeError, ServerCapabilities, DocumentSelector } from 'vscode-languageserver-protocol';
|
||||
import * as c2p from './codeConverter';
|
||||
import * as p2c from './protocolConverter';
|
||||
export { Converter as Code2ProtocolConverter } from './codeConverter';
|
||||
export { Converter as Protocol2CodeConverter } from './protocolConverter';
|
||||
export * from 'vscode-languageserver-protocol';
|
||||
export interface ExecutableOptions {
|
||||
cwd?: string;
|
||||
stdio?: string | string[];
|
||||
env?: any;
|
||||
detached?: boolean;
|
||||
}
|
||||
export interface Executable {
|
||||
command: string;
|
||||
args?: string[];
|
||||
options?: ExecutableOptions;
|
||||
}
|
||||
export interface ForkOptions {
|
||||
cwd?: string;
|
||||
env?: any;
|
||||
encoding?: string;
|
||||
execArgv?: string[];
|
||||
}
|
||||
export declare enum TransportKind {
|
||||
stdio = 0,
|
||||
ipc = 1,
|
||||
pipe = 2,
|
||||
}
|
||||
export interface NodeModule {
|
||||
module: string;
|
||||
transport?: TransportKind;
|
||||
args?: string[];
|
||||
runtime?: string;
|
||||
options?: ForkOptions;
|
||||
}
|
||||
/**
|
||||
* An action to be performed when the connection is producing errors.
|
||||
*/
|
||||
export declare enum ErrorAction {
|
||||
/**
|
||||
* Continue running the server.
|
||||
*/
|
||||
Continue = 1,
|
||||
/**
|
||||
* Shutdown the server.
|
||||
*/
|
||||
Shutdown = 2,
|
||||
}
|
||||
/**
|
||||
* An action to be performed when the connection to a server got closed.
|
||||
*/
|
||||
export declare enum CloseAction {
|
||||
/**
|
||||
* Don't restart the server. The connection stays closed.
|
||||
*/
|
||||
DoNotRestart = 1,
|
||||
/**
|
||||
* Restart the server.
|
||||
*/
|
||||
Restart = 2,
|
||||
}
|
||||
/**
|
||||
* A pluggable error handler that is invoked when the connection is either
|
||||
* producing errors or got closed.
|
||||
*/
|
||||
export interface ErrorHandler {
|
||||
/**
|
||||
* An error has occurred while writing or reading from the connection.
|
||||
*
|
||||
* @param error - the error received
|
||||
* @param message - the message to be delivered to the server if know.
|
||||
* @param count - a count indicating how often an error is received. Will
|
||||
* be reset if a message got successfully send or received.
|
||||
*/
|
||||
error(error: Error, message: Message, count: number): ErrorAction;
|
||||
/**
|
||||
* The connection to the server got closed.
|
||||
*/
|
||||
closed(): CloseAction;
|
||||
}
|
||||
export interface InitializationFailedHandler {
|
||||
(error: ResponseError<InitializeError> | Error | any): boolean;
|
||||
}
|
||||
export interface SynchronizeOptions {
|
||||
configurationSection?: string | string[];
|
||||
fileEvents?: VFileSystemWatcher | VFileSystemWatcher[];
|
||||
}
|
||||
export declare enum RevealOutputChannelOn {
|
||||
Info = 1,
|
||||
Warn = 2,
|
||||
Error = 3,
|
||||
Never = 4,
|
||||
}
|
||||
export interface ProvideCompletionItemsSignature {
|
||||
(document: TextDocument, position: VPosition, token: CancellationToken): ProviderResult<VCompletionItem[] | VCompletionList>;
|
||||
}
|
||||
export interface ResolveCompletionItemSignature {
|
||||
(item: VCompletionItem, token: CancellationToken): ProviderResult<VCompletionItem>;
|
||||
}
|
||||
export interface ProvideHoverSignature {
|
||||
(document: TextDocument, position: VPosition, token: CancellationToken): ProviderResult<VHover>;
|
||||
}
|
||||
export interface ProvideSignatureHelpSignature {
|
||||
(document: TextDocument, position: VPosition, token: CancellationToken): ProviderResult<VSignatureHelp>;
|
||||
}
|
||||
export interface ProvideDefinitionSignature {
|
||||
(document: TextDocument, position: VPosition, token: CancellationToken): ProviderResult<VDefinition>;
|
||||
}
|
||||
export interface ProvideReferencesSignature {
|
||||
(document: TextDocument, position: VPosition, options: {
|
||||
includeDeclaration: boolean;
|
||||
}, token: CancellationToken): ProviderResult<VLocation[]>;
|
||||
}
|
||||
export interface ProvideDocumentHighlightsSignature {
|
||||
(document: TextDocument, position: VPosition, token: CancellationToken): ProviderResult<VDocumentHighlight[]>;
|
||||
}
|
||||
export interface ProvideDocumentSymbolsSignature {
|
||||
(document: TextDocument, token: CancellationToken): ProviderResult<VSymbolInformation[]>;
|
||||
}
|
||||
export interface ProvideWorkspaceSymbolsSignature {
|
||||
(query: string, token: CancellationToken): ProviderResult<VSymbolInformation[]>;
|
||||
}
|
||||
export interface ProvideCodeActionsSignature {
|
||||
(document: TextDocument, range: VRange, context: VCodeActionContext, token: CancellationToken): ProviderResult<VCommand[]>;
|
||||
}
|
||||
export interface ProvideCodeLensesSignature {
|
||||
(document: TextDocument, token: CancellationToken): ProviderResult<VCodeLens[]>;
|
||||
}
|
||||
export interface ResolveCodeLensSignature {
|
||||
(codeLens: VCodeLens, token: CancellationToken): ProviderResult<VCodeLens>;
|
||||
}
|
||||
export interface ProvideDocumentFormattingEditsSignature {
|
||||
(document: TextDocument, options: VFormattingOptions, token: CancellationToken): ProviderResult<VTextEdit[]>;
|
||||
}
|
||||
export interface ProvideDocumentRangeFormattingEditsSignature {
|
||||
(document: TextDocument, range: VRange, options: VFormattingOptions, token: CancellationToken): ProviderResult<VTextEdit[]>;
|
||||
}
|
||||
export interface ProvideOnTypeFormattingEditsSignature {
|
||||
(document: TextDocument, position: VPosition, ch: string, options: VFormattingOptions, token: CancellationToken): ProviderResult<VTextEdit[]>;
|
||||
}
|
||||
export interface ProvideRenameEditsSignature {
|
||||
(document: TextDocument, position: VPosition, newName: string, token: CancellationToken): ProviderResult<VWorkspaceEdit>;
|
||||
}
|
||||
export interface ProvideDocumentLinksSignature {
|
||||
(document: TextDocument, token: CancellationToken): ProviderResult<VDocumentLink[]>;
|
||||
}
|
||||
export interface ResolveDocumentLinkSignature {
|
||||
(link: VDocumentLink, token: CancellationToken): ProviderResult<VDocumentLink>;
|
||||
}
|
||||
export interface NextSignature<P, R> {
|
||||
(data: P, next: (data: P) => R): R;
|
||||
}
|
||||
export interface DidChangeConfigurationSignature {
|
||||
(sections: string[] | undefined): void;
|
||||
}
|
||||
export interface WorkspaceMiddleware {
|
||||
didChangeConfiguration?: (sections: string[] | undefined, next: DidChangeConfigurationSignature) => void;
|
||||
}
|
||||
export interface Middleware {
|
||||
didOpen?: NextSignature<TextDocument, void>;
|
||||
didChange?: NextSignature<TextDocumentChangeEvent, void>;
|
||||
willSave?: NextSignature<TextDocumentWillSaveEvent, void>;
|
||||
willSaveWaitUntil?: NextSignature<TextDocumentWillSaveEvent, Thenable<VTextEdit[]>>;
|
||||
didSave?: NextSignature<TextDocument, void>;
|
||||
didClose?: NextSignature<TextDocument, void>;
|
||||
provideCompletionItem?: (document: TextDocument, position: VPosition, token: CancellationToken, next: ProvideCompletionItemsSignature) => ProviderResult<VCompletionItem[] | VCompletionList>;
|
||||
resolveCompletionItem?: (item: VCompletionItem, token: CancellationToken, next: ResolveCompletionItemSignature) => ProviderResult<VCompletionItem>;
|
||||
provideHover?: (document: TextDocument, position: VPosition, token: CancellationToken, next: ProvideHoverSignature) => ProviderResult<VHover>;
|
||||
provideSignatureHelp?: (document: TextDocument, position: VPosition, token: CancellationToken, next: ProvideSignatureHelpSignature) => ProviderResult<VSignatureHelp>;
|
||||
provideDefinition?: (document: TextDocument, position: VPosition, token: CancellationToken, next: ProvideDefinitionSignature) => ProviderResult<VDefinition>;
|
||||
provideReferences?: (document: TextDocument, position: VPosition, options: {
|
||||
includeDeclaration: boolean;
|
||||
}, token: CancellationToken, next: ProvideReferencesSignature) => ProviderResult<VLocation[]>;
|
||||
provideDocumentHighlights?: (document: TextDocument, position: VPosition, token: CancellationToken, next: ProvideDocumentHighlightsSignature) => ProviderResult<VDocumentHighlight[]>;
|
||||
provideDocumentSymbols?: (document: TextDocument, token: CancellationToken, next: ProvideDocumentSymbolsSignature) => ProviderResult<VSymbolInformation[]>;
|
||||
provideWorkspaceSymbols?: (query: string, token: CancellationToken, next: ProvideWorkspaceSymbolsSignature) => ProviderResult<VSymbolInformation[]>;
|
||||
provideCodeActions?: (document: TextDocument, range: VRange, context: VCodeActionContext, token: CancellationToken, next: ProvideCodeActionsSignature) => ProviderResult<VCommand[]>;
|
||||
provideCodeLenses?: (document: TextDocument, token: CancellationToken, next: ProvideCodeLensesSignature) => ProviderResult<VCodeLens[]>;
|
||||
resolveCodeLens?: (codeLens: VCodeLens, token: CancellationToken, next: ResolveCodeLensSignature) => ProviderResult<VCodeLens>;
|
||||
provideDocumentFormattingEdits?: (document: TextDocument, options: VFormattingOptions, token: CancellationToken, next: ProvideDocumentFormattingEditsSignature) => ProviderResult<VTextEdit[]>;
|
||||
provideDocumentRangeFormattingEdits?: (document: TextDocument, range: VRange, options: VFormattingOptions, token: CancellationToken, next: ProvideDocumentRangeFormattingEditsSignature) => ProviderResult<VTextEdit[]>;
|
||||
provideOnTypeFormattingEdits?: (document: TextDocument, position: VPosition, ch: string, options: VFormattingOptions, token: CancellationToken, next: ProvideOnTypeFormattingEditsSignature) => ProviderResult<VTextEdit[]>;
|
||||
provideRenameEdits?: (document: TextDocument, position: VPosition, newName: string, token: CancellationToken, next: ProvideRenameEditsSignature) => ProviderResult<VWorkspaceEdit>;
|
||||
provideDocumentLinks?: (document: TextDocument, token: CancellationToken, next: ProvideDocumentLinksSignature) => ProviderResult<VDocumentLink[]>;
|
||||
resolveDocumentLink?: (link: VDocumentLink, token: CancellationToken, next: ResolveDocumentLinkSignature) => ProviderResult<VDocumentLink>;
|
||||
workspace?: WorkspaceMiddleware;
|
||||
}
|
||||
export interface LanguageClientOptions {
|
||||
documentSelector?: DocumentSelector | string[];
|
||||
synchronize?: SynchronizeOptions;
|
||||
diagnosticCollectionName?: string;
|
||||
outputChannel?: OutputChannel;
|
||||
outputChannelName?: string;
|
||||
revealOutputChannelOn?: RevealOutputChannelOn;
|
||||
/**
|
||||
* The encoding use to read stdout and stderr. Defaults
|
||||
* to 'utf8' if ommitted.
|
||||
*/
|
||||
stdioEncoding?: string;
|
||||
initializationOptions?: any | (() => any);
|
||||
initializationFailedHandler?: InitializationFailedHandler;
|
||||
errorHandler?: ErrorHandler;
|
||||
middleware?: Middleware;
|
||||
uriConverters?: {
|
||||
code2Protocol: c2p.URIConverter;
|
||||
protocol2Code: p2c.URIConverter;
|
||||
};
|
||||
workspaceFolder?: VWorkspaceFolder;
|
||||
}
|
||||
export declare enum State {
|
||||
Stopped = 1,
|
||||
Running = 2,
|
||||
}
|
||||
export interface StateChangeEvent {
|
||||
oldState: State;
|
||||
newState: State;
|
||||
}
|
||||
/**
|
||||
* A static feature. A static feature can't be dynamically activate via the
|
||||
* server. It is wired during the initialize sequence.
|
||||
*/
|
||||
export interface StaticFeature {
|
||||
/**
|
||||
* Called to fill the initialize params.
|
||||
*
|
||||
* @params the initialize params.
|
||||
*/
|
||||
fillInitializeParams?: (params: InitializeParams) => void;
|
||||
/**
|
||||
* Called to fill in the client capabilities this feature implements.
|
||||
*
|
||||
* @param capabilities The client capabilities to fill.
|
||||
*/
|
||||
fillClientCapabilities(capabilities: ClientCapabilities): void;
|
||||
/**
|
||||
* Initialize the feature. This method is called on a feature instance
|
||||
* when the client has successfully received the initalize request from
|
||||
* the server and before the client sends the initialized notification
|
||||
* to the server.
|
||||
*
|
||||
* @param capabilities the server capabilities
|
||||
* @param documentSelector the document selector pass to the client's constuctor.
|
||||
* May be `undefined` if the client was created without a selector.
|
||||
*/
|
||||
initialize(capabilities: ServerCapabilities, documentSelector: DocumentSelector | undefined): void;
|
||||
}
|
||||
export interface RegistrationData<T> {
|
||||
id: string;
|
||||
registerOptions: T;
|
||||
}
|
||||
export interface DynamicFeature<T> {
|
||||
/**
|
||||
* The message for which this features support dynamic activation / registration.
|
||||
*/
|
||||
messages: RPCMessageType | RPCMessageType[];
|
||||
/**
|
||||
* Called to fill the initialize params.
|
||||
*
|
||||
* @params the initialize params.
|
||||
*/
|
||||
fillInitializeParams?: (params: InitializeParams) => void;
|
||||
/**
|
||||
* Called to fill in the client capabilities this feature implements.
|
||||
*
|
||||
* @param capabilities The client capabilities to fill.
|
||||
*/
|
||||
fillClientCapabilities(capabilities: ClientCapabilities): void;
|
||||
/**
|
||||
* Initialize the feature. This method is called on a feature instance
|
||||
* when the client has successfully received the initalize request from
|
||||
* the server and before the client sends the initialized notification
|
||||
* to the server.
|
||||
*
|
||||
* @param capabilities the server capabilities.
|
||||
* @param documentSelector the document selector pass to the client's constuctor.
|
||||
* May be `undefined` if the client was created without a selector.
|
||||
*/
|
||||
initialize(capabilities: ServerCapabilities, documentSelector: DocumentSelector | undefined): void;
|
||||
/**
|
||||
* Is called when the server send a register request for the given message.
|
||||
*
|
||||
* @param message the message to register for.
|
||||
* @param data additional registration data as defined in the protocol.
|
||||
*/
|
||||
register(message: RPCMessageType, data: RegistrationData<T>): void;
|
||||
/**
|
||||
* Is called when the server wants to unregister a feature.
|
||||
*
|
||||
* @param id the id used when registering the feature.
|
||||
*/
|
||||
unregister(id: string): void;
|
||||
/**
|
||||
* Called when the client is stopped to dispose this feature. Usually a feature
|
||||
* unregisters listeners registerd hooked up with the VS Code extension host.
|
||||
*/
|
||||
dispose(): void;
|
||||
}
|
||||
export interface MessageTransports {
|
||||
reader: MessageReader;
|
||||
writer: MessageWriter;
|
||||
}
|
||||
export declare namespace MessageTransports {
|
||||
function is(value: any): value is MessageTransports;
|
||||
}
|
||||
export declare abstract class BaseLanguageClient {
|
||||
constructor(id: string, name: string, clientOptions: LanguageClientOptions);
|
||||
readonly initializeResult: InitializeResult | undefined;
|
||||
sendRequest<R, E, RO>(type: RequestType0<R, E, RO>, token?: CancellationToken): Thenable<R>;
|
||||
sendRequest<P, R, E, RO>(type: RequestType<P, R, E, RO>, params: P, token?: CancellationToken): Thenable<R>;
|
||||
sendRequest<R>(method: string, token?: CancellationToken): Thenable<R>;
|
||||
sendRequest<R>(method: string, param: any, token?: CancellationToken): Thenable<R>;
|
||||
onRequest<R, E, RO>(type: RequestType0<R, E, RO>, handler: RequestHandler0<R, E>): void;
|
||||
onRequest<P, R, E, RO>(type: RequestType<P, R, E, RO>, handler: RequestHandler<P, R, E>): void;
|
||||
onRequest<R, E>(method: string, handler: GenericRequestHandler<R, E>): void;
|
||||
sendNotification<RO>(type: NotificationType0<RO>): void;
|
||||
sendNotification<P, RO>(type: NotificationType<P, RO>, params?: P): void;
|
||||
sendNotification(method: string): void;
|
||||
sendNotification(method: string, params: any): void;
|
||||
onNotification<RO>(type: NotificationType0<RO>, handler: NotificationHandler0): void;
|
||||
onNotification<P, RO>(type: NotificationType<P, RO>, handler: NotificationHandler<P>): void;
|
||||
onNotification(method: string, handler: GenericNotificationHandler): void;
|
||||
readonly clientOptions: LanguageClientOptions;
|
||||
readonly protocol2CodeConverter: p2c.Converter;
|
||||
readonly code2ProtocolConverter: c2p.Converter;
|
||||
readonly onTelemetry: Event<any>;
|
||||
readonly onDidChangeState: Event<StateChangeEvent>;
|
||||
readonly outputChannel: OutputChannel;
|
||||
readonly diagnostics: DiagnosticCollection | undefined;
|
||||
createDefaultErrorHandler(): ErrorHandler;
|
||||
trace: Trace;
|
||||
info(message: string, data?: any): void;
|
||||
warn(message: string, data?: any): void;
|
||||
error(message: string, data?: any): void;
|
||||
needsStart(): boolean;
|
||||
needsStop(): boolean;
|
||||
onReady(): Promise<void>;
|
||||
start(): Disposable;
|
||||
stop(): Thenable<void>;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
registerFeatures(features: (StaticFeature | DynamicFeature<any>)[]): void;
|
||||
registerFeature(feature: StaticFeature | DynamicFeature<any>): void;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
logFailedRequest(type: RPCMessageType, error: any): void;
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
import * as code from './vscode';
|
||||
import * as proto from 'vscode-languageserver-protocol';
|
||||
export interface Converter {
|
||||
asUri(uri: code.Uri): string;
|
||||
asTextDocumentIdentifier(textDocument: code.TextDocument): proto.TextDocumentIdentifier;
|
||||
asOpenTextDocumentParams(textDocument: code.TextDocument): proto.DidOpenTextDocumentParams;
|
||||
asChangeTextDocumentParams(textDocument: code.TextDocument): proto.DidChangeTextDocumentParams;
|
||||
asChangeTextDocumentParams(event: code.TextDocumentChangeEvent): proto.DidChangeTextDocumentParams;
|
||||
asCloseTextDocumentParams(textDocument: code.TextDocument): proto.DidCloseTextDocumentParams;
|
||||
asSaveTextDocumentParams(textDocument: code.TextDocument, includeContent?: boolean): proto.DidSaveTextDocumentParams;
|
||||
asWillSaveTextDocumentParams(event: code.TextDocumentWillSaveEvent): proto.WillSaveTextDocumentParams;
|
||||
asTextDocumentPositionParams(textDocument: code.TextDocument, position: code.Position): proto.TextDocumentPositionParams;
|
||||
asWorkerPosition(position: code.Position): proto.Position;
|
||||
asPosition(value: code.Position): proto.Position;
|
||||
asPosition(value: undefined): undefined;
|
||||
asPosition(value: null): null;
|
||||
asPosition(value: code.Position | undefined | null): proto.Position | undefined | null;
|
||||
asRange(value: code.Range): proto.Range;
|
||||
asRange(value: undefined): undefined;
|
||||
asRange(value: null): null;
|
||||
asRange(value: code.Range | undefined | null): proto.Range | undefined | null;
|
||||
asDiagnosticSeverity(value: code.DiagnosticSeverity): number;
|
||||
asDiagnostic(item: code.Diagnostic): proto.Diagnostic;
|
||||
asDiagnostics(items: code.Diagnostic[]): proto.Diagnostic[];
|
||||
asCompletionItem(item: code.CompletionItem): proto.CompletionItem;
|
||||
asTextEdit(edit: code.TextEdit): proto.TextEdit;
|
||||
asReferenceParams(textDocument: code.TextDocument, position: code.Position, options: {
|
||||
includeDeclaration: boolean;
|
||||
}): proto.ReferenceParams;
|
||||
asCodeActionContext(context: code.CodeActionContext): proto.CodeActionContext;
|
||||
asCommand(item: code.Command): proto.Command;
|
||||
asCodeLens(item: code.CodeLens): proto.CodeLens;
|
||||
asFormattingOptions(item: code.FormattingOptions): proto.FormattingOptions;
|
||||
asDocumentSymbolParams(textDocument: code.TextDocument): proto.DocumentSymbolParams;
|
||||
asCodeLensParams(textDocument: code.TextDocument): proto.CodeLensParams;
|
||||
asDocumentLink(item: code.DocumentLink): proto.DocumentLink;
|
||||
asDocumentLinkParams(textDocument: code.TextDocument): proto.DocumentLinkParams;
|
||||
}
|
||||
export interface URIConverter {
|
||||
(value: code.Uri): string;
|
||||
}
|
||||
export declare function createConverter(uriConverter?: URIConverter): Converter;
|
|
@ -1,5 +0,0 @@
|
|||
import * as code from './vscode';
|
||||
export default class ProtocolCodeLens extends code.CodeLens {
|
||||
data: any;
|
||||
constructor(range: code.Range);
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
import * as code from './vscode';
|
||||
export default class ProtocolCompletionItem extends code.CompletionItem {
|
||||
data: any;
|
||||
fromEdit: boolean;
|
||||
constructor(label: string);
|
||||
}
|
|
@ -1,74 +0,0 @@
|
|||
import * as code from './vscode';
|
||||
import * as ls from 'vscode-languageserver-protocol';
|
||||
import ProtocolCompletionItem from './protocolCompletionItem';
|
||||
export interface Converter {
|
||||
asUri(value: string): code.Uri;
|
||||
asDiagnostic(diagnostic: ls.Diagnostic): code.Diagnostic;
|
||||
asDiagnostics(diagnostics: ls.Diagnostic[]): code.Diagnostic[];
|
||||
asPosition(value: undefined | null): undefined;
|
||||
asPosition(value: ls.Position): code.Position;
|
||||
asPosition(value: ls.Position | undefined | null): code.Position | undefined;
|
||||
asRange(value: undefined | null): undefined;
|
||||
asRange(value: ls.Range): code.Range;
|
||||
asRange(value: ls.Range | undefined | null): code.Range | undefined;
|
||||
asDiagnosticSeverity(value: number | undefined | null): code.DiagnosticSeverity;
|
||||
asHover(hover: ls.Hover): code.Hover;
|
||||
asHover(hover: undefined | null): undefined;
|
||||
asHover(hover: ls.Hover | undefined | null): code.Hover | undefined;
|
||||
asCompletionResult(result: ls.CompletionList): code.CompletionList;
|
||||
asCompletionResult(result: ls.CompletionItem[]): code.CompletionItem[];
|
||||
asCompletionResult(result: undefined | null): undefined;
|
||||
asCompletionResult(result: ls.CompletionItem[] | ls.CompletionList | undefined | null): code.CompletionItem[] | code.CompletionList | undefined;
|
||||
asCompletionItem(item: ls.CompletionItem): ProtocolCompletionItem;
|
||||
asTextEdit(edit: undefined | null): undefined;
|
||||
asTextEdit(edit: ls.TextEdit): code.TextEdit;
|
||||
asTextEdits(items: ls.TextEdit[]): code.TextEdit[];
|
||||
asTextEdits(items: undefined | null): undefined;
|
||||
asTextEdits(items: ls.TextEdit[] | undefined | null): code.TextEdit[] | undefined;
|
||||
asSignatureHelp(item: undefined | null): undefined;
|
||||
asSignatureHelp(item: ls.SignatureHelp): code.SignatureHelp;
|
||||
asSignatureHelp(item: ls.SignatureHelp | undefined | null): code.SignatureHelp | undefined;
|
||||
asSignatureInformation(item: ls.SignatureInformation): code.SignatureInformation;
|
||||
asSignatureInformations(items: ls.SignatureInformation[]): code.SignatureInformation[];
|
||||
asParameterInformation(item: ls.ParameterInformation): code.ParameterInformation;
|
||||
asParameterInformations(item: ls.ParameterInformation[]): code.ParameterInformation[];
|
||||
asDefinitionResult(item: ls.Definition): code.Definition;
|
||||
asDefinitionResult(item: undefined | null): undefined;
|
||||
asDefinitionResult(item: ls.Definition | undefined | null): code.Definition | undefined;
|
||||
asLocation(item: ls.Location): code.Location;
|
||||
asLocation(item: undefined | null): undefined;
|
||||
asLocation(item: ls.Location | undefined | null): code.Location | undefined;
|
||||
asReferences(values: ls.Location[]): code.Location[];
|
||||
asReferences(values: undefined | null): code.Location[] | undefined;
|
||||
asReferences(values: ls.Location[] | undefined | null): code.Location[] | undefined;
|
||||
asDocumentHighlightKind(item: number): code.DocumentHighlightKind;
|
||||
asDocumentHighlight(item: ls.DocumentHighlight): code.DocumentHighlight;
|
||||
asDocumentHighlights(values: ls.DocumentHighlight[]): code.DocumentHighlight[];
|
||||
asDocumentHighlights(values: undefined | null): undefined;
|
||||
asDocumentHighlights(values: ls.DocumentHighlight[] | undefined | null): code.DocumentHighlight[] | undefined;
|
||||
asSymbolInformation(item: ls.SymbolInformation, uri?: code.Uri): code.SymbolInformation;
|
||||
asSymbolInformations(values: ls.SymbolInformation[], uri?: code.Uri): code.SymbolInformation[];
|
||||
asSymbolInformations(values: undefined | null, uri?: code.Uri): undefined;
|
||||
asSymbolInformations(values: ls.SymbolInformation[] | undefined | null, uri?: code.Uri): code.SymbolInformation[] | undefined;
|
||||
asCommand(item: ls.Command): code.Command;
|
||||
asCommands(items: ls.Command[]): code.Command[];
|
||||
asCommands(items: undefined | null): undefined;
|
||||
asCommands(items: ls.Command[] | undefined | null): code.Command[] | undefined;
|
||||
asCodeLens(item: ls.CodeLens): code.CodeLens;
|
||||
asCodeLens(item: undefined | null): undefined;
|
||||
asCodeLens(item: ls.CodeLens | undefined | null): code.CodeLens | undefined;
|
||||
asCodeLenses(items: ls.CodeLens[]): code.CodeLens[];
|
||||
asCodeLenses(items: undefined | null): undefined;
|
||||
asCodeLenses(items: ls.CodeLens[] | undefined | null): code.CodeLens[] | undefined;
|
||||
asWorkspaceEdit(item: ls.WorkspaceEdit): code.WorkspaceEdit;
|
||||
asWorkspaceEdit(item: undefined | null): undefined;
|
||||
asWorkspaceEdit(item: ls.WorkspaceEdit | undefined | null): code.WorkspaceEdit | undefined;
|
||||
asDocumentLink(item: ls.DocumentLink): code.DocumentLink;
|
||||
asDocumentLinks(items: ls.DocumentLink[]): code.DocumentLink[];
|
||||
asDocumentLinks(items: undefined | null): undefined;
|
||||
asDocumentLinks(items: ls.DocumentLink[] | undefined | null): code.DocumentLink[] | undefined;
|
||||
}
|
||||
export interface URIConverter {
|
||||
(value: string): code.Uri;
|
||||
}
|
||||
export declare function createConverter(uriConverter?: URIConverter): Converter;
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,24 +0,0 @@
|
|||
import { WorkspaceFoldersChangeEvent as VWorkspaceFoldersChangeEvent } from './vscode';
|
||||
import { DynamicFeature, RegistrationData, BaseLanguageClient, NextSignature } from './client';
|
||||
import { ClientCapabilities, InitializedParams, Proposed, RPCMessageType } from 'vscode-languageserver-protocol';
|
||||
export interface WorkspaceFolderMiddleware {
|
||||
workspace?: {
|
||||
workspaceFolders?: Proposed.WorkspaceFoldersRequest.MiddlewareSignature;
|
||||
didChangeWorkspaceFolders?: NextSignature<VWorkspaceFoldersChangeEvent, void>;
|
||||
};
|
||||
}
|
||||
export declare class WorkspaceFoldersFeature implements DynamicFeature<undefined> {
|
||||
private _client;
|
||||
private _listeners;
|
||||
constructor(_client: BaseLanguageClient);
|
||||
readonly messages: RPCMessageType;
|
||||
fillInitializeParams(params: InitializedParams): void;
|
||||
fillClientCapabilities(capabilities: ClientCapabilities): void;
|
||||
initialize(): void;
|
||||
register(_message: RPCMessageType, data: RegistrationData<undefined>): void;
|
||||
unregister(id: string): void;
|
||||
dispose(): void;
|
||||
private asProtocol(workspaceFolder);
|
||||
private asProtocol(workspaceFolder);
|
||||
private getWorkspaceFolderMiddleware();
|
||||
}
|
Загрузка…
Ссылка в новой задаче