OpenModelica / modelica-language-server

A VS Code language server extension for Modelica.
Other
5 stars 2 forks source link

Implement Document Highlights Request #11

Open AnHeuermann opened 9 months ago

AnHeuermann commented 9 months ago

Description

Document Highlights Request

The document highlight request is sent from the client to the server to resolve document highlights for a given text document position. For programming languages this usually highlights all references to the symbol scoped to this file. However, we kept ‘textDocument/documentHighlight’ and ‘textDocument/references’ separate requests since the first one is allowed to be more fuzzy. Symbol matches usually have a DocumentHighlightKind of Read or Write whereas fuzzy or textual matches use Text as the kind.

Desired features

Examples

Check Modelica.Blocks.Examples.PID_Controller from the MSL. Highlighting PI should highlight all locations of PI inside the model.

model PID_Controller
  "Demonstrates the usage of a Continuous.LimPID controller"
  extends Modelica.Icons.Example;
  parameter SI.Angle driveAngle=1.570796326794897
    "Reference distance to move";
  Modelica.Blocks.Continuous.LimPID PI(
    k=100,
    Ti=0.1,
    yMax=12,
    Ni=0.1,
    initType=Modelica.Blocks.Types.Init.SteadyState,
    controllerType=Modelica.Blocks.Types.SimpleController.PI,
    limiter(u(start = 0)),
    Td=0.1) annotation (Placement(transformation(extent={{-56,-20},{-36,0}})));
  Modelica.Mechanics.Rotational.Components.Inertia inertia1(
    phi(fixed=true, start=0),
    J=1,
    a(fixed=true, start=0)) annotation (Placement(transformation(extent={{2,-20},
            {22,0}})));

  Modelica.Mechanics.Rotational.Sources.Torque torque annotation (Placement(
        transformation(extent={{-25,-20},{-5,0}})));
  Modelica.Mechanics.Rotational.Components.SpringDamper spring(
    c=1e4,
    d=100,
    stateSelect=StateSelect.prefer,
    w_rel(fixed=true)) annotation (Placement(transformation(extent={{32,-20},
            {52,0}})));
  Modelica.Mechanics.Rotational.Components.Inertia inertia2(J=2) annotation (
      Placement(transformation(extent={{60,-20},{80,0}})));
  Modelica.Blocks.Sources.KinematicPTP kinematicPTP(
    startTime=0.5,
    deltaq={driveAngle},
    qd_max={1},
    qdd_max={1}) annotation (Placement(transformation(extent={{-92,20},{-72,
            40}})));
  Modelica.Blocks.Continuous.Integrator integrator(initType=Modelica.Blocks.Types.Init.InitialState)
    annotation (Placement(transformation(extent={{-63,20},{-43,40}})));
  Modelica.Mechanics.Rotational.Sensors.SpeedSensor speedSensor annotation (
      Placement(transformation(extent={{22,-50},{2,-30}})));
  Modelica.Mechanics.Rotational.Sources.ConstantTorque loadTorque(
      tau_constant=10, useSupport=false) annotation (Placement(transformation(
          extent={{98,-15},{88,-5}})));
initial equation
  der(spring.w_rel) = 0;

equation
  connect(spring.flange_b, inertia2.flange_a)
    annotation (Line(points={{52,-10},{60,-10}}));
  connect(inertia1.flange_b, spring.flange_a)
    annotation (Line(points={{22,-10},{32,-10}}));
  connect(torque.flange, inertia1.flange_a)
    annotation (Line(points={{-5,-10},{2,-10}}));
  connect(kinematicPTP.y[1], integrator.u)
    annotation (Line(points={{-71,30},{-65,30}}, color={0,0,127}));
  connect(speedSensor.flange, inertia1.flange_b)
    annotation (Line(points={{22,-40},{22,-10}}));
  connect(loadTorque.flange, inertia2.flange_b)
    annotation (Line(points={{88,-10},{80,-10}}));
  connect(PI.y, torque.tau)
    annotation (Line(points={{-35,-10},{-27,-10}}, color={0,0,127}));
  connect(speedSensor.w, PI.u_m)
    annotation (Line(points={{1,-40},{-46,-40},{-46,-22}}, color={0,0,127}));
  connect(integrator.y, PI.u_s) annotation (Line(points={{-42,30},{-37,30},{-37,
          11},{-67,11},{-67,-10},{-58,-10}}, color={0,0,127}));
end PID_Controller;