AdaCore / ada_language_server

Server implementing the Microsoft Language Protocol for Ada and SPARK
GNU General Public License v3.0
230 stars 54 forks source link

Valid Ada statement causes a loss of syntax highlighting and code navigation #1139

Open Joebeazelman opened 1 year ago

Joebeazelman commented 1 year ago

In the code below, the third line uses an odd syntax, which although valid to the compiler and Ada Language Server, results in a partial loss of syntax coloring and code navigation options. When the line is commented out, the syntax coloring returns along with code navigation, except for the line directly under it.

procedure Main is ... use type USB.Device.Init_Result; -- lose syntax highlighting and other features Status : USB.Device.Init_Result; -- this line is partially highlighted when the line above is commented out begin
... end; end main;


Interestingly, removing the line produces an error message when compiled:

> operator for type "Init_Result" defined at usb-device.ads:41 is not directly visible

package USB.Device is

type Init_Result is (Ok, Not_Enough_EPs, Not_Enough_EP_Buffer);

end USB.Device;

reznikmm commented 1 year ago

I'm unable to reproduce this. Could you provide the complete code?

petacreepers23 commented 1 year ago

I have a similar problem with uses,

having defined and in the path of the gpr:

generic
  V_DATA: STRING;
package Q_OTHER.Q_GENERIC is 
  procedure P_PROCEDURE (V_PARAM : T_TYPE);
...

Then having in file.ads sometihng like:

package Q_PACK_INSTANCE is new Q_OTHER.Q_GENERIC ("SOME_DATA");

and in the body of file.adb

use Q_PACK_INSTANCE ;

The calls to functions defined in Q_OTHER.Q_GENERIC are no longer colored nor is able to navigate to the definition of those.

procedure P_MYPROCEDURE is
begin
    P_PROCEDURE (7); --No color and no navigation to the generic definition
end P_MYPROCEDURE;
reznikmm commented 1 year ago

We still need a complete reproducer. I've tried this one and it works as expected:

package Q_OTHER is
end Q_OTHER;

generic
  V_DATA: STRING;
package Q_OTHER.Q_GENERIC is
   procedure P_PROCEDURE (V_PARAM : Integer);
end Q_OTHER.Q_GENERIC;

with Q_OTHER.Q_GENERIC;
package Q_PACK_INSTANCE is new Q_OTHER.Q_GENERIC ("SOME_DATA");

with Q_PACK_INSTANCE;
procedure Main is
   use Q_PACK_INSTANCE ;
begin
   P_PROCEDURE (7);  -- adsa11213
   Main;
end Main;