[YANGIDE-3] Yang parser is only run on the current buffer when it changes, which results in inconsistencies in compile errors Created: 05/May/16  Updated: 19/Oct/17

Status: Open
Project: yangide
Component/s: General
Affects Version/s: unspecified
Fix Version/s: None

Type: Bug
Reporter: David M. Karr Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Operating System: All
Platform: All


External issue ID: 5847

 Description   

When a change is made to a Yang module in the editor, only that Yang module is compiled by the Yang parser.

This can create inconsistencies. The required situations may be contrived, but they can be easily demonstrated.

Say a project has both a "foo.yang" and a "bar.yang", and the former imports the latter.

Assume there are no parser errors at this point.

Now go into "bar.yang" and change the module name from "bar" to "baz". Save it.

What you would expect to happen at this point is to see a compile error marker in "foo", because it references a module that isn't defined. That is not the case.

Now go into "foo.yang". Put the cursor at the end of any line and add a space. The error about the missing import file will immediately appear (although not necessarily as a proper compile marker in the editor view). Save the file.

Go back into "bar.yang". Change the module name back to "bar". Save the file. The error in "foo.yang" should still be there.

Now go back to "foo.yang". Add a space again. See the error go away.

The crux of the problem here is that the Yang parser is only run on a single file at once (unless you're doing a full build).

I believe the solution to this requires implementing a "Builder" and a "Nature". I understand the basic structure of these, but I don't understand how the Builder is going to invoke the Yang parser on the modules that need to be recompiled. I don't know if there's a way to know which ones need to be recompiled, except to recompile all the modules in the project.

The Nature is perhaps simpler. I believe the Nature would be associated with the project in "com.cisco.yangide.ui.wizards.YangProjectWizard.performFinish()".



 Comments   
Comment by Michael Vorburger [ 09/May/16 ]

Personally I would solve this bug by completely re-implementing a part of yangide (the editor related part; the code generation one from yangtools could probably stay as is) using https://www.eclipse.org/Xtext/), because that has a lot of infrastructure which would take care of and avoid a problem such as the one described here (i.e. it has a full sophisticated "model index" which can track references, and should detect this kind of case) ..

Comment by David M. Karr [ 09/May/16 ]

That sounds like overkill to me. The YangIDE already indexes all of the components in its parsed models. It's not reasonable to throw out a major portion of the architecture because we're having trouble understanding how to extend it to fix a flaw that many people would never notice.

Generated at Wed Feb 07 20:48:25 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.