util#isNullOrUndefined TypeScript Examples

The following examples show how to use util#isNullOrUndefined. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: codeActions.ts    From vscode-groovy-lint with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Provide quick-fixes for a piece of code  *
 * @export
 * @param {TextDocument} textDocument
 * @param {CodeActionParams} parms
 * @returns {CodeAction[]}
 */
export function provideQuickFixCodeActions(textDocument: TextDocument, codeActionParams: CodeActionParams, docQuickFixes: any): CodeAction[] {
	const diagnostics = codeActionParams.context.diagnostics;
	const quickFixCodeActions: CodeAction[] = [];
	if (isNullOrUndefined(diagnostics) || diagnostics.length === 0) {
		return quickFixCodeActions;
	}
	// Browse diagnostics to get related CodeActions
	for (const diagnostic of codeActionParams.context.diagnostics) {
		// Skip Diagnostics not from VsCodeGroovyLint
		if (diagnostic.source !== 'GroovyLint') {
			continue;
		}
		// Get corresponding QuickFix if existing and convert it as QuickAction
		const diagCode: string = diagnostic.code + '';
		if (docQuickFixes && docQuickFixes[diagCode]) {
			for (const quickFix of docQuickFixes[diagCode]) {
				const codeActions = createQuickFixCodeActions(diagnostic, quickFix, textDocument.uri);
				quickFixCodeActions.push(...codeActions);
			}
		}
		// Add Ignores for this error
		const disableActions = createDisableActions(diagnostic, textDocument.uri);
		quickFixCodeActions.push(...disableActions);
		const viewDocAction = createViewDocAction(diagnostic, textDocument.uri);
		if (viewDocAction) {
			quickFixCodeActions.push(viewDocAction);
		}
	}
	debug(`Provided ${quickFixCodeActions.length} codeActions for ${textDocument.uri}`);
	return quickFixCodeActions;
}
Example #2
Source File: file_export.ts    From grafana-chinese with Apache License 2.0 6 votes vote down vote up
function formatRow(row: any[], addEndRowDelimiter = true) {
  let text = '';
  for (let i = 0; i < row.length; i += 1) {
    if (isBoolean(row[i]) || isNumber(row[i]) || isNullOrUndefined(row[i])) {
      text += row[i];
    } else {
      text += `${QUOTE}${csvEscaped(htmlUnescaped(htmlDecoded(row[i])))}${QUOTE}`;
    }

    if (i < row.length - 1) {
      text += END_COLUMN;
    }
  }
  return addEndRowDelimiter ? text + END_ROW : text;
}