@@ -557,29 +557,36 @@ protected FileInfo createFileInfo(Object element) throws CoreException {
557
557
LocationKind locationKind = null ;
558
558
559
559
file = adaptable .getAdapter (IFile .class );
560
- if (file != null ) {
561
- IPath location = file .getFullPath ();
562
- locationKind = LocationKind .IFILE ;
563
- manager .connect (location , locationKind ,getProgressMonitor ());
564
- fileBuffer = manager .getTextFileBuffer (location , locationKind );
565
- } else {
566
- ILocationProvider provider = adaptable .getAdapter (ILocationProvider .class );
567
- if (provider instanceof ILocationProviderExtension ) {
568
- URI uri = ((ILocationProviderExtension )provider ).getURI (element );
569
- if (ResourcesPlugin .getWorkspace ().getRoot ().findFilesForLocationURI (uri ).length == 0 ) {
570
- IFileStore fileStore = EFS .getStore (uri );
571
- manager .connectFileStore (fileStore , getProgressMonitor ());
572
- fileBuffer = manager .getFileStoreTextFileBuffer (fileStore );
560
+ IProgressMonitor progressMonitor = getProgressMonitor ();
561
+ try {
562
+ if (file != null ) {
563
+ IPath location = file .getFullPath ();
564
+ locationKind = LocationKind .IFILE ;
565
+ manager .connect (location , locationKind , progressMonitor );
566
+ fileBuffer = manager .getTextFileBuffer (location , locationKind );
567
+ } else {
568
+ ILocationProvider provider = adaptable .getAdapter (ILocationProvider .class );
569
+ if (provider instanceof ILocationProviderExtension ) {
570
+ URI uri = ((ILocationProviderExtension ) provider ).getURI (element );
571
+ if (ResourcesPlugin .getWorkspace ().getRoot ().findFilesForLocationURI (uri ).length == 0 ) {
572
+ IFileStore fileStore = EFS .getStore (uri );
573
+ manager .connectFileStore (fileStore , progressMonitor );
574
+ fileBuffer = manager .getFileStoreTextFileBuffer (fileStore );
575
+ }
576
+ }
577
+ if (fileBuffer == null && provider != null ) {
578
+ IPath location = provider .getPath (element );
579
+ if (location == null )
580
+ return null ;
581
+ locationKind = LocationKind .NORMALIZE ;
582
+ manager .connect (location , locationKind , progressMonitor );
583
+ fileBuffer = manager .getTextFileBuffer (location , locationKind );
584
+ file = FileBuffers .getWorkspaceFileAtLocation (location );
573
585
}
574
586
}
575
- if (fileBuffer == null && provider != null ) {
576
- IPath location = provider .getPath (element );
577
- if (location == null )
578
- return null ;
579
- locationKind = LocationKind .NORMALIZE ;
580
- manager .connect (location , locationKind , getProgressMonitor ());
581
- fileBuffer = manager .getTextFileBuffer (location , locationKind );
582
- file = FileBuffers .getWorkspaceFileAtLocation (location );
587
+ } finally {
588
+ if (progressMonitor != null ) {
589
+ progressMonitor .done ();
583
590
}
584
591
}
585
592
@@ -692,14 +699,19 @@ private void removeFileBufferMapping(Object element, FileInfo info) {
692
699
*/
693
700
protected void disposeFileInfo (Object element , FileInfo info ) {
694
701
IFileBufferManager manager = FileBuffers .getTextFileBufferManager ();
702
+ IProgressMonitor progressMonitor = getProgressMonitor ();
695
703
try {
696
704
info .fTextFileBuffer .releaseSynchronizationContext ();
697
705
if (info .fTextFileBufferLocationKind != null )
698
- manager .disconnect (info .fTextFileBuffer .getLocation (), info .fTextFileBufferLocationKind , getProgressMonitor () );
706
+ manager .disconnect (info .fTextFileBuffer .getLocation (), info .fTextFileBufferLocationKind , progressMonitor );
699
707
else
700
- manager .disconnectFileStore (info .fTextFileBuffer .getFileStore (), getProgressMonitor () );
708
+ manager .disconnectFileStore (info .fTextFileBuffer .getFileStore (), progressMonitor );
701
709
} catch (CoreException x ) {
702
710
handleCoreException (x , "FileDocumentProvider.disposeElementInfo" ); //$NON-NLS-1$
711
+ } finally {
712
+ if (progressMonitor != null ) {
713
+ progressMonitor .done ();
714
+ }
703
715
}
704
716
}
705
717
@@ -747,7 +759,14 @@ public ISchedulingRule getSchedulingRule() {
747
759
return null ;
748
760
}
749
761
};
750
- executeOperation (operation , getProgressMonitor ());
762
+ IProgressMonitor progressMonitor = getProgressMonitor ();
763
+ try {
764
+ executeOperation (operation , progressMonitor );
765
+ } finally {
766
+ if (progressMonitor != null ) {
767
+ progressMonitor .done ();
768
+ }
769
+ }
751
770
} else {
752
771
getParentProvider ().resetDocument (element );
753
772
}
@@ -1034,7 +1053,14 @@ public ISchedulingRule getSchedulingRule() {
1034
1053
return null ;
1035
1054
}
1036
1055
};
1037
- executeOperation (operation , getProgressMonitor ());
1056
+ IProgressMonitor progressMonitor = getProgressMonitor ();
1057
+ try {
1058
+ executeOperation (operation , progressMonitor );
1059
+ } finally {
1060
+ if (progressMonitor != null ) {
1061
+ progressMonitor .done ();
1062
+ }
1063
+ }
1038
1064
} else
1039
1065
((IDocumentProviderExtension ) getParentProvider ()).validateState (element , computationContext );
1040
1066
}
@@ -1118,7 +1144,14 @@ public ISchedulingRule getSchedulingRule() {
1118
1144
return null ;
1119
1145
}
1120
1146
};
1121
- executeOperation (operation , getProgressMonitor ());
1147
+ IProgressMonitor progressMonitor = getProgressMonitor ();
1148
+ try {
1149
+ executeOperation (operation , progressMonitor );
1150
+ } finally {
1151
+ if (progressMonitor != null ) {
1152
+ progressMonitor .done ();
1153
+ }
1154
+ }
1122
1155
} else {
1123
1156
((IDocumentProviderExtension ) getParentProvider ()).synchronize (element );
1124
1157
}
0 commit comments