List Info

Thread: Getting the structured model in unit tests




Getting the structured model in unit tests
country flaguser name
Israel
2007-08-09 03:34:06

There were a few different versions. This is the way it should be done:

 

      // get a file from the project

      IFile file = getProject().getFile(fileName);

 

// get the equivalent model – for read or edit

      final IStructuredModel modelForEdit = StructuredModelManager.getModelManager().getModelForEdit(file);

 

      try {

            // get the document

            final IStructuredDocument document = modelForEdit.getStructuredDocument();

 

            // do the test here

            // ...

            // ...

 

      } finally {

 

            // release the model from read or edit

            if (modelForEdit != null) {

                 ; modelForEdit.releaseFromEdit();

            }

      }

 

 

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )