Adding explicit returns

This commit is contained in:
Matt Bierner
2017-02-01 17:06:13 -08:00
parent f1abc274df
commit 406014ae97
20 changed files with 71 additions and 22 deletions

View File

@@ -270,6 +270,7 @@ export class ExtHostApiCommands {
if (Array.isArray(value)) {
return value.map(typeConverters.location.to);
}
return undefined;
});
}
@@ -282,6 +283,7 @@ export class ExtHostApiCommands {
if (Array.isArray(value)) {
return value.map(typeConverters.location.to);
}
return undefined;
});
}
@@ -294,6 +296,7 @@ export class ExtHostApiCommands {
if (Array.isArray(value)) {
return value.map(typeConverters.toHover);
}
return undefined;
});
}
@@ -306,6 +309,7 @@ export class ExtHostApiCommands {
if (Array.isArray(value)) {
return value.map(typeConverters.toDocumentHighlight);
}
return undefined;
});
}
@@ -318,6 +322,7 @@ export class ExtHostApiCommands {
if (Array.isArray(value)) {
return value.map(typeConverters.location.to);
}
return undefined;
});
}
@@ -329,7 +334,7 @@ export class ExtHostApiCommands {
};
return this._commands.executeCommand<modes.WorkspaceEdit>('_executeDocumentRenameProvider', args).then(value => {
if (!value) {
return;
return undefined;
}
if (value.rejectReason) {
return TPromise.wrapError(value.rejectReason);
@@ -352,6 +357,7 @@ export class ExtHostApiCommands {
if (value) {
return typeConverters.SignatureHelp.to(value);
}
return undefined;
});
}
@@ -366,6 +372,7 @@ export class ExtHostApiCommands {
const items = result.suggestions.map(suggestion => typeConverters.Suggest.to(position, suggestion));
return new types.CompletionList(items, result.incomplete);
}
return undefined;
});
}
@@ -377,6 +384,7 @@ export class ExtHostApiCommands {
if (value && Array.isArray(value.entries)) {
return value.entries.map(typeConverters.SymbolInformation.fromOutlineEntry);
}
return undefined;
});
}
@@ -387,7 +395,7 @@ export class ExtHostApiCommands {
};
return this._commands.executeCommand<modes.CodeAction[]>('_executeCodeActionProvider', args).then(value => {
if (!Array.isArray(value)) {
return;
return undefined;
}
return value.map(quickFix => this._commands.converter.fromInternal(quickFix.command));
});
@@ -403,6 +411,7 @@ export class ExtHostApiCommands {
this._commands.converter.fromInternal(item.symbol.command));
});
}
return undefined;
});
}
@@ -415,6 +424,7 @@ export class ExtHostApiCommands {
if (Array.isArray(value)) {
return value.map(edit => new types.TextEdit(typeConverters.toRange(edit.range), edit.text));
}
return undefined;
});
}
@@ -428,6 +438,7 @@ export class ExtHostApiCommands {
if (Array.isArray(value)) {
return value.map(edit => new types.TextEdit(typeConverters.toRange(edit.range), edit.text));
}
return undefined;
});
}
@@ -442,6 +453,7 @@ export class ExtHostApiCommands {
if (Array.isArray(value)) {
return value.map(edit => new types.TextEdit(typeConverters.toRange(edit.range), edit.text));
}
return undefined;
});
}
@@ -450,6 +462,7 @@ export class ExtHostApiCommands {
if (Array.isArray(value)) {
return value.map(typeConverters.DocumentLink.to);
}
return undefined;
});
}
}

View File

@@ -166,7 +166,7 @@ export class CommandsConverter {
toInternal(command: vscode.Command): modes.Command {
if (!command) {
return;
return undefined;
}
const result: modes.Command = {
@@ -191,7 +191,7 @@ export class CommandsConverter {
fromInternal(command: modes.Command): vscode.Command {
if (!command) {
return;
return undefined;
}
const id = ObjectIdentifier.of(command);

View File

@@ -40,6 +40,7 @@ class OutlineAdapter {
if (Array.isArray(value)) {
return value.map(TypeConverters.SymbolInformation.toOutlineEntry);
}
return undefined;
});
}
}
@@ -64,7 +65,6 @@ class CodeLensAdapter {
const doc = this._documents.getDocumentData(resource).document;
return asWinJsPromise(token => this._provider.provideCodeLenses(doc, token)).then(lenses => {
if (Array.isArray(lenses)) {
return lenses.map(lens => {
const id = this._heapService.keep(lens);
@@ -74,6 +74,7 @@ class CodeLensAdapter {
}, id);
});
}
return undefined;
});
}
@@ -81,7 +82,7 @@ class CodeLensAdapter {
const lens = this._heapService.get<vscode.CodeLens>(ObjectIdentifier.of(symbol));
if (!lens) {
return;
return undefined;
}
let resolve: TPromise<vscode.CodeLens>;
@@ -118,6 +119,7 @@ class DefinitionAdapter {
} else if (value) {
return TypeConverters.location.from(value);
}
return undefined;
});
}
}
@@ -141,6 +143,7 @@ class ImplementationAdapter {
} else if (value) {
return TypeConverters.location.from(value);
}
return undefined;
});
}
}
@@ -162,7 +165,7 @@ class HoverAdapter {
return asWinJsPromise(token => this._provider.provideHover(doc, pos, token)).then(value => {
if (!value) {
return;
return undefined;
}
if (!value.range) {
value.range = doc.getWordRangeAtPosition(pos);
@@ -195,6 +198,7 @@ class DocumentHighlightAdapter {
if (Array.isArray(value)) {
return value.map(DocumentHighlightAdapter._convertDocumentHighlight);
}
return undefined;
});
}
@@ -224,6 +228,7 @@ class ReferenceAdapter {
if (Array.isArray(value)) {
return value.map(TypeConverters.location.from);
}
return undefined;
});
}
}
@@ -260,7 +265,7 @@ class QuickFixAdapter {
return asWinJsPromise(token => this._provider.provideCodeActions(doc, ran, { diagnostics: allDiagnostics }, token)).then(commands => {
if (!Array.isArray(commands)) {
return;
return undefined;
}
return commands.map((command, i) => {
return <modes.CodeAction>{
@@ -290,6 +295,7 @@ class DocumentFormattingAdapter {
if (Array.isArray(value)) {
return value.map(TypeConverters.TextEdit.from);
}
return undefined;
});
}
}
@@ -313,6 +319,7 @@ class RangeFormattingAdapter {
if (Array.isArray(value)) {
return value.map(TypeConverters.TextEdit.from);
}
return undefined;
});
}
}
@@ -338,6 +345,7 @@ class OnTypeFormattingAdapter {
if (Array.isArray(value)) {
return value.map(TypeConverters.TextEdit.from);
}
return undefined;
});
}
}
@@ -363,6 +371,7 @@ class NavigateTypeAdapter implements IWorkspaceSymbolProvider {
return ObjectIdentifier.mixin(result, id);
});
}
return undefined;
});
}
@@ -378,6 +387,7 @@ class NavigateTypeAdapter implements IWorkspaceSymbolProvider {
return value && TypeConverters.fromSymbolInformation(value);
});
}
return undefined;
}
}
@@ -397,9 +407,8 @@ class RenameAdapter {
let pos = TypeConverters.toPosition(position);
return asWinJsPromise(token => this._provider.provideRenameEdits(doc, pos, newName, token)).then(value => {
if (!value) {
return;
return undefined;
}
let result = <modes.WorkspaceEdit>{
@@ -458,7 +467,7 @@ class SuggestAdapter {
let list: CompletionList;
if (!value) {
// undefined and null are valid results
return;
return undefined;
} else if (Array.isArray(value)) {
list = new CompletionList(value);
@@ -523,7 +532,7 @@ class SuggestAdapter {
private _convertCompletionItem(item: vscode.CompletionItem, position: vscode.Position, defaultRange: vscode.Range): modes.ISuggestion {
if (!item.label) {
console.warn('INVALID text edit -> must have at least a label');
return;
return undefined;
}
const result: modes.ISuggestion = {
@@ -573,7 +582,7 @@ class SuggestAdapter {
if (!range.isSingleLine || range.start.line !== position.line) {
console.warn('INVALID text edit -> must be single line and on the same line');
return;
return undefined;
}
return result;
@@ -599,6 +608,7 @@ class SignatureHelpAdapter {
if (value) {
return TypeConverters.SignatureHelp.from(value);
}
return undefined;
});
}
}
@@ -620,6 +630,7 @@ class LinkProviderAdapter {
if (Array.isArray(links)) {
return links.map(TypeConverters.DocumentLink.from);
}
return undefined;
});
}
@@ -629,8 +640,10 @@ class LinkProviderAdapter {
if (value) {
return TypeConverters.DocumentLink.from(value);
}
return undefined;
});
}
return undefined;
}
}

View File

@@ -61,15 +61,15 @@ export class MainThreadQuickOpen extends MainThreadQuickOpenShape {
$setItems(items: MyQuickPickItems[]): Thenable<any> {
if (this._doSetItems) {
this._doSetItems(items);
return;
}
return undefined;
}
$setError(error: Error): Thenable<any> {
if (this._doSetError) {
this._doSetError(error);
return;
}
return undefined;
}
// ---- input

View File

@@ -48,7 +48,7 @@ export class MainThreadWorkspace extends MainThreadWorkspaceShape {
$startSearch(include: string, exclude: string, maxResults: number, requestId: number): Thenable<Uri[]> {
const workspace = this._contextService.getWorkspace();
if (!workspace) {
return;
return undefined;
}
const search = this._searchService.search({
@@ -63,6 +63,7 @@ export class MainThreadWorkspace extends MainThreadWorkspaceShape {
if (!isPromiseCanceledError(err)) {
return TPromise.wrapError(err);
}
return undefined;
});
this._activeSearches[requestId] = search;
@@ -79,6 +80,7 @@ export class MainThreadWorkspace extends MainThreadWorkspaceShape {
search.cancel();
return TPromise.as(true);
}
return undefined;
}
$saveAll(includeUntitled?: boolean): Thenable<boolean> {