function formatPlanstToDiag()

in vscode-extension/src/diagnostic.ts [59:96]


function formatPlanstToDiag(plansStr: string, log: Logger): vscode.Diagnostic[] {
    let plans: UpgradePlan[];
    try {
        plans = JSON.parse(plansStr);
    }
    catch {
        log.writeError("The result of Migration is wrong!");
        return [];
    }

    const diagnostics: vscode.Diagnostic[] = [];
    plans.forEach(
        plan => {
            const range = new vscode.Range(new vscode.Position(plan.SourceCommand.StartLine - 1, plan.SourceCommand.StartColumn - 1),
                new vscode.Position(plan.SourceCommand.EndLine - 1, plan.SourceCommand.EndPosition - 1));
            const message = plan.PlanResultReason;
            const diagnostic = new vscode.Diagnostic(range, message);
            if (plan.PlanSeverity == 1) {
                diagnostic.severity = vscode.DiagnosticSeverity.Error;
                diagnostic.code = "DO_NOTHING";
                diagnostic.source = '';
            }
            else if (plan.PlanSeverity == 2) {
                diagnostic.severity = vscode.DiagnosticSeverity.Information;
                diagnostic.code = "DO_NOTHING";
                diagnostic.source = '';
            }
            else {	//plan.PlanSeverity == 3
                diagnostic.severity = vscode.DiagnosticSeverity.Warning;
                diagnostic.code = "RENAME";
                diagnostic.source = plan.Replacement;
            }
            diagnostics.push(diagnostic);
        }
    );

    return diagnostics;
}