Skip to content

Commit

Permalink
Fine tuning new linter code
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhill committed Apr 2, 2023
1 parent cda3970 commit 95bd52d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
6 changes: 4 additions & 2 deletions src/css/codemirror.css
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@
align-items: center;
display: inline-flex;
flex-grow: 0;
font-size: 95%;
font-size: var(--font-size-smaller);
min-width: 6em;
visibility: hidden;
}
Expand All @@ -206,15 +206,17 @@
}

.cm-linter-widget {
align-items: center;
display: none;
flex-grow: 1;
}
.cm-linter-widget.hasErrors {
display: initial;
display: inline-flex;
}
.cm-linter-widget .cm-linter-widget-count {
color: var(--accent-surface-1);
fill: var(--accent-surface-1);
font-size: var(--font-size-smaller);
}

.cm-searching.cm-overlay {
Expand Down
13 changes: 11 additions & 2 deletions src/js/codemirror/ubo-static-filtering.js
Original file line number Diff line number Diff line change
Expand Up @@ -729,12 +729,21 @@ CodeMirror.registerHelper('fold', 'ubo-static-filtering', (( ) => {
if ( astParser.isCosmeticFilter() && astParser.result.error ) {
return `${error}: ${astParser.result.error}`;
}
if ( astParser.astError === sfp.AST_ERROR_BAD_REGEX ) {
if ( astParser.astError === sfp.AST_ERROR_REGEX ) {
return `${error}: Bad regular expression`;
}
if ( astParser.astError === sfp.AST_ERROR_BAD_PATTERN ) {
if ( astParser.astError === sfp.AST_ERROR_PATTERN ) {
return `${error}: Bad pattern`;
}
if ( astParser.astError === sfp.AST_ERROR_DOMAIN_NAME ) {
return `${error}: Bad domain name`;
}
if ( astParser.astError === sfp.AST_ERROR_OPTION_DUPLICATE ) {
return `${error}: Duplicate filter option`;
}
if ( astParser.astError === sfp.AST_ERROR_OPTION_UNKNOWN ) {
return `${error}: Unsupported filter option`;
}
return error;
};

Expand Down
14 changes: 10 additions & 4 deletions src/js/static-filtering-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,11 @@ export const AST_FLAG_HAS_OPTIONS = 1 << iota++;

iota = 0;
export const AST_ERROR_NONE = 1 << iota++;
export const AST_ERROR_BAD_REGEX = 1 << iota++;
export const AST_ERROR_BAD_PATTERN = 1 << iota++;
export const AST_ERROR_REGEX = 1 << iota++;
export const AST_ERROR_PATTERN = 1 << iota++;
export const AST_ERROR_DOMAIN_NAME = 1 << iota++;
export const AST_ERROR_OPTION_DUPLICATE = 1 << iota++;
export const AST_ERROR_OPTION_UNKNOWN = 1 << iota++;

iota = 0;
const NODE_RIGHT_INDEX = iota++;
Expand Down Expand Up @@ -1278,6 +1281,7 @@ export class AstFilterParser {
realBad = isNegated || hasValue;
break;
case NODE_TYPE_NET_OPTION_NAME_UNKNOWN:
this.astError = AST_ERROR_OPTION_UNKNOWN;
realBad = true;
break;
case NODE_TYPE_NET_OPTION_NAME_WEBRTC:
Expand Down Expand Up @@ -1481,7 +1485,7 @@ export class AstFilterParser {
}
} else {
this.astTypeFlavor = AST_TYPE_NETWORK_PATTERN_BAD;
this.astError = AST_ERROR_BAD_REGEX;
this.astError = AST_ERROR_REGEX;
this.addFlags(AST_FLAG_HAS_ERROR);
this.addNodeFlags(next, NODE_FLAG_ERROR);
}
Expand Down Expand Up @@ -1602,7 +1606,7 @@ export class AstFilterParser {
if ( normal === undefined ) {
this.astTypeFlavor = AST_TYPE_NETWORK_PATTERN_BAD;
this.addFlags(AST_FLAG_HAS_ERROR);
this.astError = AST_ERROR_BAD_PATTERN;
this.astError = AST_ERROR_PATTERN;
this.addNodeFlags(next, NODE_FLAG_ERROR);
} else if ( normal === '' || pattern === '*' ) {
this.astTypeFlavor = AST_TYPE_NETWORK_PATTERN_ANY;
Expand Down Expand Up @@ -1813,6 +1817,7 @@ export class AstFilterParser {
if ( this.getBranchFromType(nodeOptionType) !== 0 ) {
this.addNodeFlags(parent, NODE_FLAG_ERROR);
this.addFlags(AST_FLAG_HAS_ERROR);
this.astError = AST_ERROR_OPTION_DUPLICATE;
} else {
this.addNodeToRegister(nodeOptionType, parent);
}
Expand Down Expand Up @@ -1956,6 +1961,7 @@ export class AstFilterParser {
} else {
this.addNodeFlags(parent, NODE_FLAG_ERROR);
this.addFlags(AST_FLAG_HAS_ERROR);
this.astError = AST_ERROR_DOMAIN_NAME;
}
}
if ( head === 0 ) {
Expand Down

0 comments on commit 95bd52d

Please sign in to comment.