You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 30, 2024. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+30-6Lines changed: 30 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,11 +6,13 @@ This repository provides formatter settings for the [coding style rules](https:/
6
6
7
7
Settings are primarily provided for
8
8
9
-
-[Oracle SQLcl, Version 23.3.0](https://www.oracle.com/tools/downloads/sqlcl-downloads.html)
9
+
-[Oracle SQLcl, Version 23.4.0](https://www.oracle.com/tools/downloads/sqlcl-downloads.html)
10
10
-[Oracle SQL Developer, Version 23.1.1](https://www.oracle.com/tools/downloads/sqldev-downloads.html) (requires `dbtools-common.jar` from SQLcl 23.3.0)
11
11
12
12
These settings have been defined and tested with the product versions mentioned above. They might not work in other versions.
13
13
14
+
Please note, that these settings cannot be used in [Oracle SQL Developer for VSCode 23.4.0](https://marketplace.visualstudio.com/items?itemName=Oracle.sql-developer). And it does not work in the embedded version of SQLcl 23.3.1.0, which cannot run JavaScript.
15
+
14
16
JDK 11 is required for SQLDev and SQLcl. The standalone tvdformat.jar works with JDK 11 or newer.
15
17
16
18
See [releases](https://github.com/Trivadis/plsql-formatter-settings/releases) for settings supporting older versions.
@@ -21,7 +23,9 @@ SQL Developer is slowly reaching the end of its life cycle. The days when SQL De
21
23
22
24
A new SQLcl version typically comes with enhancements and bug fixes in the area of PL/SQL and SQL grammar. And this also requires an adaptation of the formatting rule due to symbol name changes etc. And as a result, these formatting rules can actually only be used in SQLcl.
23
25
24
-
However, we know that the grammars and the formatter are provided in a JAR called `dbtools-common.jar`. And this JAR file also exists in the SQL Developer distribution. This means that in order to be able to use the current formatting rules in SQL Developer, we have to copy the `dbtools-common.jar` file from SQLcl to SQL Developer as follows:
26
+
However, we know that the grammars and the formatter are provided in a JAR called `dbtools-common.jar`. And this JAR file also exists in the SQL Developer distribution. This means that in order to be able to use the current formatting rules in SQL Developer, we have to copy the `dbtools-common.jar` file from SQLcl to SQL Developer. Unfortunatelly the classes are not 100% compatible with the SQL Developer. As a a result, we have to keep some original classes, which complicates the patching process a bit.
27
+
28
+
Here's the full procedure to use `dbtools-common.jar` from SQLcl 23.4.0 in SQL Developer 23.1.1.345:
25
29
26
30
1. Quit SQL Developer
27
31
@@ -35,11 +39,31 @@ However, we know that the grammars and the formatter are provided in a JAR calle
35
39
36
40
Find the `dbtools-common.jar` in your SQLcl installation. In our case it's in `/usr/local/bin/sqlcl/lib`. Copy the file to the SQL Developer’s directory (where `dbtools-common.original.jar` is located).
37
41
38
-
4. Start SQL Developer
42
+
4. Patch SQLcl's `dbtools-common.jar`
43
+
44
+
Open a terminal window in the `lib` folder where `dbtools-common.original.jar` and `dbtools-commmon.jar` are located and run the following commands to copy the class `oracle.dbtools.parser.ParserNode.class` to `dbtools-common.jar`:
45
+
46
+
```bash
47
+
jar -xvf dbtools-common.original.jar oracle/dbtools/parser/ParseNode.class
48
+
jar -u0vMf dbtools-common.jar oracle/dbtools
49
+
rm -rf oracle
50
+
```
51
+
52
+
This step is necessary to ensure that the "Code Outline" continues to work in SQL Developer.
53
+
54
+
5. Clear SQL Developer's cache
55
+
56
+
Delete the following directory:
57
+
58
+
- On Windows: `%APPDATA%\SQL Developer\system23.1.1.345.2114\system_cache`
59
+
- On other platforms: `$HOME/.sqldeveloper/system23.1.1.345.2114/system_cache`
60
+
61
+
This step is necessary to ensure no other version of `dbtools-common.jar` is used from the cache. You will all
62
+
window settings. However, all other preferences including your connections are preserved.
39
63
40
-
Open an editor and test if the formatter is working.
64
+
6. Start SQL Developer
41
65
42
-
We have successfully tested this procedure with SQL Developer 23.1.1. However, there were cases in the past where this did not work. For example, using the JAR of SQLcl 20.3.0 in SQL Developer 20.2.0. Replacing a JAR requires a certain level of compatiblity. We therefore expect that this procedure will no longer work with an upcoming version of SQLcl. We will update this section as soon as we know more.
66
+
Open an editor and test if the formatter and code outline is working.
43
67
44
68
## Deviating Settings
45
69
@@ -137,7 +161,7 @@ SQL Developer uses its own parse tree query language called Arbori for its advan
137
161
138
162
#### Links
139
163
140
-
-[SQL Developer 22.2 User Guide, Code Editor: Format](https://docs.oracle.com/en/database/oracle/sql-developer/22.2/rptug/sql-developer-concepts-usage.html#GUID-9421DA6E-A48A-427B-88C9-4414D83EC9D1__CODEEDITORFORMAT-C73DB981)
164
+
-[SQL Developer 23.1 User Guide, Code Editor: Format](https://docs.oracle.com/en/database/oracle/sql-developer/23.1/rptug/sql-developer-concepts-usage.html#GUID-9421DA6E-A48A-427B-88C9-4414D83EC9D1__CODEEDITORFORMAT-C73DB981)
141
165
-[Formatting Code With SQL Developer](https://www.salvis.com/blog/2020/04/13/formatting-code-with-sql-developer/)
Copy file name to clipboardExpand all lines: standalone/README.md
+16-72Lines changed: 16 additions & 72 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -31,13 +31,13 @@ The parameters are the same as for the [SQLcl command `tvdformat`](../sqlcl/READ
31
31
32
32
A native image is a platform specific executable. It does not require a JDK at runtime. A native image uses less resources and is faster. The following images can be produced with a GraalVM JDK 17:
33
33
34
-
OS | amd64 (Intel)? | aarch64 (ARM)? |
35
-
------- | :-------------: | :------------: |
36
-
macOS | yes | yes |
37
-
Linux | yes | yes |
38
-
Windows | yes | - |
34
+
|OS | amd64 (Intel)? | aarch64 (ARM)? |
35
+
|---------|:--------------:|:--------------:|
36
+
|macOS |yes|yes|
37
+
|Linux |yes|yes|
38
+
|Windows |yes|-|
39
39
40
-
Currently there is no way to produce an ARM based (aarch64) native image for Windows.
40
+
Currently, there is no way to produce an ARM based (aarch64) native image for Windows.
41
41
42
42
Native images are not part of a release. You have to build them yourself as described [below](#how-to-build).
43
43
@@ -49,67 +49,11 @@ To run a native image open a terminal window and type
49
49
50
50
The parameters are the same as for the [executable JAR](#executable-jar).
51
51
52
-
## Important: Native Images Do not Work Anymore
53
-
54
-
Starting with SQLcl 23.1.0 it is not possible to build native images on all platforms anymore.
55
-
The reason is that the underlying parser uses AWT/Swing components (for whatever reason).
56
-
AWT/Swing components are supported on AMD/Linux platforms only by GraalVM.
57
-
As a result this build process will produce a non-working native image on most platforms.
58
-
59
-
You will see the following stacktrace similar to the following when running the resulting native image
60
-
(based on SQLcl 23.3.0 on macOS 14.1.2 with an M-series chip):
61
-
62
-
```
63
-
Exception in thread "main" javax.script.ScriptException: java.lang.Exception: java.lang.UnsatisfiedLinkError: no awt in java.library.path
64
-
at org.graalvm.nativeimage.builder/com.oracle.svm.core.jdk.NativeLibrarySupport.loadLibraryRelative(NativeLibrarySupport.java:136)
65
-
at java.base@17.0.9/java.lang.ClassLoader.loadLibrary(ClassLoader.java:50)
66
-
at java.base@17.0.9/java.lang.Runtime.loadLibrary0(Runtime.java:818)
67
-
at java.base@17.0.9/java.lang.System.loadLibrary(System.java:1989)
68
-
at java.desktop@17.0.9/java.awt.Toolkit$2.run(Toolkit.java:1388)
69
-
at java.desktop@17.0.9/java.awt.Toolkit$2.run(Toolkit.java:1386)
70
-
at java.base@17.0.9/java.security.AccessController.executePrivileged(AccessController.java:171)
71
-
at java.base@17.0.9/java.security.AccessController.doPrivileged(AccessController.java:318)
72
-
at java.desktop@17.0.9/java.awt.Toolkit.loadLibraries(Toolkit.java:1385)
73
-
at java.desktop@17.0.9/java.awt.Toolkit.initStatic(Toolkit.java:1423)
74
-
at java.desktop@17.0.9/java.awt.Toolkit.<clinit>(Toolkit.java:1397)
75
-
at java.desktop@17.0.9/java.awt.Component.<clinit>(Component.java:624)
76
-
at java.base@17.0.9/java.lang.Class.ensureInitialized(DynamicHub.java:579)
77
-
at java.base@17.0.9/java.lang.Class.ensureInitialized(DynamicHub.java:579)
78
-
at java.base@17.0.9/java.lang.Class.ensureInitialized(DynamicHub.java:579)
79
-
at java.base@17.0.9/java.lang.Class.ensureInitialized(DynamicHub.java:579)
80
-
at java.base@17.0.9/java.lang.Class.ensureInitialized(DynamicHub.java:579)
81
-
at oracle.dbtools.parser.Visual.<init>(Visual.java:404)
82
-
at oracle.dbtools.parser.Grammar.parseGrammarFile(Grammar.java:172)
83
-
at oracle.dbtools.parser.Grammar.parseGrammarFile(Grammar.java:152)
84
-
at oracle.dbtools.arbori.Program.getRules(Program.java:285)
85
-
at oracle.dbtools.arbori.Program.getArboriParser(Program.java:194)
86
-
at oracle.dbtools.arbori.Program.compile(Program.java:338)
87
-
at oracle.dbtools.arbori.Program.compile(Program.java:327)
88
-
at oracle.dbtools.arbori.SqlProgram.<init>(SqlProgram.java:32)
89
-
at oracle.dbtools.app.Format$3.<init>(Format.java:343)
90
-
at oracle.dbtools.app.Format.format(Format.java:343)
91
-
at <js>.formatInSandbox(<eval>:168)
92
-
at <js>.formatFile(<eval>:670)
93
-
at <js>.formatFiles(<eval>:683)
94
-
at <js>.run(<eval>:737)
95
-
at <js>.:program(<eval>:803)
96
-
at org.graalvm.sdk/org.graalvm.polyglot.Context.eval(Context.java:403)
97
-
at org.graalvm.js.scriptengine/com.oracle.truffle.js.scriptengine.GraalJSScriptEngine.eval(GraalJSScriptEngine.java:485)
98
-
at org.graalvm.js.scriptengine/com.oracle.truffle.js.scriptengine.GraalJSScriptEngine.eval(GraalJSScriptEngine.java:427)
99
-
at com.trivadis.plsql.formatter.TvdFormat.run(TvdFormat.java:36)
100
-
at com.trivadis.plsql.formatter.TvdFormat.main(TvdFormat.java:49)
101
-
```
102
-
103
-
This is really sad. However, there is nothing we can do.
104
-
We have to wait until the SQL Developer team decides to provide a parser that does not require AWT/Swing components (as in previous versions)
105
-
or until the GraalVM team provides a native-image build process that works on all platforms with AWT/Swing.
106
-
See also [macOS: no awt in java.library.path](https://github.com/oracle/graal/issues/4124).
107
-
108
52
## How to Build
109
53
110
-
1.[Download](https://www.oracle.com/tools/downloads/sqlcl-downloads.html) and install SQLcl 23.3.0
111
-
2.[Download](https://github.com/graalvm/graalvm-ce-builds/releases/tag/jdk-17.0.9) and install the GraalVM JDK 17.0.9
112
-
3.Go to the `bin` directory of the GraalVM JDK and run `./gu install js native-image visualvm`. For native image on Windows you need to [download](https://visualstudio.microsoft.com/downloads/) Visual Studio Community 2022 and install the C++ compiler. Use `x64 Native Tools Command Prompt for VS 2022` to get a terminal window with the correct environment.
54
+
1.[Download](https://www.oracle.com/tools/downloads/sqlcl-downloads.html) and install SQLcl 23.4.0
55
+
2.[Download](https://github.com/graalvm/graalvm-ce-builds/releases/tag/jdk-17.0.9) and install the GraalVM JDK 21.0.2
56
+
3. For native image on Windows you need to [download](https://visualstudio.microsoft.com/downloads/) Visual Studio Community 2022 and install the C++ compiler. Use `x64 Native Tools Command Prompt for VS 2022` to get a terminal window with the correct environment.
113
57
4.[Download](https://maven.apache.org/download.cgi) and install Apache Maven 3.9.6
114
58
5.[Download](https://git-scm.com/downloads) and install a git command line client
115
59
6. Clone the plsql-formatter-settings repository. The repository uses symbolic links. On Windows you have to use `git clone -c core.symlinks=true https://github.com/Trivadis/plsql-formatter-settings.git` as Administrator to make it work. See also [Symbolic Links in Windows](https://github.com/git-for-windows/git/wiki/Symbolic-Links) for more information.
@@ -138,14 +82,14 @@ See also [macOS: no awt in java.library.path](https://github.com/oracle/graal/is
138
82
139
83
You can define the following optional parameters:
140
84
141
-
| Parameter | Value | Meaning |
142
-
| -------------------------- | ------- |-------|
143
-
| `skip.native` | `true` | Do not produce a native image (default) |
0 commit comments