Comments (3)
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](https://private-user-images.githubusercontent.com/20703207/271821658-d743c516-1461-413d-b8a0-1ad441c8b519.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjMzODk3OTAsIm5iZiI6MTcyMzM4OTQ5MCwicGF0aCI6Ii8yMDcwMzIwNy8yNzE4MjE2NTgtZDc0M2M1MTYtMTQ2MS00MTNkLWI4YTAtMWFkNDQxYzhiNTE5LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MTElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODExVDE1MTgxMFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTkwZGQ5ZDVjZTQ3Y2RjMzY5YzNjNzQyYTNmOTExZWUxMjNhY2NjYjEzMDBmNzZjYmQzMWJmYzQwYzJlYWFlMGMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.JhOv923oyjqFMRulXCkcoymWd4rSnJWMJB9CnJcFOZY)
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
- Check if "67kW" is a known GAMS symbol → false (more on that later)
- Check if "67kW" is a quoted string → true
- Parse the source code line to find all GAMS symbols that look like this
symbol(domain1,...,domainN)
using PEG.js - 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 setmachVar
Known issues
- Parsing currently fails if there is a whitespace before or after the "," separating the domains
- 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 setsset a / test/;
andset b /test/;
, and a parameter defined asp_test(a,b);
. If the parameter is called in the source code usingp_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.
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:
from gams-ide.
fixed by #4
from gams-ide.
Related Issues (20)
- Slow gams execution
- Reflection of changes in GUI HOT 4
- Add "Ignore files for multi-file-entry point" option HOT 1
- "Run" command not working in .lst files HOT 1
- Add option to hide user error message when parsing symbol values HOT 1
- Add snippets for gams builtin functions
- Add proper documentation outside of README
- Max. errors to display setting is ignored
- Fix buttons in error messages pointing to wrong settings
- Rename "multi-file entry point" setting to "Main GMS file" to match GAMS Studio
- Add statusbar item displaying current "main gms file"
- Error opening gams-view when secondary sidebar is closed HOT 1
- Implement more LSP features such as "go to definition" etc
- Provide info about compile time variables
- Parsing symbol values fails in FarmDyn - Empty data statements not allowed HOT 1
- Should this package provide autocomplete suggestions HOT 4
- Does not always move to top of listing HOT 3
- Listing always jumps to the end HOT 2
- "Run this file" command - .lst is not saved in same directory as .gms file when multi-file entry point is defined
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gams-ide.