[jbosstools-commits] JBoss Tools SVN: r41559 - trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Wed May 30 19:53:15 EDT 2012


Author: scabanovich
Date: 2012-05-30 19:53:15 -0400 (Wed, 30 May 2012)
New Revision: 41559

Modified:
   trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/PageContextFactory.java
Log:
JBIDE-10738
https://issues.jboss.org/browse/JBIDE-10738
Improved method PageContextFactory.getResource() to find IFile for an arbitrary IDocument.



Modified: trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/PageContextFactory.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/PageContextFactory.java	2012-05-30 23:36:06 UTC (rev 41558)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/PageContextFactory.java	2012-05-30 23:53:15 UTC (rev 41559)
@@ -22,6 +22,7 @@
 import java.util.Set;
 
 import org.eclipse.core.filebuffers.FileBuffers;
+import org.eclipse.core.filebuffers.ITextFileBuffer;
 import org.eclipse.core.internal.resources.ICoreConstants;
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IProject;
@@ -31,6 +32,7 @@
 import org.eclipse.core.resources.IResourceDelta;
 import org.eclipse.core.resources.IStorage;
 import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.Path;
@@ -503,6 +505,18 @@
 				sModel.releaseFromRead();
 			}
 		}
+
+		ITextFileBuffer buffer = FileBuffers.getTextFileBufferManager().getTextFileBuffer(document);
+		if (buffer != null && buffer.getLocation() != null) {
+			IPath path = buffer.getLocation();
+			if (path.segmentCount() > 1) {
+				IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
+				if (file.isAccessible()) {
+					return file;
+				}
+			}
+		}
+
 		return null;
 	}
 	



More information about the jbosstools-commits mailing list