Description
I have a simple test case with two Yang files, named "bar.yang" and "baz.yang", where "bar.yang" imports the "baz" module. At the start of the test, these files are both green.
Now go to "baz.yang". Select the entire contents and press Delete. Then save the buffer.
Considering the principle of "least surprise", what would you expect to see at this point?
From my POV, I would expect to see a compile error in "bar.yang", saying that it can't find module "baz". I would also expect some sort of error in "baz.yang", as it's obviously not a valid source file at that point.
What actually happens is that we get only a single compile error, in "baz.yang", stating "no viable alternative at input ''". Not exactly the most understandable message, but it's something.
There is no compile error in "bar.yang", even though the referenced module doesn't exist anymore.
Now we go into "bar.yang", which presently is green. Put the cursor anywhere it is legal to insert a single space character. The end of the buffer is fine. Press the space bar. At this point, compile errors appear, because of the missing module.
You can "undo" the added space character at this point.
Now go back to "baz.yang" and undo the emptying of the buffer. Save the file. Note that now "baz.yang" is now green, but "bar.yang" is still red.
Go back to "bar.yang", seeing the compile errors still there. Put the cursor where a space character can be inserted. Press the space bar. The compile errors go away. Undo the space insertion.
These tests verify that compiles of the current buffer happen when the buffer is changed, but nothing else is compiled unless the buffer with that file changes.
What really needs to happen is that in addition to the compile of the current file on buffer change, an additional set of compiles needs to fire when that buffer is saved to disk. I believe this should be all indexed yang files in all open projects. I see no reason why imported files that are not in open projects should be compiled at this point (for instance, imported modules found in maven or source dependencies, not from open projects).
In addition to "wider" compiles running on buffer save, saving the project properties also needs to recompile the project. If I change the project dependencies, adding (or removing) a project that provides valid Yang modules to import, when I click OK on the project properties dialog, the compile should be spawned at that point.
I'm finding that the only reliable way I can make sure things are up to date is just doing lots of "Project"->"Clean" operations, and selecting all projects. This is really inefficient.