frontend: Highlight lines with error#114
Conversation
|
firebase-deployment: https://evy-lang--114-qbhffxqh.web.app (3e57c20) |
Lint CSS with stylelint, use --fix flag and manually fix 5 remaining
errors. We are not making stylelint part of the build process with
`make ci` yet, because it requires the setup of a node module :(.
We will follow up once we add bundling.
Style line was installed with:
npm init # yesyesyes
npm init stylelint
# add `"rules": { "rule-empty-line-before": "never" }` .stylelintrc.json
npx stylelint --fix "**/*.css"
The only violated rule that couldn't be auto-fixed was
`no-descending-specificity`: "Disallow selectors of lower specificity
from coming after overriding selectors of higher specificity." Fair
enough this has bitten me before.
Link: https://stylelint.io/user-guide/rules/no-descending-specificity
camh-
left a comment
There was a problem hiding this comment.
Looks all javascripty to me. 🥒
I note the PR description and second commit message says: "Evy files with more than 700ish files are starting to get janky" - I think that is meant to be "700ish lines".
Highlight lines with evy errors in editor. This is done by finding the correct token by its line and columns and adding the "err" CSS class to it. It is becoming increasingly obvious that a more fully fledged web code editor will be needed. Evy files with more than 700ish lines are starting to get janky when editing. I could work around this by only updating the relevant lines, but it all seems to get a bit to hacky. After this error highlight addition we will leave editor hacking for now.
camh-
left a comment
There was a problem hiding this comment.
LGTM. just a comment; feel free to ignore
camh-
left a comment
There was a problem hiding this comment.
LGTM. just a comment; feel free to ignore...
| if !paramType.Accepts(argType) && !paramType.Matches(argType) { | ||
| p.appendError("'" + funcName + "' takes " + ordinalize(i+1) + " argument of type '" + paramType.String() + "', found '" + argType.String() + "'") | ||
| msg := fmt.Sprintf("'%s' takes %s argument of type '%s', found '%s'", funcName, ordinalize(i+1), paramType.String(), argType.String()) | ||
| p.appendErrorForToken(msg, arg.Token()) |
There was a problem hiding this comment.
in my local proof of concept, I went a bit further and also added the token to the two other errors in this function:
if !paramType.Accepts(argType) && !paramType.Matches(argType) {
- p.appendError("'" + funcName + "' takes variadic arguments of type '" + paramType.String() + "', found '" + argType.String() + "'")
+ p.appendErrorForToken("'"+funcName+"' takes variadic arguments of type '"+paramType.String()+"', found '"+argType.String()+"'", arg.Tok())
}
and
if len(decl.Params) != len(args) {
- p.appendError("'" + funcName + "' takes " + quantify(len(decl.Params), "argument") + ", found " + strconv.Itoa(len(args)))
+ tok := p.cur
+ if len(args) > len(decl.Params) {
+ tok = args[len(decl.Params)].Tok()
+ }
+ p.appendErrorForToken("'"+funcName+"' takes "+quantify(len(decl.Params), "argument")+", found "+strconv.Itoa(len(args)), tok)
return
}
There was a problem hiding this comment.
all addressed. thank you!
(I had a mental note of doing this and then I forgot. busy mind)
Add Token() to ast Node interface so that we can more accurately pinpoint the error position, e.g.: func numf n:num print n end numf "abc" The example above only highlighted the end of line with the `numf` with a message saying first argument is of wrong type, but now it also highlights `"abc"` correctly. This is still problematic for error sources that are whole nodes, e.g.: numf "abc"+"123" Should probably highlight all of `"abc"+"123"` rather than just the first token. However, the might end up as undesired result for _very_ long expressions or multiline array / map literals.
Highlight lines with evy errors in editor. This is done by finding the
correct token by its line and columns and adding the "err" CSS class to it.
It is becoming increasingly obvious that a more fully fledged web code
editor will be needed. Evy files with more than 700ish lines are starting
to get janky when editing. I could work around this by only updating the
relevant lines, but it all seems to get a bit to hacky.
housekeeping: Do a one-off lint pass with stylelint of CSS(requires node
to which I'm not yet ready to commit.)