Bug 546920 - FileDocumentProvider.createElementInfo(Object) should not
refresh unconditionally

An attempt to call refreshFile() while workspace is locked results in a
blocking progress dialog. This is not needed if the file is not
out-of-sync, which can be tested via *non-blocking*
file.isSynchronized() API. This patch does exact that.

Change-Id: Ia1b0b7ba250f92e49bbe4343ba542a5d5c4e752b
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/FileDocumentProvider.java b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/FileDocumentProvider.java
index a61d061..be9d6f9 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/FileDocumentProvider.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/FileDocumentProvider.java
@@ -673,10 +673,15 @@
 
 			IFileEditorInput input= (IFileEditorInput) element;
 
-			try {
-				refreshFile(input.getFile());
-			} catch (CoreException x) {
-				handleCoreException(x, TextEditorMessages.FileDocumentProvider_createElementInfo);
+			// Note that file.isSynchronized does not require a scheduling rule and thus helps to identify a no-op attempt
+			// to refresh the file. The no-op will otherwise be blocked by a running build or cancel a running build
+			IFile file= input.getFile();
+			if (!file.isSynchronized(IResource.DEPTH_ZERO)) {
+				try {
+					refreshFile(file);
+				} catch (CoreException x) {
+					handleCoreException(x, TextEditorMessages.FileDocumentProvider_createElementInfo);
+				}
 			}
 
 			IDocument d= null;