/*---------------------------------------------------------
 * Copyright (C) Microsoft Corporation. All rights reserved.
 *--------------------------------------------------------*/
'use strict';
var __extends = (this && this.__extends) || function (d, b) {
    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
    function __() { this.constructor = d; }
    __.prototype = b.prototype;
    d.prototype = new __();
};
define(["require", "exports", './abstractSupport', '../protocol', 'monaco'], function (require, exports, abstractSupport_1, Protocol, monaco) {
    var ReferenceSupport = (function (_super) {
        __extends(ReferenceSupport, _super);
        function ReferenceSupport() {
            _super.apply(this, arguments);
            this.tokens = ['identifier.cs'];
        }
        ReferenceSupport.prototype.findReferences = function (resource, position, includeDeclaration) {
            if (this.isInMemory(resource)) {
                return monaco.Promise.as([]);
            }
            return this.server().makeRequest(Protocol.FindUsages, {
                Filename: resource.fsPath,
                Line: position.lineNumber,
                Column: position.column,
                OnlyThisFile: false,
                ExcludeDefinition: false
            }).then(function (res) {
                return !res || !Array.isArray(res.QuickFixes)
                    ? []
                    : res.QuickFixes.map(ReferenceSupport.asReference);
            });
        };
        ReferenceSupport.asReference = function (quickFix) {
            return {
                resourceUrl: new monaco.URL(monaco.URI.file(quickFix.FileName)),
                range: {
                    startLineNumber: quickFix.Line,
                    startColumn: quickFix.Column,
                    endLineNumber: quickFix.EndLine,
                    endColumn: quickFix.EndColumn
                }
            };
        };
        return ReferenceSupport;
    })(abstractSupport_1.default);
    exports.default = ReferenceSupport;
});
