GithubHelp home page GithubHelp logo

Comments (3)

chrispahm avatar chrispahm commented on August 25, 2024

Made a suggestion in #4, you can download the extension (VSIX) including the suggested changes here:
https://github.com/chrispahm/gams-ide/files/12776899/gams-ide-0.0.5.vsix.zip

image

Clicking on a quoted element will now show the expected set at the argument position of the enclosing parameter/variable/equation/set in the sidebar.

The picture shows this for the quoted element "67kW": It is the 2nd domain argument of the op_attr parameter. Upon clicking on "67kW", gams-ide performs the following steps

  1. Check if "67kW" is a known GAMS symbol → false (more on that later)
  2. Check if "67kW" is a quoted string → true
  3. Parse the source code line to find all GAMS symbols that look like this symbol(domain1,...,domainN) using PEG.js
  4. Find the encapsulating GAMS symbol corresponding to the clicked range (op_attr in the example), check it's domain (operation,machVar,rounded_plotSize,opAttr), and return the set found at the index position of the clicked symbol (cursor is on 2nd domain position) → which is the set machVar

Known issues

  1. Parsing currently fails if there is a whitespace before or after the "," separating the domains
  2. In a (rare) scenario where multiple sets contain an element with the same name, and a parameter is referencing these sets, it may occur that the plugin shows the wrong set for the index position.
    E.g consider the sets set a / test/; and set b /test/;, and a parameter defined as p_test(a,b);. If the parameter is called in the source code using p_test("test","test);, clicking on the second instance of "test" will result in the set a being shown in the sidebar, instead of the correct set b.

This happens because PEG.js outputs the same start and end locations for every domain encountered within a symbol, e.g.

{
    type: "functionCall",
    name: "c_p_t_i",
    args: [
      {
        name: "curCrops",
        location: {
          start: { offset: 8, line: 1, column: 9 },
          end: { offset: 39, line: 1, column: 40 },
        },
      },
      {
        name: "plot",
        location: {
          start: { offset: 8, line: 1, column: 9 },
          end: { offset: 39, line: 1, column: 40 },
        },
      },

To find the index of the domain that was clicked upon, we currently check if the word that was clicked upon is included the domains "name" property, and also if the start and end positions match with the current cursor position.
In order to solve this issue, the parser would need to be improved to ideally show the correct line for the specific elements and not the whole range.

from gams-ide.

chrispahm avatar chrispahm commented on August 25, 2024

Alright, I updated the parser which should fix the issues mentioned above!
Please try the attached new beta, which also includes a simple hint if a quoted element is clicked so it's easier to see if the package actually finds the correct set for the given position:
image

gams-ide-0.0.51.vsix.zip

from gams-ide.

chrispahm avatar chrispahm commented on August 25, 2024

fixed by #4

from gams-ide.

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.