Skip to content

Commit

Permalink
feat: add slint support (#500)
Browse files Browse the repository at this point in the history
Fixes #496.
  • Loading branch information
apocelipes authored Aug 29, 2024
1 parent 5acb76c commit 7106388
Show file tree
Hide file tree
Showing 6 changed files with 130 additions and 25 deletions.
1 change: 1 addition & 0 deletions LANGUAGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ Shell (sh,.tcshrc)
Sieve (sieve)
SKILL (il)
Slang (slang)
Slint (slint)
Smarty Template (tpl)
Snakemake (smk,rules,snakefile)
SNOBOL (sno)
Expand Down
46 changes: 23 additions & 23 deletions SCC-OUTPUT-REPORT.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<th>456</th>
<th>7602</th>
<th>1517</th>
<th>253980</th>
<th>254028</th>
<th>4051</th>
</tr><tr>
<td>processor/formatters.go</td>
Expand Down Expand Up @@ -220,16 +220,6 @@
<td>8</td>
<td>2030</td>
<td>52</td>
</tr><tr>
<td>cmd/badges/simplecache_test.go</td>
<td></td>
<td>52</td>
<td>12</td>
<td>0</td>
<td>40</td>
<td>9</td>
<td>1041</td>
<td>30</td>
</tr><tr>
<td>processor/filereader.go</td>
<td></td>
Expand All @@ -240,6 +230,16 @@
<td>6</td>
<td>1316</td>
<td>37</td>
</tr><tr>
<td>cmd/badges/simplecache_test.go</td>
<td></td>
<td>52</td>
<td>12</td>
<td>0</td>
<td>40</td>
<td>9</td>
<td>1041</td>
<td>30</td>
</tr><tr>
<td>processor/cocomo.go</td>
<td></td>
Expand All @@ -250,16 +250,6 @@
<td>0</td>
<td>2209</td>
<td>35</td>
</tr><tr>
<td>processor/bloom.go</td>
<td></td>
<td>37</td>
<td>7</td>
<td>12</td>
<td>18</td>
<td>2</td>
<td>1062</td>
<td>29</td>
</tr><tr>
<td>processor/cocomo_test.go</td>
<td></td>
Expand All @@ -270,6 +260,16 @@
<td>6</td>
<td>686</td>
<td>23</td>
</tr><tr>
<td>processor/bloom.go</td>
<td></td>
<td>37</td>
<td>7</td>
<td>12</td>
<td>18</td>
<td>2</td>
<td>1062</td>
<td>29</td>
</tr><tr>
<td>processor/helpers_test.go</td>
<td></td>
Expand Down Expand Up @@ -318,7 +318,7 @@
<td>0</td>
<td>4</td>
<td>0</td>
<td>22757</td>
<td>22805</td>
<td>5</td>
</tr></tbody>
<tfoot><tr>
Expand All @@ -329,7 +329,7 @@
<th>456</th>
<th>7602</th>
<th>1517</th>
<th>253980</th>
<th>254028</th>
<th>4051</th>
</tr>
<tr>
Expand Down
72 changes: 72 additions & 0 deletions examples/language/slint.slint
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
// an example from https://releases.slint.dev/1.7.2/docs/slint/src/recipes/recipes#custom-table-view
// 2 comments 5 blanks 9 Complexity 65 code

import { VerticalBox, ListView } from "std-widgets.slint";

component TableView inherits Rectangle {
in property <[string]> columns;
in property <[[string]]> values;

private property <length> e: self.width / root.columns.length;
private property <[length]> column_sizes: [
root.e, root.e, root.e, root.e, root.e, root.e, root.e, root.e, root.e, root.e, root.e, root.e, root.e, root.e, root.e, root.e, root.e, root.e, root.e, root.e, root.e, root.e,
root.e, root.e, root.e, root.e, root.e, root.e, root.e, root.e, root.e, root.e, root.e, root.e, root.e, root.e, root.e, root.e, root.e, root.e, root.e, root.e, root.e, root.e,
root.e, root.e, root.e, root.e, root.e, root.e, root.e, root.e, root.e, root.e, root.e, root.e, root.e, root.e, root.e, root.e, root.e, root.e, root.e, root.e, root.e, root.e,
];

VerticalBox {
padding: 5px;
HorizontalLayout {
padding: 5px; spacing: 5px;
vertical-stretch: 0;
for title[idx] in root.columns : HorizontalLayout {
width: root.column_sizes[idx];
Text { overflow: elide; text: title; }
Rectangle {
width: 1px;
background: gray;
TouchArea {
width: 10px;
x: (parent.width - self.width) / 2;
property <length> cached;
pointer-event(event) => {
if (event.button == PointerEventButton.left && event.kind == PointerEventKind.down) {
self.cached = root.column_sizes[idx];
}
}
moved => {
if (self.pressed) {
root.column_sizes[idx] += (self.mouse-x - self.pressed-x);
if (root.column_sizes[idx] < 0) {
root.column_sizes[idx] = 0;
}
}
}
mouse-cursor: ew-resize;
}
}
}
}
ListView {
for r in root.values : HorizontalLayout {
padding: 5px;
spacing: 5px;
for t[idx] in r : HorizontalLayout {
width: root.column_sizes[idx];
Text { overflow: elide; text: t; }
}
}
}
}
}

export component Example inherits Window {
TableView {
columns: ["Device", "Mount Point", "Total", "Free"];
values: [
["/dev/sda1", "/", "255GB", "82.2GB"] ,
["/dev/sda2", "/tmp", "60.5GB", "44.5GB"] ,
["/dev/sdb1", "/home", "255GB", "32.2GB"] ,
];
}
}
32 changes: 32 additions & 0 deletions languages.json
Original file line number Diff line number Diff line change
Expand Up @@ -7480,6 +7480,38 @@
}
]
},
"Slint": {
"complexitychecks": [
"for ",
"if ",
"if(",
"states ",
"states[",
"else ",
"|| ",
"&& ",
"!= ",
"== "
],
"extensions": [
"slint"
],
"line_comment": [
"//"
],
"multi_line": [
[
"/*",
"*/"
]
],
"quotes": [
{
"end": "\"",
"start": "\""
}
]
},
"Smarty Template": {
"complexitychecks": [
"for ",
Expand Down
2 changes: 1 addition & 1 deletion processor/constants.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion test-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -915,7 +915,7 @@ else
fi

# Try out specific languages
for i in 'Bosque ' 'Flow9 ' 'Bitbucket Pipeline ' 'Docker ignore ' 'Q# ' 'Futhark ' 'Alloy ' 'Wren ' 'Monkey C ' 'Alchemist ' 'Luna ' 'ignore ' 'XML Schema ' 'Web Services' 'Go ' 'Java ' 'Boo ' 'License ' 'BASH ' 'C Shell ' 'Korn Shell ' 'Makefile ' 'Shell ' 'Zsh ' 'Rakefile ' 'Gemfile ' 'Dockerfile ' 'Yarn ' 'Sieve ' 'F# ' 'Elm ' 'Terraform ' 'Clojure ' 'C# ' 'LLVM IR ' 'HAML ' 'FXML ' 'DM ' 'Nushell ' 'R ' 'Racket ' 'DOT ' 'YAML ' 'Teal ' 'FSL ' 'INI ' 'Hare ' 'Templ ' 'Cuda ' 'GraphQL ' 'Bicep ' 'Pkl ' 'TypeSpec ' 'LALRPOP ' 'Snakemake ' 'OpenQASM ' 'Typst ' 'ZoKrates ' 'Chapel ' 'Slang ' 'Circom ' 'Proto ' 'wenyan ' 'Cangjie ' 'Clipper '
for i in 'Bosque ' 'Flow9 ' 'Bitbucket Pipeline ' 'Docker ignore ' 'Q# ' 'Futhark ' 'Alloy ' 'Wren ' 'Monkey C ' 'Alchemist ' 'Luna ' 'ignore ' 'XML Schema ' 'Web Services' 'Go ' 'Java ' 'Boo ' 'License ' 'BASH ' 'C Shell ' 'Korn Shell ' 'Makefile ' 'Shell ' 'Zsh ' 'Rakefile ' 'Gemfile ' 'Dockerfile ' 'Yarn ' 'Sieve ' 'F# ' 'Elm ' 'Terraform ' 'Clojure ' 'C# ' 'LLVM IR ' 'HAML ' 'FXML ' 'DM ' 'Nushell ' 'R ' 'Racket ' 'DOT ' 'YAML ' 'Teal ' 'FSL ' 'INI ' 'Hare ' 'Templ ' 'Cuda ' 'GraphQL ' 'Bicep ' 'Pkl ' 'TypeSpec ' 'LALRPOP ' 'Snakemake ' 'OpenQASM ' 'Typst ' 'ZoKrates ' 'Chapel ' 'Slang ' 'Circom ' 'Proto ' 'wenyan ' 'Cangjie ' 'Clipper ' 'Slint '
do
if ./scc "examples/language/" | grep -q "$i "; then
echo -e "${GREEN}PASSED $i Language Check"
Expand Down

0 comments on commit 7106388

Please sign in to comment.