This is an automated email from the ASF dual-hosted git repository.
lkishalmi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/netbeans.git
The following commit(s) were added to refs/heads/master by this push:
new 7daf641f7e Some support for TOML files (#4503)
7daf641f7e is described below
commit 7daf641f7ea14d4ee696362223704dc721e1a2b4
Author: Laszlo Kishalmi <[email protected]>
AuthorDate: Mon Aug 22 08:39:44 2022 -0700
Some support for TOML files (#4503)
* Add tomlj library.
* Added support for TOML Lexer
* Added a few useful keystrokes for TOML
* Added transparent backround to the TOML icon.
* Added a simple TOML completion provider
* Enabled TOML formatting options
* Adjusted TOML Syntax Coloring
* Remove some cruft on TOML Support
* Polishing TOML Support
* Added TOML Support to Editor Kit as dependency
* Added some testing for TOML
---
.travis.yml | 1 +
ide/editor.kit/nbproject/project.xml | 6 +
ide/languages.toml/build.xml | 28 +++
ide/languages.toml/licenseinfo.xml | 29 +++
ide/languages.toml/manifest.mf | 6 +
ide/languages.toml/nbproject/project.properties | 19 ++
.../nbproject/project.xml | 166 ++++++++--------
.../modules/languages/toml/Bundle.properties | 35 ++++
.../modules/languages/toml/FontAndColors.xml | 41 ++++
.../languages/toml/LexerInputCharStream.java | 109 +++++++++++
.../languages/toml/TomlCompletionProvider.java | 128 +++++++++++++
.../modules/languages/toml/TomlDataObject.java | 141 ++++++++++++++
.../languages/toml/TomlDeletedTextInterceptor.java | 68 +++++++
.../modules/languages/toml/TomlExample.toml | 17 ++
.../modules/languages/toml/TomlLanguage.java | 46 +++++
.../netbeans/modules/languages/toml/TomlLexer.java | 163 ++++++++++++++++
.../modules/languages/toml/TomlTokenId.java | 86 +++++++++
.../languages/toml/TomlTypedTextInterceptor.java | 177 ++++++++++++++++++
.../org/netbeans/modules/languages/toml/layer.xml | 66 +++++++
.../modules/languages/toml/preferences.xml | 28 +++
.../netbeans/modules/languages/toml/toml-icon.png | Bin 0 -> 145 bytes
.../modules/languages/toml/toml-icon_dark.png | Bin 0 -> 149 bytes
.../languages/toml/TomlCompletionProviderTest.java | 151 +++++++++++++++
.../modules/languages/toml/TomlKeystrokeTest.java | 93 +++++++++
.../modules/languages/toml/TomlTestBase.java | 52 ++++++
ide/libs.tomlj/build.xml | 24 +++
ide/libs.tomlj/external/binaries-list | 17 ++
ide/libs.tomlj/external/tomlj-1.0.0-license.txt | 208 +++++++++++++++++++++
ide/libs.tomlj/manifest.mf | 3 +
ide/libs.tomlj/nbproject/project.properties | 19 ++
ide/libs.tomlj/nbproject/project.xml | 47 +++++
.../src/org/netbeans/libs/tomlj/Bundle.properties | 21 +++
.../org/netbeans/nbbuild/extlibs/ignored-overlaps | 1 +
nbbuild/cluster.properties | 2 +
nbbuild/rat-exclusions.txt | 1 +
35 files changed, 1918 insertions(+), 81 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index b861c1e387..0fad14210c 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -256,6 +256,7 @@ matrix:
- ant $OPTS -f ide/hudson.tasklist test
- ant $OPTS -f ide/hudson.ui test
- ant $OPTS -f ide/javascript2.debug test
+ - ant $OPTS -f ide/languages.toml test
- ant $OPTS -f ide/languages.yaml test
- ant $OPTS -f ide/lexer test
- ant $OPTS -f ide/lib.terminalemulator test
diff --git a/ide/editor.kit/nbproject/project.xml
b/ide/editor.kit/nbproject/project.xml
index 30b43bd854..e95b7975fd 100644
--- a/ide/editor.kit/nbproject/project.xml
+++ b/ide/editor.kit/nbproject/project.xml
@@ -99,6 +99,12 @@
<specification-version>1.3</specification-version>
</run-dependency>
</dependency>
+ <dependency>
+
<code-name-base>org.netbeans.modules.languages.toml</code-name-base>
+ <run-dependency>
+ <specification-version>1.0</specification-version>
+ </run-dependency>
+ </dependency>
<dependency>
<code-name-base>org.netbeans.modules.languages.yaml</code-name-base>
<run-dependency>
diff --git a/ide/languages.toml/build.xml b/ide/languages.toml/build.xml
new file mode 100644
index 0000000000..7bc3a1ca19
--- /dev/null
+++ b/ide/languages.toml/build.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+
+-->
+<!-- You may freely edit this file. See harness/README in the NetBeans
platform -->
+<!-- for some information on what you could do (e.g. targets to override). -->
+<!-- If you delete this file and reopen the project it will be recreated. -->
+<project name="ide/languages.toml" default="build" basedir=".">
+ <description>Builds, tests, and runs the project
org.netbeans.modules.languages.toml</description>
+ <import file="../../nbbuild/templates/projectized.xml"/>
+</project>
diff --git a/ide/languages.toml/licenseinfo.xml
b/ide/languages.toml/licenseinfo.xml
new file mode 100644
index 0000000000..ba6b813060
--- /dev/null
+++ b/ide/languages.toml/licenseinfo.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+
+-->
+<licenseinfo>
+ <fileset>
+ <file>src/org/netbeans/modules/languages/toml/toml-icon.png</file>
+ <file>src/org/netbeans/modules/languages/toml/toml-icon_dark.png</file>
+ <license ref="Apache-2.0-ASF" />
+ <comment type="COMMENT_UNSUPPORTED" />
+ </fileset>
+</licenseinfo>
diff --git a/ide/languages.toml/manifest.mf b/ide/languages.toml/manifest.mf
new file mode 100644
index 0000000000..d5867ea3ce
--- /dev/null
+++ b/ide/languages.toml/manifest.mf
@@ -0,0 +1,6 @@
+Manifest-Version: 1.0
+OpenIDE-Module: org.netbeans.modules.languages.toml
+OpenIDE-Module-Layer: org/netbeans/modules/languages/toml/layer.xml
+OpenIDE-Module-Localizing-Bundle:
org/netbeans/modules/languages/toml/Bundle.properties
+OpenIDE-Module-Specification-Version: 1.0
+AutoUpdate-Show-In-Client: false
diff --git a/ide/languages.toml/nbproject/project.properties
b/ide/languages.toml/nbproject/project.properties
new file mode 100644
index 0000000000..1f532a257e
--- /dev/null
+++ b/ide/languages.toml/nbproject/project.properties
@@ -0,0 +1,19 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+javac.source=1.8
+
+
diff --git a/ide/editor.kit/nbproject/project.xml
b/ide/languages.toml/nbproject/project.xml
similarity index 55%
copy from ide/editor.kit/nbproject/project.xml
copy to ide/languages.toml/nbproject/project.xml
index 30b43bd854..1b7f3de630 100644
--- a/ide/editor.kit/nbproject/project.xml
+++ b/ide/languages.toml/nbproject/project.xml
@@ -23,193 +23,197 @@
<type>org.netbeans.modules.apisupport.project</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/nb-module-project/3">
- <code-name-base>org.netbeans.modules.editor.kit</code-name-base>
+
<code-name-base>org.netbeans.modules.languages.toml</code-name-base>
<module-dependencies>
<dependency>
-
<code-name-base>org.netbeans.modules.css.visual</code-name-base>
- <run-dependency>
- <release-version>3</release-version>
- <specification-version>3.0</specification-version>
- </run-dependency>
- </dependency>
- <dependency>
-
<code-name-base>org.netbeans.modules.editor.actions</code-name-base>
+
<code-name-base>org.netbeans.core.multiview</code-name-base>
+ <build-prerequisite/>
+ <compile-dependency/>
<run-dependency>
<release-version>1</release-version>
- <specification-version>1.0</specification-version>
+ <specification-version>1.29</specification-version>
</run-dependency>
</dependency>
<dependency>
-
<code-name-base>org.netbeans.modules.editor.autosave</code-name-base>
+
<code-name-base>org.netbeans.libs.antlr4.runtime</code-name-base>
+ <build-prerequisite/>
+ <compile-dependency/>
<run-dependency>
- <release-version>1</release-version>
- <specification-version>1.0</specification-version>
+ <specification-version>1.18</specification-version>
</run-dependency>
</dependency>
<dependency>
-
<code-name-base>org.netbeans.modules.editor.bracesmatching</code-name-base>
+ <code-name-base>org.netbeans.libs.tomlj</code-name-base>
+ <build-prerequisite/>
+ <compile-dependency/>
<run-dependency>
- <release-version>0-1</release-version>
- <specification-version>1.7</specification-version>
+ <specification-version>1.0.0.0</specification-version>
</run-dependency>
</dependency>
<dependency>
-
<code-name-base>org.netbeans.modules.editor.search</code-name-base>
+
<code-name-base>org.netbeans.modules.csl.api</code-name-base>
+ <build-prerequisite/>
+ <compile-dependency/>
<run-dependency>
- <specification-version>1.1</specification-version>
+ <release-version>2</release-version>
+ <specification-version>2.74</specification-version>
</run-dependency>
</dependency>
<dependency>
- <code-name-base>org.netbeans.modules.html</code-name-base>
+
<code-name-base>org.netbeans.modules.editor.completion</code-name-base>
+ <build-prerequisite/>
+ <compile-dependency/>
<run-dependency>
<release-version>1</release-version>
- <specification-version>1.23</specification-version>
+ <specification-version>1.62</specification-version>
</run-dependency>
</dependency>
<dependency>
-
<code-name-base>org.netbeans.modules.html.parser</code-name-base>
+
<code-name-base>org.netbeans.modules.editor.document</code-name-base>
+ <build-prerequisite/>
+ <compile-dependency/>
<run-dependency>
- <release-version>1</release-version>
- <specification-version>1.1</specification-version>
+ <specification-version>1.26</specification-version>
</run-dependency>
</dependency>
<dependency>
-
<code-name-base>org.netbeans.modules.html.validation</code-name-base>
+
<code-name-base>org.netbeans.modules.editor.lib2</code-name-base>
+ <build-prerequisite/>
+ <compile-dependency/>
<run-dependency>
<release-version>1</release-version>
- <specification-version>1.1</specification-version>
+ <specification-version>2.37</specification-version>
</run-dependency>
</dependency>
<dependency>
- <code-name-base>org.netbeans.modules.image</code-name-base>
+
<code-name-base>org.netbeans.modules.editor.mimelookup</code-name-base>
+ <build-prerequisite/>
+ <compile-dependency/>
<run-dependency>
<release-version>1</release-version>
- <specification-version>1.19</specification-version>
+ <specification-version>1.57</specification-version>
</run-dependency>
</dependency>
<dependency>
-
<code-name-base>org.netbeans.modules.languages.diff</code-name-base>
- <run-dependency>
- <specification-version>1.4</specification-version>
- </run-dependency>
- </dependency>
- <dependency>
-
<code-name-base>org.netbeans.modules.languages.manifest</code-name-base>
- <run-dependency>
- <specification-version>1.3</specification-version>
- </run-dependency>
- </dependency>
- <dependency>
-
<code-name-base>org.netbeans.modules.languages.yaml</code-name-base>
- <run-dependency>
- <specification-version>2.1</specification-version>
- </run-dependency>
- </dependency>
- <dependency>
-
<code-name-base>org.netbeans.modules.parsing.api</code-name-base>
+ <code-name-base>org.netbeans.modules.lexer</code-name-base>
+ <build-prerequisite/>
<compile-dependency/>
<run-dependency>
- <release-version>1</release-version>
- <specification-version>9.0</specification-version>
+ <release-version>2</release-version>
+ <specification-version>1.80</specification-version>
</run-dependency>
</dependency>
<dependency>
-
<code-name-base>org.netbeans.modules.properties</code-name-base>
+ <code-name-base>org.openide.awt</code-name-base>
+ <build-prerequisite/>
+ <compile-dependency/>
<run-dependency>
- <release-version>1</release-version>
- <specification-version>1.21</specification-version>
+ <specification-version>7.85</specification-version>
</run-dependency>
</dependency>
<dependency>
-
<code-name-base>org.netbeans.modules.xml.core</code-name-base>
+ <code-name-base>org.openide.filesystems</code-name-base>
+ <build-prerequisite/>
+ <compile-dependency/>
<run-dependency>
- <release-version>2</release-version>
- <specification-version>1.13</specification-version>
+ <specification-version>9.29</specification-version>
</run-dependency>
</dependency>
<dependency>
-
<code-name-base>org.netbeans.modules.xml.lexer</code-name-base>
+ <code-name-base>org.openide.loaders</code-name-base>
+ <build-prerequisite/>
+ <compile-dependency/>
<run-dependency>
- <specification-version>1.1</specification-version>
+ <specification-version>7.87</specification-version>
</run-dependency>
</dependency>
<dependency>
-
<code-name-base>org.netbeans.modules.xml.schema.completion</code-name-base>
+ <code-name-base>org.openide.nodes</code-name-base>
+ <build-prerequisite/>
+ <compile-dependency/>
<run-dependency>
- <specification-version>1.0</specification-version>
+ <specification-version>7.62</specification-version>
</run-dependency>
</dependency>
<dependency>
-
<code-name-base>org.netbeans.modules.xml.text</code-name-base>
+ <code-name-base>org.openide.util</code-name-base>
+ <build-prerequisite/>
+ <compile-dependency/>
<run-dependency>
- <release-version>2</release-version>
- <specification-version>1.60</specification-version>
+ <specification-version>9.25</specification-version>
</run-dependency>
</dependency>
<dependency>
-
<code-name-base>org.netbeans.modules.xml.tools</code-name-base>
+ <code-name-base>org.openide.util.lookup</code-name-base>
+ <build-prerequisite/>
+ <compile-dependency/>
<run-dependency>
- <release-version>2</release-version>
- <specification-version>1.13</specification-version>
+ <specification-version>8.51</specification-version>
</run-dependency>
</dependency>
<dependency>
- <code-name-base>org.netbeans.modules.xsl</code-name-base>
+ <code-name-base>org.openide.util.ui</code-name-base>
+ <build-prerequisite/>
+ <compile-dependency/>
<run-dependency>
- <release-version>1</release-version>
- <specification-version>1.13</specification-version>
+ <specification-version>9.25</specification-version>
</run-dependency>
</dependency>
<dependency>
-
<code-name-base>org.netbeans.spi.editor.hints.projects</code-name-base>
+ <code-name-base>org.openide.windows</code-name-base>
+ <build-prerequisite/>
+ <compile-dependency/>
<run-dependency>
- <specification-version>1.1</specification-version>
+ <specification-version>6.94</specification-version>
</run-dependency>
</dependency>
</module-dependencies>
<test-dependencies>
<test-type>
- <name>qa-functional</name>
+ <name>unit</name>
<test-dependency>
<code-name-base>org.netbeans.libs.junit4</code-name-base>
<compile-dependency/>
</test-dependency>
<test-dependency>
-
<code-name-base>org.netbeans.modules.jellytools.ide</code-name-base>
+
<code-name-base>org.netbeans.modules.csl.api</code-name-base>
+ <recursive/>
<compile-dependency/>
+ <test/>
</test-dependency>
<test-dependency>
-
<code-name-base>org.netbeans.modules.jellytools.platform</code-name-base>
+
<code-name-base>org.netbeans.modules.nbjunit</code-name-base>
+ <recursive/>
<compile-dependency/>
</test-dependency>
<test-dependency>
-
<code-name-base>org.netbeans.modules.jemmy</code-name-base>
- <compile-dependency/>
+
<code-name-base>org.netbeans.modules.masterfs</code-name-base>
</test-dependency>
<test-dependency>
-
<code-name-base>org.netbeans.modules.nbjunit</code-name-base>
- <recursive/>
+
<code-name-base>org.openide.util.lookup</code-name-base>
<compile-dependency/>
+ <test/>
</test-dependency>
<test-dependency>
-
<code-name-base>org.openide.filesystems</code-name-base>
+
<code-name-base>org.netbeans.modules.editor.lib</code-name-base>
<compile-dependency/>
</test-dependency>
<test-dependency>
- <code-name-base>org.openide.loaders</code-name-base>
+
<code-name-base>org.netbeans.modules.editor.mimelookup</code-name-base>
<compile-dependency/>
</test-dependency>
<test-dependency>
- <code-name-base>org.openide.nodes</code-name-base>
- <compile-dependency/>
+
<code-name-base>org.netbeans.modules.editor.mimelookup.impl</code-name-base>
</test-dependency>
<test-dependency>
- <code-name-base>org.openide.util.ui</code-name-base>
+
<code-name-base>org.netbeans.modules.editor.util</code-name-base>
+ <recursive/>
<compile-dependency/>
</test-dependency>
<test-dependency>
<code-name-base>org.openide.util.lookup</code-name-base>
<compile-dependency/>
+ <test/>
</test-dependency>
</test-type>
</test-dependencies>
diff --git
a/ide/languages.toml/src/org/netbeans/modules/languages/toml/Bundle.properties
b/ide/languages.toml/src/org/netbeans/modules/languages/toml/Bundle.properties
new file mode 100644
index 0000000000..921df74e3f
--- /dev/null
+++
b/ide/languages.toml/src/org/netbeans/modules/languages/toml/Bundle.properties
@@ -0,0 +1,35 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+OpenIDE-Module-Name=TOML Editor Support
+OpenIDE-Module-Display-Category=Base IDE
+OpenIDE-Module-Short-Description=Support for editing TOML files.
+OpenIDE-Module-Long-Description=Support for editing TOML files.
+
+Editors/text/x-toml=TOML
+
+boolean=Boolean
+comment=Comment
+date=Date
+key=Key
+number=Number
+operator=Operator
+separator=Separator
+string=String
+string-escape=String Escape Sequence
+table-mark=Table Marking
+whitespace=Whitespace
diff --git
a/ide/languages.toml/src/org/netbeans/modules/languages/toml/FontAndColors.xml
b/ide/languages.toml/src/org/netbeans/modules/languages/toml/FontAndColors.xml
new file mode 100644
index 0000000000..b626f14325
--- /dev/null
+++
b/ide/languages.toml/src/org/netbeans/modules/languages/toml/FontAndColors.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+
+-->
+<!DOCTYPE fontscolors PUBLIC "-//NetBeans//DTD Editor Fonts and Colors
settings 1.1//EN" "http://www.netbeans.org/dtds/EditorFontsColors-1_1.dtd">
+<fontscolors>
+ <fontcolor name="boolean" default="keyword"/>
+ <fontcolor name="comment" default="comment"/>
+ <fontcolor name="date" default="number"/>
+ <fontcolor name="key" default="identifier">
+ <font style="bold" />
+ </fontcolor>
+ <fontcolor name="number" default="number"/>
+ <fontcolor name="operator" default="operator"/>
+ <fontcolor name="separator" default="separator"/>
+ <fontcolor name="string" default="string"/>
+ <fontcolor name="string-escape" default="string">
+ <font style="bold" />
+ </fontcolor>
+ <fontcolor name="table-mark" default="identfier">
+ <font style="bold" />
+ </fontcolor>
+ <fontcolor name="whitespace" default="whitespace"/>
+</fontscolors>
diff --git
a/ide/languages.toml/src/org/netbeans/modules/languages/toml/LexerInputCharStream.java
b/ide/languages.toml/src/org/netbeans/modules/languages/toml/LexerInputCharStream.java
new file mode 100644
index 0000000000..307a13e5e2
--- /dev/null
+++
b/ide/languages.toml/src/org/netbeans/modules/languages/toml/LexerInputCharStream.java
@@ -0,0 +1,109 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.languages.toml;
+
+import java.util.Stack;
+import org.antlr.v4.runtime.CharStream;
+import org.antlr.v4.runtime.misc.Interval;
+import org.netbeans.spi.lexer.*;
+
+/**
+ *
+ * @author lkishalmi
+ */
+public class LexerInputCharStream implements CharStream {
+ private final LexerInput input;
+ private final Stack<Integer> markers = new Stack<>();
+
+ public LexerInputCharStream(LexerInput input) {
+ this.input = input;
+
+ }
+
+ @Override
+ public String getText(Interval intrvl) {
+ return input.readText(intrvl.a, intrvl.b).toString();
+ }
+
+ @Override
+ public void consume() {
+ input.read();
+ }
+
+ @Override
+ public int LA(int count) {
+ if (count == 0) {
+ return 0; //the behaviour is not defined
+ }
+
+ int c = 0;
+ if (count > 0) {
+ for (int i = 0; i < count; i++) {
+ c = input.read();
+ }
+ input.backup(count);
+ } else {
+ input.backup(count);
+ c = input.read();
+ }
+ return c;
+ }
+
+ @Override
+ public int mark() {
+ markers.push(index());
+ return markers.size() - 1;
+ }
+
+ @Override
+ public void release(int marker) {
+ while (marker < markers.size()) {
+ markers.pop();
+ }
+ }
+
+ @Override
+ public int index() {
+ return input.readLengthEOF();
+ }
+
+ @Override
+ public void seek(int i) {
+ if (i < input.readLengthEOF()) {
+ input.backup(index() - i);
+ } else {
+ while (input.readLengthEOF() < i) {
+ if (input.read() == LexerInput.EOF) {
+ break;
+ }
+ }
+ }
+ }
+
+ @Override
+ public int size() {
+ return -1;
+ //throw new UnsupportedOperationException("Stream size is unknown.");
+ }
+
+ @Override
+ public String getSourceName() {
+ return UNKNOWN_SOURCE_NAME;
+ }
+}
diff --git
a/ide/languages.toml/src/org/netbeans/modules/languages/toml/TomlCompletionProvider.java
b/ide/languages.toml/src/org/netbeans/modules/languages/toml/TomlCompletionProvider.java
new file mode 100644
index 0000000000..5628f220ff
--- /dev/null
+++
b/ide/languages.toml/src/org/netbeans/modules/languages/toml/TomlCompletionProvider.java
@@ -0,0 +1,128 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.languages.toml;
+
+import java.util.EnumSet;
+import java.util.HashSet;
+import java.util.Set;
+import javax.swing.text.AbstractDocument;
+import javax.swing.text.BadLocationException;
+import javax.swing.text.Document;
+import javax.swing.text.JTextComponent;
+import org.netbeans.api.editor.mimelookup.MimeRegistration;
+import org.netbeans.api.lexer.TokenHierarchy;
+import org.netbeans.api.lexer.TokenSequence;
+import org.netbeans.spi.editor.completion.CompletionProvider;
+import org.netbeans.spi.editor.completion.CompletionResultSet;
+import org.netbeans.spi.editor.completion.CompletionTask;
+import org.netbeans.spi.editor.completion.support.AsyncCompletionQuery;
+import org.netbeans.spi.editor.completion.support.AsyncCompletionTask;
+import org.netbeans.spi.editor.completion.support.CompletionUtilities;
+import org.tomlj.Toml;
+import org.tomlj.TomlParseResult;
+
+/**
+ *
+ * @author Laszlo Kishalmi
+ */
+@MimeRegistration(mimeType = TomlTokenId.TOML_MIME_TYPE, service =
CompletionProvider.class)
+public class TomlCompletionProvider implements CompletionProvider {
+
+ @Override
+ public CompletionTask createTask(int queryType, JTextComponent component) {
+ return new AsyncCompletionTask(new TomlCompletionQuery(), component);
+ }
+
+ @Override
+ public int getAutoQueryTypes(JTextComponent component, String typedText) {
+ return 0;
+ }
+
+ private class TomlCompletionQuery extends AsyncCompletionQuery {
+
+ @Override
+ protected void query(CompletionResultSet resultSet, Document document,
int caretOffset) {
+ Set<String> candidates = new HashSet<>();
+ try {
+ AbstractDocument doc = (AbstractDocument) document;
+ doc.readLock();
+ StringBuilder toml;
+ String simplePrefix, prefix;
+ try {
+ int prefixOfs = keyPrefixOffset(doc, caretOffset);
+ prefix = doc.getText(prefixOfs, caretOffset - prefixOfs);
+ int lastDot = prefix.lastIndexOf('.');
+ simplePrefix = lastDot != -1 ? prefix.substring(lastDot +
1) : prefix;
+
+ toml = new StringBuilder(doc.getLength());
+ //Remove the current prefix for the parser to get better
results
+ toml.append(doc.getText(0, prefixOfs));
+ toml.append(doc.getText(caretOffset, doc.getLength() -
caretOffset));
+ } finally {
+ doc.readUnlock();
+ }
+ TomlParseResult parse = Toml.parse(toml.toString());
+ for (String key : parse.dottedKeySet()) {
+ String candidate = matchKey(key, prefix);
+ if (candidate != null) {
+ candidates.add(candidate);
+ }
+ }
+ for (String candidate : candidates) {
+ String insert = candidate.substring(simplePrefix.length());
+
resultSet.addItem(CompletionUtilities.newCompletionItemBuilder(insert)
+ .leftHtmlText(candidate)
+ .sortText(candidate)
+ .build());
+ }
+ } catch (BadLocationException ex) {
+ } finally {
+ resultSet.finish();
+ }
+ }
+
+ }
+
+
+ static String matchKey(String key, String prefix) {
+ String ret = null;
+ int keyStart = key.indexOf(prefix);
+ if (keyStart == 0 || ((keyStart > 0) && (key.charAt(keyStart - 1) ==
'.'))) {
+ int lastDot = prefix.lastIndexOf('.');
+ String m = key.substring(keyStart + lastDot + 1);
+ int dot = m.indexOf('.');
+ ret = (dot > -1) ? m.substring(0, dot) : m;
+ }
+ return ret;
+ }
+
+ private static final Set<TomlTokenId> DOT_OR_KEY =
EnumSet.of(TomlTokenId.DOT, TomlTokenId.KEY);
+
+ static int keyPrefixOffset(Document doc, int offset) throws
BadLocationException {
+ TokenHierarchy th = TokenHierarchy.get(doc);
+ TokenSequence<TomlTokenId> ts = th.tokenSequence();
+ ts.move(offset);
+ ts.movePrevious();
+ while ((ts.token() != null) && DOT_OR_KEY.contains(ts.token().id())) {
+ ts.movePrevious();
+ }
+ ts.moveNext();
+ return ts.offset();
+ }
+}
diff --git
a/ide/languages.toml/src/org/netbeans/modules/languages/toml/TomlDataObject.java
b/ide/languages.toml/src/org/netbeans/modules/languages/toml/TomlDataObject.java
new file mode 100644
index 0000000000..644c4b7903
--- /dev/null
+++
b/ide/languages.toml/src/org/netbeans/modules/languages/toml/TomlDataObject.java
@@ -0,0 +1,141 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.languages.toml;
+
+import java.io.IOException;
+import org.netbeans.core.spi.multiview.MultiViewElement;
+import org.netbeans.core.spi.multiview.text.MultiViewEditorElement;
+import org.openide.awt.ActionID;
+import org.openide.awt.ActionReference;
+import org.openide.awt.ActionReferences;
+import org.openide.filesystems.FileObject;
+import org.openide.filesystems.MIMEResolver;
+import org.openide.loaders.DataNode;
+import org.openide.loaders.DataObject;
+import org.openide.loaders.DataObjectExistsException;
+import org.openide.loaders.MultiDataObject;
+import org.openide.loaders.MultiFileLoader;
+import org.openide.nodes.Children;
+import org.openide.nodes.Node;
+import org.openide.util.*;
+import org.openide.windows.TopComponent;
+
+/**
+ *
+ * @author lkishalmi
+ */
[email protected](
+ "TOMLResolver=Toml File"
+)
[email protected](displayName = "#TOMLResolver",
+ extension = "toml",
+ mimeType = TomlTokenId.TOML_MIME_TYPE,
+ position = 285
+)
+
+@ActionReferences({
+ @ActionReference(
+ path = "Loaders/text/x-toml/Actions",
+ id = @ActionID(category = "System", id =
"org.openide.actions.OpenAction"),
+ position = 100,
+ separatorAfter = 300
+ ),
+ @ActionReference(
+ path = "Loaders/text/x-toml/Actions",
+ id = @ActionID(category = "Edit", id =
"org.openide.actions.CutAction"),
+ position = 400
+ ),
+ @ActionReference(
+ path = "Loaders/text/x-toml/Actions",
+ id = @ActionID(category = "Edit", id =
"org.openide.actions.CopyAction"),
+ position = 500,
+ separatorAfter = 600
+ ),
+ @ActionReference(
+ path = "Loaders/text/x-toml/Actions",
+ id = @ActionID(category = "Edit", id =
"org.openide.actions.DeleteAction"),
+ position = 700
+ ),
+ @ActionReference(
+ path = "Loaders/text/x-toml/Actions",
+ id = @ActionID(category = "System", id =
"org.openide.actions.RenameAction"),
+ position = 800,
+ separatorAfter = 900
+ ),
+ @ActionReference(
+ path = "Loaders/text/x-toml/Actions",
+ id = @ActionID(category = "System", id =
"org.openide.actions.SaveAsTemplateAction"),
+ position = 1000,
+ separatorAfter = 1100
+ ),
+ @ActionReference(
+ path = "Loaders/text/x-toml/Actions",
+ id = @ActionID(category = "System", id =
"org.openide.actions.FileSystemAction"),
+ position = 1200,
+ separatorAfter = 1300
+ ),
+ @ActionReference(
+ path = "Loaders/text/x-toml/Actions",
+ id = @ActionID(category = "System", id =
"org.openide.actions.ToolsAction"),
+ position = 1400
+ ),
+ @ActionReference(
+ path = "Loaders/text/x-toml/Actions",
+ id = @ActionID(category = "System", id =
"org.openide.actions.PropertiesAction"),
+ position = 1500
+ )
+})
+
[email protected](
+ mimeType = TomlTokenId.TOML_MIME_TYPE,
+ iconBase = "org/netbeans/modules/languages/toml/toml-icon.png",
+ displayName = "#TOMLResolver",
+ position = 303
+)
+public final class TomlDataObject extends MultiDataObject {
+
+ public TomlDataObject(FileObject pf, MultiFileLoader loader) throws
DataObjectExistsException, IOException {
+ super(pf, loader);
+ registerEditor(TomlTokenId.TOML_MIME_TYPE, true);
+ }
+
+ @Override
+ protected Node createNodeDelegate() {
+ return new DataNode(this, Children.LEAF, getLookup());
+ }
+
+ @Override
+ protected int associateLookup() {
+ return 1;
+ }
+
+ @NbBundle.Messages("Source=&Source")
+ @MultiViewElement.Registration(
+ displayName = "#Source",
+ iconBase = "org/netbeans/modules/languages/toml/toml-icon.png",
+ persistenceType = TopComponent.PERSISTENCE_ONLY_OPENED,
+ mimeType = TomlTokenId.TOML_MIME_TYPE,
+ preferredID = "neon.source",
+ position = 1
+ )
+ public static MultiViewEditorElement createMultiViewEditorElement(Lookup
context) {
+ return new MultiViewEditorElement(context);
+ }
+
+}
diff --git
a/ide/languages.toml/src/org/netbeans/modules/languages/toml/TomlDeletedTextInterceptor.java
b/ide/languages.toml/src/org/netbeans/modules/languages/toml/TomlDeletedTextInterceptor.java
new file mode 100644
index 0000000000..3765448344
--- /dev/null
+++
b/ide/languages.toml/src/org/netbeans/modules/languages/toml/TomlDeletedTextInterceptor.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.languages.toml;
+
+import javax.swing.text.BadLocationException;
+import org.netbeans.api.editor.mimelookup.MimePath;
+import org.netbeans.api.editor.mimelookup.MimeRegistration;
+import org.netbeans.spi.editor.typinghooks.DeletedTextInterceptor;
+
+/**
+ *
+ * @author lkishalmi
+ */
+public final class TomlDeletedTextInterceptor implements
DeletedTextInterceptor {
+
+ @Override
+ public boolean beforeRemove(Context context) throws BadLocationException {
+ return false;
+ }
+
+ @Override
+ public void remove(Context context) throws BadLocationException {
+ if (context.isBackwardDelete()) {
+ String txt = context.getText();
+ int nextCharOffset = context.getOffset() - 1;
+ String after = context.getDocument().getText(nextCharOffset, 1);
+ if (("[".equals(txt) && "]".equals(after))
+ || ("{".equals(txt) && "}".equals(after))) {
+ context.getDocument().remove(nextCharOffset, 1);
+ }
+ }
+ }
+
+ @Override
+ public void afterRemove(Context context) throws BadLocationException {
+ }
+
+ @Override
+ public void cancelled(Context context) {
+ }
+
+ @MimeRegistration(mimeType = TomlTokenId.TOML_MIME_TYPE, service =
DeletedTextInterceptor.Factory.class)
+ public static class TomlDeletedTextInterceptorFactory implements
DeletedTextInterceptor.Factory {
+
+ @Override
+ public DeletedTextInterceptor createDeletedTextInterceptor(MimePath
mimePath) {
+ return new TomlDeletedTextInterceptor();
+ }
+
+ }
+
+}
diff --git
a/ide/languages.toml/src/org/netbeans/modules/languages/toml/TomlExample.toml
b/ide/languages.toml/src/org/netbeans/modules/languages/toml/TomlExample.toml
new file mode 100644
index 0000000000..25b88222d5
--- /dev/null
+++
b/ide/languages.toml/src/org/netbeans/modules/languages/toml/TomlExample.toml
@@ -0,0 +1,17 @@
+# This line is a comment
+
+environment = "production"
+
+[application]
+name = "hello_world"
+message = "TOML Says:\nHello World!"
+description = """
+This application says
+
+Hello World!
+"""
+release.version = '1.1'
+release.revision = 42
+release.snapshot = true
+release.date = 2022-07-20T18:20:00Z
+
diff --git
a/ide/languages.toml/src/org/netbeans/modules/languages/toml/TomlLanguage.java
b/ide/languages.toml/src/org/netbeans/modules/languages/toml/TomlLanguage.java
new file mode 100644
index 0000000000..55e62bf148
--- /dev/null
+++
b/ide/languages.toml/src/org/netbeans/modules/languages/toml/TomlLanguage.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.languages.toml;
+
+import org.netbeans.api.lexer.Language;
+import org.netbeans.modules.csl.spi.DefaultLanguageConfig;
+import org.netbeans.modules.csl.spi.LanguageRegistration;
+
+/**
+ *
+ * @author lkishalmi
+ */
+@LanguageRegistration(mimeType = TomlTokenId.TOML_MIME_TYPE) //NOI18N
+public class TomlLanguage extends DefaultLanguageConfig {
+
+ @Override
+ public Language getLexerLanguage() {
+ return TomlTokenId.language();
+ }
+
+ @Override
+ public String getDisplayName() {
+ return "TOML"; //NOI18N
+ }
+
+ @Override
+ public String getLineCommentPrefix() {
+ return "#"; // NOI18N
+ }
+}
diff --git
a/ide/languages.toml/src/org/netbeans/modules/languages/toml/TomlLexer.java
b/ide/languages.toml/src/org/netbeans/modules/languages/toml/TomlLexer.java
new file mode 100644
index 0000000000..d7bc97eb3e
--- /dev/null
+++ b/ide/languages.toml/src/org/netbeans/modules/languages/toml/TomlLexer.java
@@ -0,0 +1,163 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.languages.toml;
+
+import org.antlr.v4.runtime.misc.IntegerList;
+import org.netbeans.api.lexer.Token;
+import org.netbeans.spi.lexer.Lexer;
+import org.netbeans.spi.lexer.LexerRestartInfo;
+import org.netbeans.spi.lexer.TokenFactory;
+
+import static org.tomlj.internal.TomlLexer.*;
+import static org.netbeans.modules.languages.toml.TomlTokenId.*;
+
+/**
+ *
+ * @author lkishalmi
+ */
+public final class TomlLexer implements Lexer<TomlTokenId> {
+
+ private final TokenFactory<TomlTokenId> tokenFactory;
+ private final org.tomlj.internal.TomlLexer lexer;
+
+ public TomlLexer(LexerRestartInfo<TomlTokenId> info) {
+ this.tokenFactory = info.tokenFactory();
+ this.lexer = new org.tomlj.internal.TomlLexer(new
LexerInputCharStream(info.input()));
+ if (info.state() != null) {
+ ((LexerState) info.state()).restore(lexer);
+ }
+ }
+
+ @Override
+ public Token<TomlTokenId> nextToken() {
+ try {
+ org.antlr.v4.runtime.Token nextToken = lexer.nextToken();
+ if (nextToken.getType() == EOF) {
+ return null;
+ }
+ switch (nextToken.getType()) {
+ case TripleQuotationMark:
+ case TripleApostrophe:
+ return token(ML_STRING_START);
+
+ case StringChar:
+ case QuotationMark:
+ case Apostrophe:
+ return token(STRING);
+
+ case MLBasicStringEnd:
+ case MLLiteralStringEnd:
+ return token(ML_STRING_END);
+
+ case Comma:
+ case ArrayStart:
+ case ArrayEnd:
+ case InlineTableStart:
+ case InlineTableEnd:
+
+ case Dot:
+ return token(DOT);
+
+ case Equals:
+ return token(EQUALS);
+
+ case TableKeyStart:
+ case TableKeyEnd:
+ case ArrayTableKeyStart:
+ case ArrayTableKeyEnd:
+ return token(TABLE_MARK);
+ case UnquotedKey:
+ return token(KEY);
+ case Comment:
+ return token(COMMENT);
+ case WS:
+ case NewLine:
+ return token(TomlTokenId.WHITESPACE);
+ case Error:
+ return token(ERROR);
+ case DecimalInteger:
+ case HexInteger:
+ case OctalInteger:
+ case BinaryInteger:
+ case FloatingPoint:
+ case FloatingPointInf:
+ case FloatingPointNaN:
+ return token(NUMBER);
+
+ case TrueBoolean:
+ case FalseBoolean:
+ return token(BOOLEAN);
+
+ case EscapeSequence:
+ return token(ESCAPE_SEQUENCE);
+
+ case Dash:
+ case Plus:
+ case Colon:
+ case Z:
+ case TimeDelimiter:
+ case DateDigits:
+ case DateComma:
+ return token(DATE);
+ default:
+ return token(ERROR);
+ }
+ } catch (IndexOutOfBoundsException ex) {
+ return token(ERROR);
+ }
+ }
+
+ @Override
+ public Object state() {
+ return new LexerState(lexer);
+ }
+
+ @Override
+ public void release() {
+ }
+
+ private Token<TomlTokenId> token(TomlTokenId id) {
+ return tokenFactory.createToken(id);
+ }
+
+ private static class LexerState {
+ final int state;
+ final int mode;
+ final IntegerList modes;
+
+ LexerState(org.tomlj.internal.TomlLexer lexer) {
+ this.state= lexer.getState();
+
+ this.mode = lexer._mode;
+ this.modes = new IntegerList(lexer._modeStack);
+ }
+
+ public void restore(org.tomlj.internal.TomlLexer lexer) {
+ lexer.setState(state);
+ lexer._modeStack.addAll(modes);
+ lexer._mode = mode;
+ }
+
+ @Override
+ public String toString() {
+ return String.valueOf(state);
+ }
+
+ }
+}
diff --git
a/ide/languages.toml/src/org/netbeans/modules/languages/toml/TomlTokenId.java
b/ide/languages.toml/src/org/netbeans/modules/languages/toml/TomlTokenId.java
new file mode 100644
index 0000000000..deacdc4e62
--- /dev/null
+++
b/ide/languages.toml/src/org/netbeans/modules/languages/toml/TomlTokenId.java
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.languages.toml;
+
+import java.util.Collection;
+import java.util.EnumSet;
+import org.netbeans.api.editor.mimelookup.MimeRegistration;
+import org.netbeans.api.lexer.Language;
+import org.netbeans.api.lexer.TokenId;
+import org.netbeans.spi.lexer.LanguageHierarchy;
+import org.netbeans.spi.lexer.Lexer;
+import org.netbeans.spi.lexer.LexerRestartInfo;
+
+/**
+ *
+ * @author lkishalmi
+ */
+public enum TomlTokenId implements TokenId {
+
+ COMMENT("comment"),
+ ERROR("error"),
+ KEY("key"),
+ BOOLEAN("boolean"),
+ DATE("date"),
+ NUMBER("number"),
+ EQUALS("operator"),
+ DOT("separator"),
+ TABLE_MARK("table-mark"),
+ STRING("string"),
+ ML_STRING_START("string"),
+ ML_STRING_END("string"),
+ ESCAPE_SEQUENCE("string-escape"),
+ WHITESPACE("whitespace");
+
+ private final String category;
+
+ TomlTokenId(String category) {
+ this.category = category;
+ }
+
+ @Override
+ public String primaryCategory() {
+ return category;
+ }
+
+ private static final Language<TomlTokenId> LANGUAGE = new
LanguageHierarchy<TomlTokenId>() {
+ @Override
+ protected Collection<TomlTokenId> createTokenIds() {
+ return EnumSet.allOf(TomlTokenId.class);
+ }
+
+ @Override
+ protected Lexer<TomlTokenId> createLexer(LexerRestartInfo<TomlTokenId>
info) {
+ return new TomlLexer(info);
+ }
+
+ @Override
+ protected String mimeType() {
+ return TomlTokenId.TOML_MIME_TYPE;
+ }
+ }.language();
+
+ @MimeRegistration(mimeType = TOML_MIME_TYPE, service = Language.class)
+ public static final Language<?> language() {
+ return LANGUAGE;
+ }
+
+ public static final String TOML_MIME_TYPE = "text/x-toml"; // NOI18N
+}
+
diff --git
a/ide/languages.toml/src/org/netbeans/modules/languages/toml/TomlTypedTextInterceptor.java
b/ide/languages.toml/src/org/netbeans/modules/languages/toml/TomlTypedTextInterceptor.java
new file mode 100644
index 0000000000..caf8ae7516
--- /dev/null
+++
b/ide/languages.toml/src/org/netbeans/modules/languages/toml/TomlTypedTextInterceptor.java
@@ -0,0 +1,177 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.languages.toml;
+
+import java.util.EnumSet;
+import java.util.Set;
+import javax.swing.text.BadLocationException;
+import javax.swing.text.Document;
+import org.netbeans.api.editor.document.LineDocument;
+import org.netbeans.api.editor.document.LineDocumentUtils;
+import org.netbeans.api.editor.mimelookup.MimePath;
+import org.netbeans.api.editor.mimelookup.MimeRegistration;
+import org.netbeans.api.lexer.TokenHierarchy;
+import org.netbeans.api.lexer.TokenId;
+import org.netbeans.api.lexer.TokenSequence;
+import org.netbeans.spi.editor.typinghooks.TypedTextInterceptor;
+
+/**
+ *
+ * @author lkishalmi
+ */
+public class TomlTypedTextInterceptor implements TypedTextInterceptor {
+
+ private int caretPosition = -1;
+
+ @Override
+ public boolean beforeInsert(Context context) throws BadLocationException {
+ return false;
+ }
+
+ @Override
+ public void insert(MutableContext context) throws BadLocationException {
+ String txt = context.getText();
+ if (context.getReplacedText().length() == 0) {
+ switch (txt) {
+ case "{":
+ context.setText("{}", 1);
+ break;
+ case "}":
+ if ("}".equals(textAfter(context, 1))) {
+ skipNext(context);
+ }
+ break;
+ case "[":
+ context.setText("[]", 1);
+ break;
+ case "]":
+ if ("]".equals(textAfter(context, 1))){
+ skipNext(context);
+ }
+ break;
+ case " ":
+ String b = textBefore(context, 1);
+ String a = textAfter(context, 1);
+ if ( ("{".equals(b) && "}".equals(a))
+ || ("[".equals(b) && "]".equals(a))) {
+ context.setText(" ", 1);
+ }
+ break;
+ case "\"":
+ if (!isInMultilineString(context)) {
+ if (!"\"\"".equals(textBefore(context, 2))) {
+ if ("\"".equals(textAfter(context, 1))){
+ skipNext(context);
+ } else {
+ int quotes = quotesInLine(context, '"');
+ if (quotes % 2 == 0) {
+ context.setText("\"\"", 1);
+ }
+ }
+ }
+ }
+ break;
+ case "'":
+ if (!isInMultilineString(context)) {
+ if (!"''".equals(textBefore(context, 2))) {
+ if ("'".equals(textAfter(context, 1))){
+ skipNext(context);
+ } else {
+ int quotes = quotesInLine(context, '\'');
+ if (quotes % 2 == 0) {
+ context.setText("''", 1);
+ }
+ }
+ }
+ }
+ break;
+ }
+ } else if (("\"".equals(txt) || "'".equals(txt)) &&
!isInMultilineString(context)) {
+ context.setText(txt + context.getReplacedText() + txt,
context.getReplacedText().length() + 2);
+ }
+ }
+
+ private void skipNext(MutableContext context) {
+ context.setText("", 0);
+ caretPosition = context.getOffset() + 1;
+ }
+
+ private static String textAfter(Context context, int length) throws
BadLocationException {
+ int next = Math.min(length, context.getDocument().getLength() -
context.getOffset());
+ return context.getDocument().getText(context.getOffset(), next);
+ }
+
+ private static String textBefore(Context context, int lenght) throws
BadLocationException {
+ int pre = Math.min(lenght, context.getOffset());
+ return context.getDocument().getText(context.getOffset() - pre, pre);
+ }
+
+ private static final Set<? extends TokenId> STRING_OR_WS =
EnumSet.of(TomlTokenId.STRING, TomlTokenId.WHITESPACE);
+
+ private static boolean isInMultilineString(Context context){
+ TokenHierarchy<Document> th =
TokenHierarchy.get(context.getDocument());
+ TokenSequence<?> ts = th.tokenSequence();
+ ts.move(context.getOffset());
+ ts.movePrevious();
+ while ((ts.token() != null) && STRING_OR_WS.contains(ts.token().id()))
{
+ ts.movePrevious();
+ }
+ return (ts.token() != null) && TomlTokenId.ML_STRING_START ==
ts.token().id();
+ }
+
+ private static int quotesInLine(Context context, char quote) throws
BadLocationException {
+ LineDocument doc = (LineDocument) context.getDocument();
+ int lineStart = LineDocumentUtils.getLineStart(doc,
context.getOffset());
+ int lineEnd = LineDocumentUtils.getLineEnd(doc, context.getOffset());
+ char[] line = doc.getText(lineStart, lineEnd -
lineStart).toCharArray();
+
+ int quotes = 0;
+ for (int i = 0; i < line.length; i++) {
+ char d = line[i];
+ if ('\\' == d) {
+ i++;
+ continue;
+ }
+ if (quote == d) quotes++;
+ }
+ return quotes;
+ }
+
+ @Override
+ public void afterInsert(Context context) throws BadLocationException {
+ if (caretPosition > -1) {
+ context.getComponent().setCaretPosition(caretPosition);
+ caretPosition = -1;
+ }
+ }
+
+ @Override
+ public void cancelled(Context context) {
+ }
+
+ @MimeRegistration(mimeType = TomlTokenId.TOML_MIME_TYPE, service =
TypedTextInterceptor.Factory.class)
+ public static class TomlTypedTextInterceptorFactory implements
TypedTextInterceptor.Factory {
+
+ @Override
+ public TypedTextInterceptor createTypedTextInterceptor(MimePath
mimePath) {
+ return new TomlTypedTextInterceptor();
+ }
+
+ }
+}
diff --git
a/ide/languages.toml/src/org/netbeans/modules/languages/toml/layer.xml
b/ide/languages.toml/src/org/netbeans/modules/languages/toml/layer.xml
new file mode 100644
index 0000000000..59d0f2b1c6
--- /dev/null
+++ b/ide/languages.toml/src/org/netbeans/modules/languages/toml/layer.xml
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+
+-->
+<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.2//EN"
"http://www.netbeans.org/dtds/filesystem-1_2.dtd">
+<filesystem>
+ <folder name="Editors">
+ <folder name="text">
+ <folder name="x-toml">
+ <attr name="displayName"
bundlevalue="org.netbeans.modules.languages.toml.Bundle#Editors/text/x-toml"/>
+ <folder name="FontsColors">
+ <folder name="NetBeans">
+ <folder name="Defaults">
+ <file name="FontAndColors.xml"
url="FontAndColors.xml">
+ <attr name="SystemFileSystem.localizingBundle"
stringvalue="org.netbeans.modules.languages.toml.Bundle"/>
+ </file>
+ </folder>
+ </folder>
+ </folder>
+ <folder name="Preferences">
+ <folder name="Defaults">
+ <file
name="org-netbeans-modules-languages-toml-preferences.xml"
url="preferences.xml"/>
+ </folder>
+ </folder>
+ </folder>
+ </folder>
+ </folder>
+ <folder name="OptionsDialog">
+ <folder name="PreviewExamples">
+ <folder name="text">
+ <file name="x-toml" url="TomlExample.toml"/>
+ </folder>
+ </folder>
+ <folder name="Editor">
+ <folder name="Formatting">
+ <folder name="text">
+ <folder name="x-toml">
+ <file name="TabsAndIndents.instance">
+ <attr name="instanceOf"
stringvalue="org.netbeans.modules.options.editor.spi.PreferencesCustomizer$Factory"/>
+ <attr name="instanceCreate"
methodvalue="org.netbeans.modules.options.editor.spi.CustomizerFactories.createDefaultTabsAndIndentsCustomizerFactory"/>
+ <attr name="previewTextFile"
stringvalue="org/netbeans/modules/languages/toml/TomlExample.toml"/>
+ <attr name="position" intvalue="100"/>
+ </file>
+ </folder>
+ </folder>
+ </folder>
+ </folder>
+ </folder>
+</filesystem>
diff --git
a/ide/languages.toml/src/org/netbeans/modules/languages/toml/preferences.xml
b/ide/languages.toml/src/org/netbeans/modules/languages/toml/preferences.xml
new file mode 100644
index 0000000000..2876e004cd
--- /dev/null
+++ b/ide/languages.toml/src/org/netbeans/modules/languages/toml/preferences.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+
+-->
+<!DOCTYPE editor-preferences PUBLIC "-//NetBeans//DTD Editor Preferences
1.0//EN" "http://www.netbeans.org/dtds/EditorPreferences-1_0.dtd">
+<editor-preferences>
+ <entry javaType="java.lang.Boolean" name="enable-indent"
xml:space="preserve"><value>true</value></entry>
+ <entry javaType="java.lang.Integer" name="indent-shift-width"
xml:space="preserve"><value>2</value></entry>
+ <entry javaType="java.lang.Integer" name="spaces-per-tab"
xml:space="preserve"><value>2</value></entry>
+</editor-preferences>
+
diff --git
a/ide/languages.toml/src/org/netbeans/modules/languages/toml/toml-icon.png
b/ide/languages.toml/src/org/netbeans/modules/languages/toml/toml-icon.png
new file mode 100644
index 0000000000..59df7d39a2
Binary files /dev/null and
b/ide/languages.toml/src/org/netbeans/modules/languages/toml/toml-icon.png
differ
diff --git
a/ide/languages.toml/src/org/netbeans/modules/languages/toml/toml-icon_dark.png
b/ide/languages.toml/src/org/netbeans/modules/languages/toml/toml-icon_dark.png
new file mode 100644
index 0000000000..ac6e016fcf
Binary files /dev/null and
b/ide/languages.toml/src/org/netbeans/modules/languages/toml/toml-icon_dark.png
differ
diff --git
a/ide/languages.toml/test/unit/src/org/netbeans/modules/languages/toml/TomlCompletionProviderTest.java
b/ide/languages.toml/test/unit/src/org/netbeans/modules/languages/toml/TomlCompletionProviderTest.java
new file mode 100644
index 0000000000..80c1aee834
--- /dev/null
+++
b/ide/languages.toml/test/unit/src/org/netbeans/modules/languages/toml/TomlCompletionProviderTest.java
@@ -0,0 +1,151 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.languages.toml;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.Reader;
+import java.io.Writer;
+import javax.swing.Action;
+import javax.swing.text.BadLocationException;
+import javax.swing.text.Caret;
+import javax.swing.text.DefaultEditorKit;
+import javax.swing.text.Document;
+import javax.swing.text.EditorKit;
+import javax.swing.text.JTextComponent;
+import javax.swing.text.ViewFactory;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.netbeans.spi.editor.completion.CompletionTask;
+
+/**
+ *
+ * @author lkishalmi
+ */
+public class TomlCompletionProviderTest extends TomlTestBase {
+
+ public TomlCompletionProviderTest(String testName) {
+ super(testName);
+ }
+
+ @Test
+ public void testMatchKey1() {
+ String key = "version";
+ String prefix = "ver";
+ String expResult = "version";
+ String result = TomlCompletionProvider.matchKey(key, prefix);
+ assertEquals(expResult, result);
+ }
+
+ @Test
+ public void testMatchKey2() {
+ String key = "cars.ford.focus";
+ String prefix = "ford.fo";
+ String expResult = "focus";
+ String result = TomlCompletionProvider.matchKey(key, prefix);
+ assertEquals(expResult, result);
+ }
+
+ @Test
+ public void testNotMatchKey1() {
+ String key = "version";
+ String prefix = "var";
+ String expResult = null;
+ String result = TomlCompletionProvider.matchKey(key, prefix);
+ assertEquals(expResult, result);
+ }
+
+ @Test
+ public void testNotMatchKey2() {
+ String key = "cars.ford.focus";
+ String prefix = "ord.fo";
+ String expResult = null;
+ String result = TomlCompletionProvider.matchKey(key, prefix);
+ assertEquals(expResult, result);
+ }
+
+ @Test
+ public void testKeyPrefixOffset1() throws Exception {
+ Document doc = getDocument("[fruits]\norange.color");
+ int offset = 0;
+ int expResult = 0;
+ int result = TomlCompletionProvider.keyPrefixOffset(doc, offset);
+ assertEquals(expResult, result);
+ }
+
+ @Test
+ public void testKeyPrefixOffset2() throws Exception {
+ Document doc = getDocument("[fruits]\norange.color");
+ int offset = "[".length();
+ int expResult = "[".length();
+ int result = TomlCompletionProvider.keyPrefixOffset(doc, offset);
+ assertEquals(expResult, result);
+ }
+
+ @Test
+ public void testKeyPrefixOffset3() throws Exception {
+ Document doc = getDocument("[fruits]\norange.color");
+ int offset = "[fru".length();
+ int expResult = "[".length();
+ int result = TomlCompletionProvider.keyPrefixOffset(doc, offset);
+ assertEquals(expResult, result);
+ }
+
+
+ @Test
+ public void testKeyPrefixOffset4() throws Exception {
+ Document doc = getDocument("[fruits]\norange.color");
+ int offset = "[fruits]\nora".length();
+ int expResult = "[fruits]\n".length();
+ int result = TomlCompletionProvider.keyPrefixOffset(doc, offset);
+ assertEquals(expResult, result);
+ }
+
+
+ @Test
+ public void testKeyPrefixOffset5() throws Exception {
+ Document doc = getDocument("[fruits]\norange.color");
+ int offset = "[fruits]\norange.color".length();
+ int expResult = "[fruits]\n".length();
+ int result = TomlCompletionProvider.keyPrefixOffset(doc, offset);
+ assertEquals(expResult, result);
+ }
+
+ @Test
+ public void testKeyPrefixOffset6() throws Exception {
+ Document doc = getDocument("msg=\"Hello");
+ int offset = "msg=\"Hello".length();
+ int expResult = "msg=\"Hello".length();
+ int result = TomlCompletionProvider.keyPrefixOffset(doc, offset);
+ assertEquals(expResult, result);
+ }
+
+ @Test
+ public void testKeyPrefixOffset7() throws Exception {
+ Document doc = getDocument("msg=\"Hello");
+ int offset = "msg=\"".length();
+ int expResult = "msg=\"".length();
+ int result = TomlCompletionProvider.keyPrefixOffset(doc, offset);
+ assertEquals(expResult, result);
+ }
+}
diff --git
a/ide/languages.toml/test/unit/src/org/netbeans/modules/languages/toml/TomlKeystrokeTest.java
b/ide/languages.toml/test/unit/src/org/netbeans/modules/languages/toml/TomlKeystrokeTest.java
new file mode 100644
index 0000000000..bb4ad19fbe
--- /dev/null
+++
b/ide/languages.toml/test/unit/src/org/netbeans/modules/languages/toml/TomlKeystrokeTest.java
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.languages.toml;
+
+/**
+ *
+ * @author lkishalmi
+ */
+public class TomlKeystrokeTest extends TomlTestBase {
+
+ public TomlKeystrokeTest(String testName) {
+ super(testName);
+ }
+
+ @Override
+ protected boolean runInEQ() {
+ // Must run in AWT thread (BaseKit.install() checks for that)
+ return true;
+ }
+
+ private void insertChar(String original, char insertText, String expected)
throws Exception {
+ insertChar(original, insertText, expected, null);
+ }
+
+ private void insertChar(String original, char insertText, String expected,
String selection) throws Exception {
+ insertChar(original, insertText, expected, selection, false);
+ }
+
+ public void testInsertBracket() throws Exception {
+ insertChar("^", '[', "[^]");
+ }
+
+ public void testDeleteBracket() throws Exception {
+ deleteChar("[^]", "^");
+ }
+
+ public void testInsertCurly() throws Exception {
+ insertChar("^", '{', "{^}");
+ }
+
+ public void testDeleteCurly() throws Exception {
+ deleteChar("{{^}}", "{^}");
+ }
+
+ public void testInsertSpaceCurly() throws Exception {
+ insertChar("{{^}}", ' ', "{{ ^ }}");
+ }
+
+ public void testInsertSpaceBracket() throws Exception {
+ insertChar("[^]", ' ', "[ ^ ]");
+ }
+
+ public void testInsertSingleQuote1() throws Exception {
+ insertChar("foo= ^", '\'', "foo= '^'");
+ }
+
+ public void testInsertSingleQuote2() throws Exception {
+ insertChar("foo= 'a^", '\'', "foo= 'a'^");
+ }
+
+ public void testInsertSingleQuote3() throws Exception {
+ insertChar("foo= bar^", '\'', "foo= 'bar'^", "bar");
+ }
+
+ public void testInsertSingleQuote4() throws Exception {
+ insertChar("foo= ^bar", '\'', "foo= 'bar'^", "bar");
+ }
+
+ public void testStepSingleQuote() throws Exception {
+ insertChar("foo= '^'", '\'', "foo= ''^");
+ }
+
+ public void testDeleteSingle2() throws Exception {
+ deleteChar("foo= ''^", "foo= '^");
+ }
+
+}
diff --git
a/ide/languages.toml/test/unit/src/org/netbeans/modules/languages/toml/TomlTestBase.java
b/ide/languages.toml/test/unit/src/org/netbeans/modules/languages/toml/TomlTestBase.java
new file mode 100644
index 0000000000..12475a3b14
--- /dev/null
+++
b/ide/languages.toml/test/unit/src/org/netbeans/modules/languages/toml/TomlTestBase.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.languages.toml;
+
+import org.netbeans.modules.csl.api.Formatter;
+import org.netbeans.modules.csl.api.test.CslTestBase;
+import org.netbeans.modules.csl.api.test.CslTestBase.IndentPrefs;
+import org.netbeans.modules.csl.spi.DefaultLanguageConfig;
+
+/**
+ *
+ * @author lkishalmi
+ */
+public class TomlTestBase extends CslTestBase {
+
+ public TomlTestBase(String testName){
+ super(testName);
+ }
+
+ @Override
+ protected DefaultLanguageConfig getPreferredLanguage() {
+ return new TomlLanguage();
+
+ }
+
+ @Override
+ protected String getPreferredMimeType() {
+ return TomlTokenId.TOML_MIME_TYPE;
+ }
+
+ @Override
+ protected Formatter getFormatter(IndentPrefs preferences) {
+ return null;
+ }
+
+}
diff --git a/ide/libs.tomlj/build.xml b/ide/libs.tomlj/build.xml
new file mode 100644
index 0000000000..ff692ac022
--- /dev/null
+++ b/ide/libs.tomlj/build.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+
+-->
+<project name="ide/libs.tomlj" default="build" basedir=".">
+ <import file="../../nbbuild/templates/projectized.xml"/>
+</project>
diff --git a/ide/libs.tomlj/external/binaries-list
b/ide/libs.tomlj/external/binaries-list
new file mode 100644
index 0000000000..0d65e1acf3
--- /dev/null
+++ b/ide/libs.tomlj/external/binaries-list
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+D1922FB5E672E04D8E8D8DAC0B058B1897E6E940 org.tomlj:tomlj:1.0.0
diff --git a/ide/libs.tomlj/external/tomlj-1.0.0-license.txt
b/ide/libs.tomlj/external/tomlj-1.0.0-license.txt
new file mode 100644
index 0000000000..70bf4d6466
--- /dev/null
+++ b/ide/libs.tomlj/external/tomlj-1.0.0-license.txt
@@ -0,0 +1,208 @@
+Name: TOML parser in Java
+Version: 1.0.0
+Description: A parser for Tom's Obvious, Minimal Language (TOML).
+License: Apache-2.0
+Origin: Apache Software Foundation
+URL: http://incubator.apache.org/projects/netbeans.html
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/ide/libs.tomlj/manifest.mf b/ide/libs.tomlj/manifest.mf
new file mode 100644
index 0000000000..a19c688e1c
--- /dev/null
+++ b/ide/libs.tomlj/manifest.mf
@@ -0,0 +1,3 @@
+OpenIDE-Module: org.netbeans.libs.tomlj
+OpenIDE-Module-Localizing-Bundle: org/netbeans/libs/tomlj/Bundle.properties
+OpenIDE-Module-Specification-Version: 1.0.0.0
diff --git a/ide/libs.tomlj/nbproject/project.properties
b/ide/libs.tomlj/nbproject/project.properties
new file mode 100644
index 0000000000..7e5fd34391
--- /dev/null
+++ b/ide/libs.tomlj/nbproject/project.properties
@@ -0,0 +1,19 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+release.external/tomlj-1.0.0.jar=modules/ext/tomlj.jar
+is.autoload=true
+
diff --git a/ide/libs.tomlj/nbproject/project.xml
b/ide/libs.tomlj/nbproject/project.xml
new file mode 100644
index 0000000000..98cbc5051b
--- /dev/null
+++ b/ide/libs.tomlj/nbproject/project.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+
+-->
+<project xmlns="http://www.netbeans.org/ns/project/1">
+ <type>org.netbeans.modules.apisupport.project</type>
+ <configuration>
+ <data xmlns="http://www.netbeans.org/ns/nb-module-project/2">
+ <code-name-base>org.netbeans.libs.tomlj</code-name-base>
+ <module-dependencies>
+ <dependency>
+
<code-name-base>org.netbeans.libs.antlr4.runtime</code-name-base>
+ <build-prerequisite/>
+ <compile-dependency/>
+ <run-dependency>
+ <specification-version>1.18</specification-version>
+ </run-dependency>
+ </dependency>
+ </module-dependencies>
+ <public-packages>
+ <package>org.tomlj</package>
+ <package>org.tomlj.internal</package>
+ </public-packages>
+ <class-path-extension>
+ <runtime-relative-path>ext/tomlj.jar</runtime-relative-path>
+ <binary-origin>external/tomlj-1.0.0.jar</binary-origin>
+ </class-path-extension>
+ </data>
+ </configuration>
+</project>
diff --git a/ide/libs.tomlj/src/org/netbeans/libs/tomlj/Bundle.properties
b/ide/libs.tomlj/src/org/netbeans/libs/tomlj/Bundle.properties
new file mode 100644
index 0000000000..ddde0ed644
--- /dev/null
+++ b/ide/libs.tomlj/src/org/netbeans/libs/tomlj/Bundle.properties
@@ -0,0 +1,21 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+OpenIDE-Module-Display-Category=Libraries
+OpenIDE-Module-Long-Description=\
+ Tomlj is an open source implementation of TOML parser. See:
https://github.com/tomlj/tomlj
+OpenIDE-Module-Name=Java TOML Parser Library
+OpenIDE-Module-Short-Description=Tomlj is an open source implementation of
TOML parser
diff --git a/nbbuild/antsrc/org/netbeans/nbbuild/extlibs/ignored-overlaps
b/nbbuild/antsrc/org/netbeans/nbbuild/extlibs/ignored-overlaps
index 4b2031e724..9553042e08 100644
--- a/nbbuild/antsrc/org/netbeans/nbbuild/extlibs/ignored-overlaps
+++ b/nbbuild/antsrc/org/netbeans/nbbuild/extlibs/ignored-overlaps
@@ -72,6 +72,7 @@ extide/gradle/external/gradle-7.4-bin.zip
ide/c.jcraft.jsch/external/jsch-0.1.55
extide/gradle/external/gradle-7.4-bin.zip
ide/c.jcraft.jzlib/external/jzlib-1.1.3.jar
extide/gradle/external/gradle-7.4-bin.zip
ide/libs.antlr4.runtime/external/antlr4-runtime-4.7.2.jar
extide/gradle/external/gradle-7.4-bin.zip
ide/libs.commons_compress/external/commons-compress-1.21.jar
+extide/gradle/external/gradle-7.4-bin.zip
ide/libs.tomlj/external/tomlj-1.0.0.jar
extide/gradle/external/gradle-7.4-bin.zip
ide/o.apache.commons.lang/external/commons-lang-2.6.jar
extide/gradle/external/gradle-7.4-bin.zip
ide/o.eclipse.jgit/external/org.eclipse.jgit-5.7.0.202003110725-r.jar
extide/gradle/external/gradle-7.4-bin.zip
java/maven.embedder/external/apache-maven-3.8.6-bin.zip
diff --git a/nbbuild/cluster.properties b/nbbuild/cluster.properties
index 4bf77612a2..bb59882c6c 100644
--- a/nbbuild/cluster.properties
+++ b/nbbuild/cluster.properties
@@ -427,6 +427,7 @@ nb.cluster.ide=\
languages,\
languages.diff,\
languages.manifest,\
+ languages.toml,\
languages.yaml,\
lexer,\
lexer.nbbridge,\
@@ -449,6 +450,7 @@ nb.cluster.ide=\
libs.snakeyaml_engine,\
libs.svnClientAdapter,\
libs.svnClientAdapter.javahl,\
+ libs.tomlj,\
libs.truffleapi,\
libs.xerces,\
localhistory,\
diff --git a/nbbuild/rat-exclusions.txt b/nbbuild/rat-exclusions.txt
index e4c8ab1876..299e1a6ce7 100644
--- a/nbbuild/rat-exclusions.txt
+++ b/nbbuild/rat-exclusions.txt
@@ -215,6 +215,7 @@
javafx/javafx2.project/src/org/netbeans/modules/javafx2/project/templates/**
java/jshell.support/src/org/netbeans/modules/jshell/resources/consoleExample.jsh
java/junit.ui/src/org/netbeans/modules/junit/ui/resources/*.template
ide/languages.diff/src/org/netbeans/modules/languages/diff/DiffExample.diff
+ide/languages.toml/src/org/netbeans/modules/languages/toml/*.toml
ide/languages.yaml/src/org/netbeans/modules/languages/yaml/*.yaml
ide/languages.yaml/src/org/netbeans/modules/languages/yaml/*.yml
java/spring.beans/src/org/netbeans/modules/spring/beans/resources/templates/*.template
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists