Forum Stats

  • 3,770,581 Users
  • 2,253,136 Discussions
  • 7,875,499 Comments

Discussions

PL/SQL Custom Syntax Rules is not working

User_H3J7U
User_H3J7U Member Posts: 693 Silver Trophy

I am trying to use an example https://vadimtropashko.wordpress.com/2019/08/01/arbori-semantic-actions/, but it is not working.

I added a rule WrongToDateNumOfArgs:

After restarting IDE Custom Syntax Rules pane show error PlainLanguageSupport cannot be cast to ArboriLanguageSupport:

java.lang.ClassCastException: oracle.javatools.editor.language.plain.PlainLanguageSupport cannot be cast to oracle.dbtools.raptor.plsql.structure.arbori.ArboriLanguageSupport

   at oracle.dbtools.raptor.plsql.structure.arbori.ArboriFoldingPlugin.createModel(ArboriFoldingPlugin.java:45)

   at oracle.javatools.editor.folding.CodeFoldingMargin.createCodeFoldingModel(CodeFoldingMargin.java:418)

   at oracle.javatools.editor.folding.CodeFoldingMargin.attach(CodeFoldingMargin.java:359)

   at oracle.javatools.editor.folding.AbstractCodeFoldingPlugin.attach(AbstractCodeFoldingPlugin.java:124)

   at oracle.javatools.editor.folding.AbstractCodeFoldingPlugin.installImpl(AbstractCodeFoldingPlugin.java:42)

   at oracle.javatools.editor.plugins.AbstractEditorPlugin.install(AbstractEditorPlugin.java:43)

   at oracle.javatools.editor.BasicEditorPane.installPlugin(BasicEditorPane.java:2722)

   at oracle.dbtools.raptor.plsql.structure.arbori.ArboriTextPane.<init>(ArboriTextPane.java:62)

   at oracle.dbtools.raptor.plsql.structure.arbori.ArboriTextPane.<init>(ArboriTextPane.java:38)

   at oracle.dbtools.raptor.config.SyntaxColorCustomOptions.<init>(SyntaxColorCustomOptions.java:60)

   at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

   at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)

   at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)

   at java.lang.reflect.Constructor.newInstance(Constructor.java:423)

   at java.lang.Class.newInstance(Class.java:442)

   at javax.ide.util.MetaClass.newInstance(MetaClass.java:154)

   at oracle.ide.javaxide.Util.createInstance(Util.java:60)

   at oracle.ide.javaxide.Util.createInstance(Util.java:40)

   at oracle.ide.extension.LazyClassAdapter.createInstance(LazyClassAdapter.java:65)

   at oracle.ide.config.ExtensionSettingsPage.newTraversable(ExtensionSettingsPage.java:106)

   at oracle.ide.config.ExtensionNavigable.newTraversable(ExtensionNavigable.java:87)

   at oracle.ide.panels.MetaTraversable.newTraversable(MetaTraversable.java:219)

   at oracle.ide.panels.MDDPanel.getTraversable(MDDPanel.java:1390)

   at oracle.ide.panels.MDDPanel.access$800(MDDPanel.java:129)

   at oracle.ide.panels.MDDPanel$Tsl.updateSelectedNavigable(MDDPanel.java:1653)

   at oracle.ide.panels.MDDPanel$Tsl.updateSelection(MDDPanel.java:1561)

   at oracle.ide.panels.MDDPanel$Tsl.actionPerformed(MDDPanel.java:1555)

   at javax.swing.Timer.fireActionPerformed(Timer.java:313)

   at javax.swing.Timer$DoPostEvent.run(Timer.java:245)

   at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)

   at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)

   at java.awt.EventQueue.access$500(EventQueue.java:97)

   at java.awt.EventQueue$3.run(EventQueue.java:709)

   at java.awt.EventQueue$3.run(EventQueue.java:703)

   at java.security.AccessController.doPrivileged(Native Method)

   at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)

   at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)

   at oracle.javatools.internal.ui.EventQueueWrapper._dispatchEvent(EventQueueWrapper.java:169)

   at oracle.javatools.internal.ui.EventQueueWrapper.dispatchEvent(EventQueueWrapper.java:151)

   at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)

   at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)

   at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:109)

   at java.awt.WaitDispatchSupport$2.run(WaitDispatchSupport.java:190)

   at java.awt.WaitDispatchSupport$4.run(WaitDispatchSupport.java:235)

   at java.awt.WaitDispatchSupport$4.run(WaitDispatchSupport.java:233)

   at java.security.AccessController.doPrivileged(Native Method)

   at java.awt.WaitDispatchSupport.enter(WaitDispatchSupport.java:233)

   at java.awt.Dialog.show(Dialog.java:1084)

   at java.awt.Component.show(Component.java:1671)

   at java.awt.Component.setVisible(Component.java:1623)

   at java.awt.Window.setVisible(Window.java:1014)

   at java.awt.Dialog.setVisible(Dialog.java:1005)

   at oracle.bali.ewt.dialog.JEWTDialog.runDialog(JEWTDialog.java:399)

   at oracle.bali.ewt.dialog.JEWTDialog.runDialog(JEWTDialog.java:360)

   at oracle.ide.dialogs.WizardLauncher.runDialog(WizardLauncher.java:55)

   at oracle.ide.panels.TDialogLauncher.showDialog(TDialogLauncher.java:225)

   at oracle.ide.config.IdeSettings.showDialog(IdeSettings.java:875)

   at oracle.ide.config.IdeSettings.showDialog(IdeSettings.java:612)

   at oracle.dbtools.raptor.standalone.IndexedPreferencesCommand$IndexPreferencesTask.invokeLater(IndexedPreferencesCommand.java:219)

   at oracle.dbtools.raptor.standalone.IndexedPreferencesCommand$IndexPreferencesTask$WaitOver$1.run(IndexedPreferencesCommand.java:231)

   at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)

   at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)

   at java.awt.EventQueue.access$500(EventQueue.java:97)

   at java.awt.EventQueue$3.run(EventQueue.java:709)

   at java.awt.EventQueue$3.run(EventQueue.java:703)

   at java.security.AccessController.doPrivileged(Native Method)

   at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)

   at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)

   at oracle.javatools.internal.ui.EventQueueWrapper._dispatchEvent(EventQueueWrapper.java:169)

   at oracle.javatools.internal.ui.EventQueueWrapper.dispatchEvent(EventQueueWrapper.java:151)

   at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)

   at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)

   at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)

   at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)

   at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)

   at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

When i removed the {java script} after -> at end of rule (custom_syntax.arbori file at home dir) and restarted the IDE, i see the new rule WrongToDateNumOfArgs in Syntax Colors/Available Styles,  but changing the color settings does not affect the code highlighting of to_date( defg ) as in example.

Oracle SQL Developer 21.2.1.204
 Version 21.2.1.204
Build 204.1703


Comments

  • Mike Kutz
    Mike Kutz Member Posts: 5,827 Silver Crown

    I'll have to check this out.

    I remember talking to someone about creating these rules. It might have been Vadim. I'll have to check

  • Vadim Tropashko-Oracle
    Vadim Tropashko-Oracle Posts: 1,243 Employee
    edited Oct 26, 2021 8:11PM

    Reproduced, bugged, thank you.

    Workaround:

    0. Delete AppData\Roaming\SQL Developer\system21.2.1.204.1703\o.sqldeveloper\custom_syntax.arbori

    1. Add a query without JS callback action, first:

    WrongToDateNumOfArgs:
    ( [node^) function_call
    | [node^) datetime_literal
    | [node^) function_expression
    ) & ?node = 'TO_DATE'
    & ([arg) expr
    | [arg) string_literal
    | [arg) pls_expr )
    &  arg^-1 = node
    & [arg+1) ')'
    & [arg-1) '('
    ;
    

    2. Press OK to save it, then restart sqldev

    3. At the parent preference panel Preferences -> Code Editor -> PL/SQL Syntax Colors you should be able to see the newly introduced style. Edit the color, and other attributes.

    4. Add javascript condition (without trailing semicolon):

    WrongToDateNumOfArgs:
    ( [node^) function_call
    | [node^) datetime_literal
    | [node^) function_expression
    ) & ?node = 'TO_DATE'
    & ([arg) expr
    | [arg) string_literal
    | [arg) pls_expr )
    &  arg^-1 = node
    & [arg+1) ')'
    & [arg-1) '('
    ->{
       var node = tuple.get("node");
       struct.addStyle(target, node, "WrongToDateNumOfArgs");
    }