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

Syntax highlighting bug #3

Closed
rossburton opened this issue Apr 14, 2016 · 3 comments
Closed

Syntax highlighting bug #3

rossburton opened this issue Apr 14, 2016 · 3 comments
Labels

Comments

@rossburton
Copy link

The following bbclass snipped causes the highlighting to go all wrong. Note how the FOO=bar assignments are coloured differently under language-bb.

FOO = "bar"

def some_python_function(d):
    bb.warn(u"PE = %s", "epoch")

FOO = "bar"

The highlighting parser sees PE = in the python block and decides that its a bitbake variable assignment.

@ghost ghost added the bug label Apr 14, 2016
@ghost
Copy link

ghost commented Apr 14, 2016

Thanks for the report.

After a little bit of testing I noticed that adding a space before the first double quote in the python function lets language-bb highlight the function correctly:

FOO = "bar"

def some_python_function(d):
    bb.warn(u "PE = %s", "epoch")

FOO = "bar"

Therefore it seems there's something wrong with the string/double-quote parsing.

@ghost ghost closed this as completed in 204832c Apr 15, 2016
@rossburton
Copy link
Author

I've replaced my 0.2.1 install of language-bb with a git clone but this still breaks for me.

The original source of the bad formatting was meta/classes/buildhistory.bbclass, in the write_recipeinfo function (oe-core git master).

@ghost
Copy link

ghost commented Apr 15, 2016

Thanks for testing, you're right. The following snippet is still parsed incorrectly:

FOO = "bar"

def write_recipehistory(rcpinfo, d):
    import codecs

    bb.debug(2, "Writing recipe history")

    pkghistdir = d.getVar('BUILDHISTORY_DIR_PACKAGE', True)

    infofile = os.path.join(pkghistdir, "latest")
    with codecs.open(infofile, "w", encoding='utf8') as f:
        if rcpinfo.pe != "0":
            f.write(u"PE = %s\n" %  rcpinfo.pe)
        f.write(u"PV = %s\n" %  rcpinfo.pv)
        f.write(u"PR = %s\n" %  rcpinfo.pr)
        f.write(u"DEPENDS = %s\n" %  rcpinfo.depends)
        f.write(u"PACKAGES = %s\n" %  rcpinfo.packages)

FOO = "bar"

Looks like that problem is caused by the empty newline in the python function.
Following snippet is parsed correctly:

FOO = "bar"

def write_recipehistory(rcpinfo, d):
    import codecs
    bb.debug(2, "Writing recipe history")
    pkghistdir = d.getVar('BUILDHISTORY_DIR_PACKAGE', True)
    infofile = os.path.join(pkghistdir, "latest")
    with codecs.open(infofile, "w", encoding='utf8') as f:
        if rcpinfo.pe != "0":
            f.write(u"PE = %s\n" %  rcpinfo.pe)
        f.write(u"PV = %s\n" %  rcpinfo.pv)
        f.write(u"PR = %s\n" %  rcpinfo.pr)
        f.write(u"DEPENDS = %s\n" %  rcpinfo.depends)
        f.write(u"PACKAGES = %s\n" %  rcpinfo.packages)

FOO = "bar"

@ghost ghost reopened this Apr 15, 2016
@ghost ghost closed this as completed in 004a229 Apr 15, 2016
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant