Giter Site home page Giter Site logo

Comments (5)

msujew avatar msujew commented on September 26, 2024

It's not a bug, it's a feature, see:

protected performNextTokenCompletion(document: LangiumDocument, text: string, _offset: number, _end: number): boolean {
// This regex returns false if the text ends with a letter.
// We don't want to complete new text immediately after a keyword, ID etc.
// We only care about the last character in the text, so we use $ here.
// The \P{L} used here is a Unicode category that matches any character that is not a letter
return /\P{L}$/u.test(text);
}

from langium.

cdietrich avatar cdietrich commented on September 26, 2024

i will check

from langium.

cdietrich avatar cdietrich commented on September 26, 2024

i wonder if we can have access to both the current and following token.
thus we can decide if we need a space between two alphanumeric things or not.
or should this be done in completionFor ?

from langium.

cdietrich avatar cdietrich commented on September 26, 2024

this is also hard to achieve. backtrackToAnyToken wont give a whitespace token

something like

    protected override async completionFor(context: CompletionContext, next: NextFeature<GrammarAST.AbstractElement>, acceptor: CompletionAcceptor): Promise<void> {
        const { nextTokenStart, previousTokenStart, previousTokenEnd } = this.backtrackToAnyToken(context.textDocument.getText(), context.tokenEndOffset)
        if (previousTokenEnd === nextTokenStart) {
            const x = context.textDocument.getText().slice(previousTokenStart, previousTokenEnd)
            if (HelloWorldCompletionProvider.AllKeywords.has(x)) {
                if (GrammarAST.isKeyword(next.feature)) {
                    const kw = next.feature.value
                    if (/^[a-z0-9]+$/i.test(kw.charAt(0))) {
                        return;
                    }
                } else {
                    return;
                }
            }
        }
        
        await super.completionFor(context, next, acceptor)
    }

seems to work

from langium.

cdietrich avatar cdietrich commented on September 26, 2024

pot. workaround: adjust keyword completion to add the :

from langium.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.