Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CLOSED] Extending support for existing languages #2863

Open
core-ai-bot opened this issue Aug 29, 2021 · 7 comments
Open

[CLOSED] Extending support for existing languages #2863

core-ai-bot opened this issue Aug 29, 2021 · 7 comments

Comments

@core-ai-bot
Copy link
Member

Issue by MarkMurphy
Tuesday Mar 05, 2013 at 14:46 GMT
Originally opened as adobe/brackets#3044


If I wanted to make an extension that offers tag & attribute hinting for SVG I'd ideally be able to un-register ".svg" from the "xml" language and declare a new "svg" language to take over it. (For code hinting specifically, you could do hacks to avoid defining a new language, but ultimately that approach will probably hit a wall).

The more specific formats we add to our languages, the more likely this is to become an issue. But as with my SVG example above, it's possible to hit this issue even on current master.

This issue was initially discovered here: adobe/brackets#3029 (diff)

@core-ai-bot
Copy link
Member Author

Comment by DennisKehrig
Tuesday Mar 05, 2013 at 14:57 GMT


I now wonder whether a file can actually have multiple languages. An SVG file doesn't stop being an XML file, after all. So maybe languages can inherit from other languages? If a child language defines a file extension that the parent uses, too, the child language is preferred.

@core-ai-bot
Copy link
Member Author

Comment by MarkMurphy
Tuesday Mar 05, 2013 at 15:32 GMT


@DennisKehrig Interesting. I can't think of any reason or use case where that would cause a problem. So assuming your proposal would solve the issue at hand, can you provide an example of how that would work in code?

@core-ai-bot
Copy link
Member Author

Comment by DennisKehrig
Wednesday Mar 06, 2013 at 14:45 GMT


I'm working on something like this:

    LanguageManager.defineLanguage("svg", {
        parent: "xml",
        name: "SVG",
        fileExtensions: ["svg"]
    })

@core-ai-bot
Copy link
Member Author

Comment by MarkMurphy
Wednesday Mar 06, 2013 at 15:06 GMT


@DennisKehrig looks good. Would it make more sense to rename "parent" to "extends" as in oop?

@core-ai-bot
Copy link
Member Author

Comment by DennisKehrig
Wednesday Mar 06, 2013 at 17:18 GMT


@MarkMurphy Thanks! "extends" is what I had first, but SciTE highlighted it differently because it's actually a reserved word in JavaScript. So to avoid any issues I wanted an alternative. Seeing how the other keys are not descriptions of what the language does (SVG extends XML), but what the language has (a name, a mode, a comment syntax, ...), "parent" seemed to fit in great, especially since it then goes along with a _setParent method.

@core-ai-bot
Copy link
Member Author

Comment by njx
Wednesday Mar 06, 2013 at 19:05 GMT


Reviewed. Marking low priority, but since@DennisKehrig already has a potential solution,@peterflynn will review when he has a chance.

@core-ai-bot
Copy link
Member Author

Comment by peterflynn
Friday Apr 04, 2014 at 00:00 GMT


Closing -- in Sprint 38 it's possible to unregister a file extension and register it to a new language, and as noted above this can also be resolved by just writing a code hint provider that registers for the built-in "xml" language but only responds when in SVG content.

In the future we may start seeing use cases where solutions like that aren't adequate, but in the year since we originally raised this question we haven't hit any yet, so I think it's safe to close this and reopen or refile later when/if we run into it.

(See also further thoughts here: adobe/brackets#3052 (comment))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant