You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
davidmichaelkarr
changed the title
Compiles of all files in all open projects should happen on buffer save
Compiles of all files in all open projects should happen on buffer save and project properties change
Dec 4, 2015
After some research and consideration, it's clear to me that the correct way to do this is to implement a "YangNature" and a builder that utilizes the Yang compiler. The YangNature would be associated with the project in the "YangProjectWizard.performFinish()" method, but a developer could manually assign the Yang nature to an existing Java/Maven project at any time, getting them full Yang functionality without needing to create a Yang project. There are aspects of this potential implementation that are unclear to me, mostly what will happen in the "builder" class associated with the nature.
I was able to make a "YangNature" class, along with a "YangProjectBuilder" (extends "IncrementalProjectBuilder"), along with all the required connections into the project. However, even when I've determined that the visitor has found a resource which is a Yang file, I don't know how to plug it into the build process. Setting a breakpoint in "YangParserUtil" and going through the steps that compile Yang files is somewhat informative, by inspecting the stack at that point, but that doesn't lead me to how to properly queue a yang file for compilation. I had thought before that using the "IndexManager" to queue files would do it, but that didn't appear to do anything useful.
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.
The text was updated successfully, but these errors were encountered: