Lsp: Any way to raise a warning when calling a deprecated class/method?

Created on 28 Feb 2020  Â·  3Comments  Â·  Source: sublimelsp/LSP

Hi! I was wondering if it could be a way to show a warning when calling a deprecated class, method, or whatever deprecable symbol. There is some code that I would write in another way if I had a report on that.

enhancement

Most helpful comment

There is also depreacted tags for diagnostics.

export interface Diagnostic {
    /**
     * Additional metadata about the diagnostic.
     *
     * @since 3.15.0
     */
    tags?: DiagnosticTag[];
}

/**
 * The diagnostic tags.
 *
 * @since 3.15.0
 */
export namespace DiagnosticTag {
    /**
     * Unused or unnecessary code.
     *
     * Clients are allowed to render diagnostics with this tag faded out instead of having
     * an error squiggle.
     */
    export const Unnecessary: 1 = 1;
    /**
     * Deprecated or obsolete code.
     *
     * Clients are allowed to rendered diagnostics with this tag strike through.
     */
    export const Deprecated: 2 = 2;
}

So we could use that information to show a inline phantom to show a warning sign âš  like so:
2020-02-29-104354_1326x728_scrot
Note - new âš Person()

All 3 comments

Yes, there is a way :)

dasd

This PR https://github.com/sublimelsp/LSP/pull/866 will provide the deprecatedSupport LSP spec.

        /**
         * Client supports the deprecated property on a completion item.
         */
        deprecatedSupport?: boolean;

But because the CompletionItem.deprecated is actually deprecated :)

CompletionItem {
    /**
     * Indicates if this item is deprecated.
     *
     * @deprecated Use `tags` instead if supported.
     */
    deprecated?: boolean;
}

It is still used in servers like metals, rls.
In the future there could be an a follow up PR that would add support for CompletionItemTag :)

There is also depreacted tags for diagnostics.

export interface Diagnostic {
    /**
     * Additional metadata about the diagnostic.
     *
     * @since 3.15.0
     */
    tags?: DiagnosticTag[];
}

/**
 * The diagnostic tags.
 *
 * @since 3.15.0
 */
export namespace DiagnosticTag {
    /**
     * Unused or unnecessary code.
     *
     * Clients are allowed to render diagnostics with this tag faded out instead of having
     * an error squiggle.
     */
    export const Unnecessary: 1 = 1;
    /**
     * Deprecated or obsolete code.
     *
     * Clients are allowed to rendered diagnostics with this tag strike through.
     */
    export const Deprecated: 2 = 2;
}

So we could use that information to show a inline phantom to show a warning sign âš  like so:
2020-02-29-104354_1326x728_scrot
Note - new âš Person()

I'm closing this because it's implemented in ST4 for completion items. For the case of diagnostic tags, continue the conversation in the linked issue above.

Was this page helpful?
0 / 5 - 0 ratings