Git Product home page Git Product logo

Comments (6)

PhilippSalvisberg avatar PhilippSalvisberg commented on August 26, 2024

Hi,

I cannot reproduce the problem. When I format this:

DECLARE
/* @formatter:off */
   full_dnames CLOB := 
   '[{"NAME":"ORDERNUMBER","TYPE":"NUMBER","DESIGNATION":"DIMENSION","GRADE":1},
   {"NAME":"ORDERNUMBER","TYPE":"VARCHAR","DESIGNATION":"DIMENSION","GRADE":1},
   {"NAME":"FIRSTNAME","TYPE":"VARCHAR","DESIGNATION":"ATTRIBUTE","GRADE":1}';
/* @formatter:on */
BEGIN
   NULL;
END; 

Then I get this formatted result:

declare
   /* @formatter:off */
   full_dnames CLOB := 
   '[{"NAME":"ORDERNUMBER","TYPE":"NUMBER","DESIGNATION":"DIMENSION","GRADE":1},
   {"NAME":"ORDERNUMBER","TYPE":"VARCHAR","DESIGNATION":"DIMENSION","GRADE":1},
   {"NAME":"FIRSTNAME","TYPE":"VARCHAR","DESIGNATION":"ATTRIBUTE","GRADE":1}';
/* @formatter:on */
begin
   null;
end;

I suspect that you do not use the settings provided in this repository. Another Arbori program. Maybe the default provided by SQLDev?

Could you please provide screenshots of your settings? They should look similar to this:

image

image

from plsql-formatter-settings.

jcarey9149 avatar jcarey9149 commented on August 26, 2024

I should mention that I can work around this with a strategically placed comment. However in the full case the assignment had to be broken up into a couple of strings, and I don't want the default '||' operator alignment (with the ':=') for the same reason as the first line break.

from plsql-formatter-settings.

jcarey9149 avatar jcarey9149 commented on August 26, 2024

I tried reloading the settings from the repository, and all my formatting went away. I'll look into this.

from plsql-formatter-settings.

jcarey9149 avatar jcarey9149 commented on August 26, 2024

I think you were right, but having reloaded the files there is no formatting. Looks like when I load the advanced xml file it resets the custom code. How can I debug this?

from plsql-formatter-settings.

jcarey9149 avatar jcarey9149 commented on August 26, 2024

Looks like the files as downloaded a couple of days ago just don't work with sqldeveloper 22.2.1. I reinstalled v 21.4.3 and it seems to be working.

from plsql-formatter-settings.

PhilippSalvisberg avatar PhilippSalvisberg commented on August 26, 2024

I think you were right

Thanks for confirming it.

having reloaded the files there is no formatting.
Looks like when I load the advanced xml file it resets the custom code.

Correct. Just follow the installation instructions. ;-)

How can I debug this?

Debugging in SQLDev is a bit tricky. The simplest approach is to enable logging. You have to change the logging.conf in SQLDev. This comment explains how to do it.

However, you can also check the version of the Arbori program in the Setting under "Code Editor -> Format -> Advanced Format -> Custom Format". As shown in the screenshot above. Here are some links based on released versions:

Looks like the files as downloaded a couple of days ago just don't work with sqldeveloper 22.2.1.

The current version in the main branch is 5 months old and works with a manually patched version of SQLDev 22.2.1 and SQLcl 22.3.0 and SQLcl 22.4.0.

The latest release is from 2022-10-09.

So, which version did you download? Actually, one that does not match the product version you are using.

The XML configuration file trivadis_advanced_format.xmlis more or less version independent. However, the Arbor file trivadis_custom_format.arbori is very much dependent on the version of SQLDev and SQLcl. Unfortunately, the release cycles of SQLDev and SQLDev are independent now. This leads to the situation where sometimes no configuration exists that works in the latest versions of both products. The dirty workaround is to manually patch SQLDev with the libraries from SQLcl.

The reason for the version-dependency is that the Arbori program queries the parse-tree and uses specific symbol names expected in the parse tree. When new SQL features are supported in the product or parser bugs are fixed then the parse-tree structure and the used symbol names change as well. This leads to runtime errors in the Arbori program. This is why you really need to check that you install the configuration for the correct product version.

If you are interested in the details you can look at the differences between version sqldev-21.4.3 and sqlcl-22.3.0. There you see that some symbol names in trivadis_custom_format.arbori have changed, e.g.

  • column[4,12) to column___0
  • create_view#[114,130) to create_view#___0
  • create_materialized_view[33,79) to create_materialized_view2___0
  • "inner_cross_join_clause"[26,55) to "inner_cross_join_clause"___0
  • in_condition[24,35) to in_condition___0
  • simple_case_expression[4,27)# to simple_case_expression___0#
  • create_materialized_view[91,136) to create_materialized_view3___2
  • create_materialized_view[136,174) to create_materialized_view3___3
  • create_materialized_view[200,210) to create_materialized_view3___0
  • insert_into_clause[13,25) to insert_into_clause___0
  • merge_insert_clause[23,35) to merge_insert_clause___0
  • merge_insert_clause[43,50) to merge_insert_clause___2
  • ...

In other words, a lot changed between these versions making them completely incompatible from a SQL grammar point of view.

In https://github.com/Trivadis/plsql-formatter-settings/releases you find all released versions for the formatter settings. There is also a section that defines the compatibility with SQLDev and SQLcl. In some cases, you have to manually patch SQLDev to make it work (copy a JAR file from the SQLcl installation). If you do not want to do that, you have to use a different version.

from plsql-formatter-settings.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.