[jbosstools-commits] JBoss Tools SVN: r41757 - 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 Jun 6 19:15:47 EDT 2012


Author: akazakov
Date: 2012-06-06 19:15:45 -0400 (Wed, 06 Jun 2012)
New Revision: 41757

Modified:
   trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/PageContextFactory.java
Log:
https://issues.jboss.org/browse/JBIDE-10738 As-you-type EL validation

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-06-06 20:22:00 UTC (rev 41756)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/PageContextFactory.java	2012-06-06 23:15:45 UTC (rev 41757)
@@ -285,11 +285,16 @@
 		}
 	}
 
-	private ELContext createPropertiesContext(IFile file) {
+	private ELContext createPropertiesContext(IFile file, IDocument document, boolean useLastSavedStateOfFile) {
 		ELContextImpl context = new ELContextImpl();
 		context.setResource(file);
 		context.setElResolvers(ELResolverFactoryManager.getInstance().getResolvers(file));
-		String content = FileUtil.getContentFromEditorOrFile(file);
+		String content = null;
+		if(document==null || useLastSavedStateOfFile) {
+			content = FileUtil.getContentFromEditorOrFile(file);
+		} else {
+			content = document.get();
+		}
 		if(content.indexOf('{')>-1 && content.indexOf(EL_START_1) >-1 || content.indexOf(EL_START_2)>-1 ) {
 			ELReference elReference = new ValidationELReference();
 			elReference.setResource(file);
@@ -297,18 +302,19 @@
 			elReference.setStartPosition(0);
 			elReference.init(content);
 			context.addELReference(elReference);
-			
 		}
 		return context;
 	}
 
-	private static ELContext createJavaContext(IFile file) {
+	private static ELContext createJavaContext(IFile file, IDocument document, boolean useLastSavedStateOfFile) {
 		ELContextImpl context = new ELContextImpl();
 		context.setResource(file);
 		context.setElResolvers(ELResolverFactoryManager.getInstance().getResolvers(file));
-		String content = FileUtil.getContentFromEditorOrFile(file);
 		FastJavaPartitionScanner scaner = new FastJavaPartitionScanner();
-		Document document = new Document(content);
+		if(document==null || useLastSavedStateOfFile) {
+			String content = FileUtil.getContentFromEditorOrFile(file);
+			document = new Document(content);
+		}
 		scaner.setRange(document, 0, document.getLength());
 		IToken token = scaner.nextToken();
 		while(token!=null && token!=Token.EOF) {
@@ -371,9 +377,9 @@
 			String typeId = getContentTypeIdentifier(file == null ? document : file);
 
 			if(JavaCore.JAVA_SOURCE_CONTENT_TYPE.equalsIgnoreCase(typeId)) {
-				context = createJavaContext(file);
+				context = createJavaContext(file, document, !dontUseCache);
 			} else if(JAVA_PROPERTIES_CONTENT_TYPE.equalsIgnoreCase(typeId)) {
-				context = createPropertiesContext(file);
+				context = createPropertiesContext(file, document, !dontUseCache);
 			} else if(file != null && isXMLWithoutEL(file)) {
 				IProject project = file != null ? file.getProject() : getActiveProject();
 				context = new SimpleELContext();
@@ -405,7 +411,7 @@
 								IProject project = file != null ? file.getProject() : getActiveProject();
 								
 								context.setElResolvers(ELResolverFactoryManager.getInstance().getResolvers(project));
-								if (context instanceof JspContextImpl && !(context instanceof FaceletPageContextImpl)) {
+								if (document!=null && context instanceof JspContextImpl && !(context instanceof FaceletPageContextImpl)) {
 									// Fill JSP namespaces defined in TLDCMDocumentManager 
 									fillJSPNameSpaces((JspContextImpl)context, document);
 								}



More information about the jbosstools-commits mailing list