Some resource optimizations.
diff --git a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/JsTranslation.java b/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/JsTranslation.java
index 87b9524..c829e31 100644
--- a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/JsTranslation.java
+++ b/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/JsTranslation.java
@@ -61,21 +61,11 @@
 	
 	private ICompilationUnit fCompilationUnit = null;
 	private DocumentContextFragmentRoot fDocumentScope;
-	
-	
-	//private String fHtmlMangledPageName = ""; //$NON-NLS-1$
-	/** the name of the class (w/out extension) * */
-	//private String fHtmlPageName;
-	//private String fHtmlText = ""; //$NON-NLS-1$
 	private IJavaProject fJavaProject = null;
-	//private String fJsText = ""; //$NON-NLS-1$
-	/** lock to synchronize access to the compilation unit * */
 	private byte[] fLock = null;
 	private IProgressMonitor fProgressMonitor = null;
-	//private Position[] importRanges;
-	//private Position[] locationsInHtml;
-	//private IFile targetFile;
 	private IStructuredDocument fHtmlDocument;
+	private String fModelBaseLocation;
 	
 	
 	private static final String SUPER_TYPE_NAME = "Window";
@@ -89,28 +79,9 @@
 		fLock = new byte[0];
 		fJavaProject = javaProj;
 		fHtmlDocument = htmlDocument;
-	
-		
-		translator = new JsTranslator(getModel());
-		//resetDocScope();
-		mangledName = createMangledName();
-//		if (xmlModel != null) {
-//			
-//			IStructuredDocument doc = xmlModel.getStructuredDocument();
-//			//translator.translate();
-//			fHtmlMangledPageName = createClassname(xmlModel);
-//			fJsText = translator.getTranslation().toString();
-//			//fHtmlText = translator.getHtmlText();
-//			targetFile = getFile(xmlModel);
-//			fHtmlPageName = targetFile.getName();
-//			
-//			fDocumentScope = new DocumentContextFragmentRoot(fJavaProject, targetFile, WebRootFinder.getWebContentFolder(javaProj.getProject()), WebRootFinder.getServerContextRoot(javaProj.getProject()), JsWebNature.VIRTUAL_SCOPE_ENTRY);
-//			importRanges = translator.getImportHtmlRanges();
-//			cuImports = translator.getRawImports();
-//			locationsInHtml = translator.getHtmlLocations();
-//			//fHtmlDocument = translator.getStructuredDocument();
-//		}
-//		
+		setBaseLocation();
+		translator = new JsTranslator(htmlDocument, fModelBaseLocation);
+		mangledName = createMangledName();	
 	}	
 	
 	public IJavaProject getJavaProject() {
@@ -128,21 +99,22 @@
 		return fDocumentScope;
 	}
 	
-	private IDOMModel getModel() {
+	private void setBaseLocation() {
 		IDOMModel xmlModel=null;
 		try {
 			xmlModel = (IDOMModel) StructuredModelManager.getModelManager().getExistingModelForRead(fHtmlDocument);
 			if(xmlModel==null) {
 				xmlModel = (IDOMModel) StructuredModelManager.getModelManager().getModelForRead(fHtmlDocument);
 			}
+			fModelBaseLocation = xmlModel.getBaseLocation();
 		}finally {
 			if(xmlModel!=null) xmlModel.releaseFromRead();
 		}
-		return xmlModel;
+	//	return xmlModel;
 	}
 		
 	public IFile getFile() {
-			return FileBuffers.getWorkspaceFileAtLocation(new Path(getModel().getBaseLocation()));
+			return FileBuffers.getWorkspaceFileAtLocation(new Path(fModelBaseLocation));
 	}
 		
 	
@@ -182,41 +154,9 @@
 		if (buffer != null) {
 			translator.setBuffer(buffer);
 		}
-		//cu.makeConsistent(getProgressMonitor());
-		// cu.reconcile(ICompilationUnit.NO_AST, true, getWorkingCopyOwner(),
-		// getProgressMonitor());
-//		if (getHtmlPageName() == null || getMangledName() == null) {
-//			String cuName = cu.getPath().lastSegment();
-//			if (cuName != null) {
-//				//fHtmlMangledPageName = cuName.substring(0, cuName.lastIndexOf('.'));
-//				// set name of jsp file
-//				String unmangled = JsNameManglerUtil.unmangle(cuName);
-//				//fHtmlPageName = unmangled.substring(unmangled.lastIndexOf('/') + 1, unmangled.length());
-//			}
-//		}
-//		if (JsTranslation.DEBUG) {
-//			String cuText = cu.toString();
-//			System.out.println("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"); //$NON-NLS-1$
-//			System.out.println("(+) JSPTranslation [" + this + "] finished creating CompilationUnit: " + cu); //$NON-NLS-1$ //$NON-NLS-2$
-//			System.out.println("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"); //$NON-NLS-1$
-//			IPackageDeclaration[] ipd = cu.getPackageDeclarations();
-//			for (int i = 0; i < ipd.length; i++) {
-//				System.out.println("JSPTranslation.getCU() Package:" + ipd[i].getElementName());
-//			}
-//		}
 		return cu;
 	}
 	
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.eclipse.wst.jsdt.web.core.internal.java.JSPTranslation_Interface#fixupMangledName(java.lang.String)
-	 */
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.eclipse.wst.jsdt.web.core.internal.java.IJSPTranslation#fixupMangledName(java.lang.String)
-	 */
 	public String fixupMangledName(String displayString) {
 		if (displayString == null) {
 			return null;
@@ -224,12 +164,6 @@
 		return displayString.replaceAll(getMangledName() + ".js", getHtmlPageName());
 	}
 	
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.eclipse.wst.jsdt.web.core.internal.java.IJSPTranslation#getAllElementsInJsRange(int,
-	 *      int)
-	 */
 	public IJavaElement[] getAllElementsInJsRange(int javaPositionStart, int javaPositionEnd) {
 		IJavaElement[] EMTPY_RESULT_SET = new IJavaElement[0];
 		IJavaElement[] result = EMTPY_RESULT_SET;
@@ -258,16 +192,6 @@
 		return result;
 	}
 	
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.eclipse.wst.jsdt.web.core.internal.java.JSPTranslation_Interface#getCompilationUnit()
-	 */
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.eclipse.wst.jsdt.web.core.internal.java.IJSPTranslation#getCompilationUnit()
-	 */
 	public ICompilationUnit getCompilationUnit() {
 		synchronized (fLock) {
 			try {
@@ -275,7 +199,6 @@
 					fCompilationUnit = createCompilationUnit();
 					return fCompilationUnit;
 				}
-				// reconcileCompilationUnit();
 				
 			} catch (JavaModelException jme) {
 				if (JsTranslation.DEBUG) {
@@ -295,26 +218,11 @@
 		return fCompilationUnit;
 	}
 	
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.eclipse.wst.jsdt.web.core.internal.java.JSPTranslation_Interface#getElementsFromJspRange(int,
-	 *      int)
-	 */
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.eclipse.wst.jsdt.web.core.internal.java.IJSPTranslation#getElementsFromJsRange(int,
-	 *      int)
-	 */
 	public IJavaElement[] getElementsFromJsRange(int javaPositionStart, int javaPositionEnd) {
 		IJavaElement[] EMTPY_RESULT_SET = new IJavaElement[0];
 		IJavaElement[] result = EMTPY_RESULT_SET;
 		try {
 			ICompilationUnit cu = getCompilationUnit();
-			// cu.makeConsistent(getProgressMonitor());
-			// cu.reconcile(ICompilationUnit.NO_AST, true,
-			// getWorkingCopyOwner(), getProgressMonitor());
 			if (cu != null) {
 				synchronized (fLock) {
 					int cuDocLength = cu.getBuffer().getLength();
@@ -334,65 +242,24 @@
 	}
 	
 	private String getHtmlPageName() {
-		IPath path = new Path(getModel().getBaseLocation());
+		IPath path = new Path(fModelBaseLocation);
 		return path.lastSegment();
 		
 	}
-	
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.eclipse.wst.jsdt.web.core.internal.java.JSPTranslation_Interface#getJspText()
-	 */
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.eclipse.wst.jsdt.web.core.internal.java.IJSPTranslation#getHtmlText()
-	 */
+
 	public String getHtmlText() {
 		return fHtmlDocument.get();
 	}
 	
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.eclipse.wst.jsdt.web.core.internal.java.JSPTranslation_Interface#isUseBean(int)
-	 */
-	// public boolean isUseBean(int javaOffset) {
-	// System.out.println("REMOVE JSPTranslation.isUseBean(int javaOffset)");
-	// return false;
-	// }
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.eclipse.wst.jsdt.web.core.internal.java.JSPTranslation_Interface#getJavaPath()
-	 */
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.eclipse.wst.jsdt.web.core.internal.java.IJSPTranslation#getJavaPath()
-	 */
 	public String getJavaPath() {
 		String webRoot = getWebRoot() ;
 		IPackageFragmentRoot root = getDocScope(false);
 		String cuPath = root.getPath().append("/" + webRoot).append("/" + getMangledName() + JsDataTypes.BASE_FILE_EXTENSION ).toString();
-		// create if necessary
-		//ICompilationUnit cu = getCompilationUnit();
-		//String otherCuPath =  (cu != null) ? cu.getPath().toString() : ""; //$NON-NLS-1$
 		return cuPath;
 	}
 	
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.eclipse.wst.jsdt.web.core.internal.java.IJSPTranslation#getJsElementAtOffset(int)
-	 */
 	public IJavaElement getJsElementAtOffset(int jsOffset) {
 		IJavaElement elements = null;
-		// Position[] positions = getJavaRanges(htmlOffset, length);
-		//        
-		// ICompilationUnit cu = getCompilationUnit();
-		// synchronized (cu) {
 		try {
 			elements = getCompilationUnit().getElementAt(jsOffset);
 		} catch (JavaModelException e) {
@@ -420,8 +287,6 @@
 	}
 	
 	public String getJsText() {
-		// return (fTranslator != null) ?
-		// fTranslator.getTranslation().toString(): ""; //$NON-NLS-1$
 		return translator.getJsText();
 	}
 	
@@ -430,12 +295,7 @@
 	}
 	
 	private String createMangledName() {
-		String classname = ""; //$NON-NLS-1$
-		
-		String base = getModel().getBaseLocation();
-		classname = JsNameManglerUtil.mangle(base);
-		
-		return classname;
+		return JsNameManglerUtil.mangle(fModelBaseLocation);
 	}
 	
 	/**
@@ -447,26 +307,11 @@
 		return CompilationUnitHelper.getInstance().getProblemRequestor();
 	}
 	
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.eclipse.wst.jsdt.web.core.internal.java.JSPTranslation_Interface#getProblems()
-	 */
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.eclipse.wst.jsdt.web.core.internal.java.IJSPTranslation#getProblems()
-	 */
 	public List getProblems() {
 		List problems = getProblemRequestor().getCollectedProblems();
 		return problems != null ? problems : new ArrayList();
 	}
 	
-	/**
-	 * 
-	 * @return the progress monitor used in long operations (reconcile, creating
-	 *         the CompilationUnit...) in this JSPTranslation
-	 */
 	private IProgressMonitor getProgressMonitor() {
 		if (fProgressMonitor == null) {
 			fProgressMonitor = new NullProgressMonitor();
@@ -474,25 +319,10 @@
 		return fProgressMonitor;
 	}
 	
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.eclipse.wst.jsdt.web.core.internal.java.JSPTranslation_Interface#getWorkingCopyOwner()
-	 */
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.eclipse.wst.jsdt.web.core.internal.java.IJSPTranslation#getWorkingCopyOwner()
-	 */
 	public WorkingCopyOwner getWorkingCopyOwner() {
 		return CompilationUnitHelper.getInstance().getWorkingCopyOwner();
 	}
 	
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.eclipse.wst.jsdt.web.core.internal.java.IJSPTranslation#ifOffsetInImportNode(int)
-	 */
 	public boolean ifOffsetInImportNode(int offset) {
 		Position[] importRanges = translator.getImportHtmlRanges();
 		for (int i = 0; i < importRanges.length; i++) {
@@ -502,27 +332,7 @@
 		}
 		return false;
 	}
-	
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.eclipse.wst.jsdt.web.core.internal.java.IJSPTranslation#isOffsetInScriptNode(int)
-	 */
-//	public boolean isOffsetInScriptNode(int offset) {
-//		/* check import nodes */
-//		for (int i = 0; i < locationsInHtml.length; i++) {
-//			if (locationsInHtml[i].includes(offset)) {
-//				return true;
-//			}
-//		}
-//		return false;
-//	}
-	
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.eclipse.wst.jsdt.web.core.internal.java.IJSPTranslation#reconcileCompilationUnit()
-	 */
+
 	public void reconcileCompilationUnit() {
 		// if(true) return;
 		ICompilationUnit cu = getCompilationUnit();
@@ -542,17 +352,9 @@
 		}
 	}
 	
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.eclipse.wst.jsdt.web.core.internal.java.JSPTranslation_Interface#release()
-	 */
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.eclipse.wst.jsdt.web.core.internal.java.IJSPTranslation#release()
-	 */
+
 	public void release() {
+		if(translator!=null) translator.release();
 		synchronized (fLock) {
 			if (fCompilationUnit != null) {
 				try {
@@ -569,26 +371,13 @@
 		}
 	}
 	
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.eclipse.wst.jsdt.web.core.internal.java.JSPTranslation_Interface#setProblemCollectingActive(boolean)
-	 */
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.eclipse.wst.jsdt.web.core.internal.java.IJSPTranslation#setProblemCollectingActive(boolean)
-	 */
 	public void setProblemCollectingActive(boolean collect) {
 		ICompilationUnit cu = getCompilationUnit();
 		if (cu != null) {
 			getProblemRequestor().setIsActive(collect);
 		}
 	}
-
-	/* (non-Javadoc)
-	 * @see org.eclipse.core.resources.IResourceChangeListener#resourceChanged(org.eclipse.core.resources.IResourceChangeEvent)
-	 */
+	
 	public void classpathChange() {
 		
 		if(fDocumentScope!=null){
diff --git a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/JsTranslationAdapter.java b/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/JsTranslationAdapter.java
index 8a57631..74b7ebd 100644
--- a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/JsTranslationAdapter.java
+++ b/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/JsTranslationAdapter.java
@@ -25,6 +25,7 @@
 import org.eclipse.wst.jsdt.web.core.internal.Logger;
 import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter;
 import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
 import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
 
 /**
@@ -33,18 +34,16 @@
  * @author pavery
  */
 public class JsTranslationAdapter implements INodeAdapter, IResourceChangeListener {
-	// for debugging
+
 	private static final boolean DEBUG = "true".equalsIgnoreCase(Platform.getDebugOption("org.eclipse.wst.jsdt.web.core/debug/jsptranslation")); //$NON-NLS-1$  //$NON-NLS-2$
-	// private boolean fDocumentIsDirty = true;
-	private IDocument fJspDocument = null;
+	private IStructuredDocument fHtmlDocument = null;
 	private JsTranslation fJSPTranslation = null;
 	private NullProgressMonitor fTranslationMonitor = null;
-	// private JsTranslator fTranslator = null;
-	private IDOMModel fXMLModel;
+	private String baseLocation;
 	
 	public JsTranslationAdapter(IDOMModel xmlModel, boolean listenForProjectChanges) {
-		fXMLModel = xmlModel;
-		fJspDocument = fXMLModel.getStructuredDocument();
+		fHtmlDocument = xmlModel.getStructuredDocument();
+		baseLocation = xmlModel.getBaseLocation();
 		initializeJavaPlugins();
 		
 		if(listenForProjectChanges) {
@@ -55,27 +54,16 @@
 
 	public IJavaProject getJavaProject() {
 		IJavaProject javaProject = null;
-		try {
-			String baseLocation = fXMLModel.getBaseLocation();
-			// 20041129 (pa) the base location changed for XML model
-			// because of FileBuffers, so this code had to be updated
-			// https://bugs.eclipse.org/bugs/show_bug.cgi?id=79686
-			IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
-			IPath filePath = new Path(baseLocation);
-			IProject project = null;
-			if (filePath.segmentCount() > 0) {
-				project = root.getProject(filePath.segment(0));
-			}
-			if (project != null) {
-				javaProject = JavaCore.create(project);
-			}
-		} catch (Exception ex) {
-			if (fXMLModel != null) {
-				Logger.logException("(JSPTranslationAdapter) problem getting java project from the XMLModel's baseLocation > " + fXMLModel.getBaseLocation(), ex); //$NON-NLS-1$
-			} else {
-				Logger.logException("(JSPTranslationAdapter) problem getting java project", ex); //$NON-NLS-1$
-			}
+		IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+		IPath filePath = new Path(baseLocation);
+		IProject project = null;
+		if (filePath.segmentCount() > 0) {
+			project = root.getProject(filePath.segment(0));
 		}
+		if (project != null) {
+			javaProject = JavaCore.create(project);
+		}
+		
 		return javaProject;
 	}
 	
@@ -85,13 +73,9 @@
 	 * @return a JSPTranslationExtension
 	 */
 	public JsTranslation getJSPTranslation() {
-		synchronized (fXMLModel) {
-			if (fJSPTranslation == null) {
-				
-				fJSPTranslation = new JsTranslation(fXMLModel.getStructuredDocument(), getJavaProject());
-			}
+		if (fJSPTranslation == null) {
+			fJSPTranslation = new JsTranslation(fHtmlDocument, getJavaProject());
 		}
-		
 		return fJSPTranslation;
 	}
 	
diff --git a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/JsTranslator.java b/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/JsTranslator.java
index 1ebb482..49271d0 100644
--- a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/JsTranslator.java
+++ b/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/JsTranslator.java
@@ -52,18 +52,10 @@
 		String value = Platform.getDebugOption("org.eclipse.wst.jsdt.web.core/debug/jspjavamapping"); //$NON-NLS-1$
 		DEBUG = value != null && value.equalsIgnoreCase("true"); //$NON-NLS-1$
 	}
-	//private String fClassname;
+
 	private IStructuredDocumentRegion fCurrentNode;
-	/* map of ALL ranges */
-	/**
-	 * save JSP document text for later use may just want to read this from the
-	 * file or strucdtured document depending what is available
-	 */
-	//private StringBuffer fHtmlTextBuffer = new StringBuffer();
-	//private IProgressMonitor fProgressMonitor = null;
-	StringBuffer fScriptText = new StringBuffer();
+	private StringBuffer fScriptText = new StringBuffer();
 	private IStructuredDocument fStructuredDocument = null;
-	private IDOMModel fStructuredModel = null;
 	private ArrayList importLocationsInHtml = new ArrayList();
 	/* use java script by default */
 	private boolean isGlobalJs = true;
@@ -81,18 +73,14 @@
 		setCurrentNode(getCurrentNode().getNext());
 	}
 	
-	public JsTranslator(IDOMModel node) {
-		super("JavaScript translation for : "  + node.getBaseLocation());
-	
-		fStructuredModel = node;
-		fStructuredDocument = fStructuredModel.getStructuredDocument();
+	public JsTranslator(IStructuredDocument document, 	String fileName) {
+		super("JavaScript translation for : "  + fileName);
+		fStructuredDocument = document;
 		fStructuredDocument.addDocumentListener(this);
 		setPriority(Job.LONG);
 		setSystem(true);
 		schedule();
-		
 		reset();
-
 	}
 		
 	public String getJsText() {
@@ -224,6 +212,8 @@
 	}
 	
 	private void finishedTranslation() {
+		System.out.println("Updating CU Buffer..");
+		
 		if(compUnitBuff!=null) compUnitBuff.setContents(fScriptText.toString());
 	}
 	
@@ -378,6 +368,9 @@
 	
 		return Status.OK_STATUS;
 	}
-	public void finalize() {
+	
+	public void release() {
+		fStructuredDocument.removeDocumentListener(this);
 	}
+	
 }
\ No newline at end of file
diff --git a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/search/JsSearchDocument.java b/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/search/JsSearchDocument.java
index 9c17ef1..0096beb 100644
--- a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/search/JsSearchDocument.java
+++ b/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/search/JsSearchDocument.java
@@ -167,7 +167,12 @@
 		if (this.fCUPath == null || isDirty() || this.fCUPath == UNKNOWN_PATH) {
 			JsTranslation trans = getJSPTranslation();
 			if (trans != null) {
-				this.fCUPath = trans.getJavaPath();
+				try {
+					this.fCUPath = trans.getJavaPath();
+				} catch (RuntimeException ex) {
+					// TODO Auto-generated catch block
+					ex.printStackTrace();
+				}
 				// save since it's expensive to calculate again later
 				fCachedCharContents = trans.getJsText().toCharArray();
 			}
diff --git a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/search/JsSearchParticipant.java b/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/search/JsSearchParticipant.java
index fe064fa..a120dbb 100644
--- a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/search/JsSearchParticipant.java
+++ b/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/search/JsSearchParticipant.java
@@ -42,7 +42,7 @@
 	
 	
 	public String getDescription() {
-		return "JSP"; //$NON-NLS-1$
+		return "Embeded JavaScript"; //$NON-NLS-1$
 	}
 	
 	/**
diff --git a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/validation/JsBatchValidator.java b/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/validation/JsBatchValidator.java
index fb7b000..36c2c00 100644
--- a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/validation/JsBatchValidator.java
+++ b/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/validation/JsBatchValidator.java
@@ -30,6 +30,7 @@
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IConfigurationElement;
 import org.eclipse.core.runtime.IExecutableExtension;
+import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.NullProgressMonitor;
@@ -42,7 +43,12 @@
 import org.eclipse.core.runtime.jobs.ISchedulingRule;
 import org.eclipse.core.runtime.jobs.Job;
 import org.eclipse.osgi.util.NLS;
+import org.eclipse.wst.jsdt.core.IClasspathAttribute;
+import org.eclipse.wst.jsdt.core.IClasspathEntry;
+import org.eclipse.wst.jsdt.core.IJavaProject;
+import org.eclipse.wst.jsdt.core.IPackageFragmentRoot;
 import org.eclipse.wst.jsdt.core.JavaCore;
+import org.eclipse.wst.jsdt.core.JavaModelException;
 import org.eclipse.wst.jsdt.web.core.internal.JsCoreMessages;
 import org.eclipse.wst.jsdt.web.core.internal.Logger;
 import org.eclipse.wst.jsdt.web.core.internal.provisional.contenttype.ContentTypeIdForJSP;
@@ -196,6 +202,35 @@
 	public void cleanup(IReporter reporter) {
 		fJSPJavaValidator.cleanup(reporter);
 	}
+	private IPath[] getLibraryPaths(IFile file) {
+		IProject project = file.getProject();
+		IJavaProject javaProject= JavaCore.create(project);
+		
+		if(javaProject==null) return new IPath[0];
+		
+		IClasspathEntry[] entries = new IClasspathEntry[0];
+		try {
+			entries = javaProject.getResolvedClasspath(true);
+		} catch (JavaModelException ex) {
+			// TODO Auto-generated catch block
+			ex.printStackTrace();
+		}
+		ArrayList ignorePaths = new ArrayList();
+		nextEntry: for(int i = 0;i<entries.length;i++) {
+			if(entries[i].getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
+				IClasspathAttribute[] attribs = entries[i].getExtraAttributes();
+				for(int k=0; attribs!=null && k<attribs.length;k++) {
+					if(attribs[k].getName().equalsIgnoreCase("validate") && attribs[k].getName().equalsIgnoreCase("false")) {
+						ignorePaths.add(entries[k].getPath());
+						continue nextEntry;
+					}
+				}
+			}
+		}
+		
+		return (Path[])ignorePaths.toArray(new Path[ignorePaths.size()]);
+	}
+	
 	
 	void doValidate(IValidationContext helper, IReporter reporter) throws ValidationException {
 		reporter.removeAllMessages(this);
@@ -203,6 +238,10 @@
 		if (uris.length > 0) {
 			IWorkspaceRoot wsRoot = ResourcesPlugin.getWorkspace().getRoot();
 			IFile currentFile = null;
+			
+			
+			
+			
 			for (int i = 0; i < uris.length && !reporter.isCancelled(); i++) {
 				currentFile = wsRoot.getFile(new Path(uris[i]));
 				if (currentFile != null && currentFile.exists()) {
@@ -377,6 +416,14 @@
 	
 	private boolean shouldValidate(IFile file) {
 		IResource resource = file;
+		IPath[] libPaths = getLibraryPaths(file);
+		IPath filePath = file.getLocation().removeLastSegments(1);
+		for(int i = 0;i<libPaths.length;i++) {
+			if(libPaths[i].isPrefixOf(filePath)){
+				return false;
+			}
+		}
+		
 		do {
 			if (resource.isDerived() || resource.isTeamPrivateMember() || !resource.isAccessible() || resource.getName().charAt(0) == '.') {
 				return false;
diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/contentoutline/IJavaWebNode.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/contentoutline/IJavaWebNode.java
index b90966e..492b85d 100644
--- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/contentoutline/IJavaWebNode.java
+++ b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/contentoutline/IJavaWebNode.java
@@ -14,6 +14,8 @@
 	public IJavaElement getJavaElement();
 	
 	public Node getParentNode();
+		
+	public boolean hasChildren();
 	
-	public IJavaElement getDirtyElement();
+	
 }
diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/contentoutline/JFaceNodeAdapterForJs.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/contentoutline/JFaceNodeAdapterForJs.java
index 18b3fb5..d5eae0a 100644
--- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/contentoutline/JFaceNodeAdapterForJs.java
+++ b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/contentoutline/JFaceNodeAdapterForJs.java
@@ -2,6 +2,7 @@
 
 import java.util.Vector;
 
+import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.NullProgressMonitor;
 import org.eclipse.jface.text.Position;
 import org.eclipse.swt.graphics.Image;
@@ -38,13 +39,15 @@
 	}
 	
 	private ICompilationUnit lazyCu;
+	private IProgressMonitor monitor;
+	private JavaElementLabelProvider javaElementLabelProvider;
 	
 	public Object[] getChildren(Object object) {
 		if (object instanceof IJavaElement) {
 			return getJavaElementProvider().getChildren(object);
 		}
 		if (object instanceof IJavaWebNode) {
-			JavaElement enclosedElement = (JavaElement) ((IJavaWebNode) object).getDirtyElement();
+			JavaElement enclosedElement = (JavaElement) ((IJavaWebNode) object).getJavaElement();
 			if (enclosedElement != null) {
 				try {
 					IJavaElement[] children = enclosedElement.getChildren();
@@ -67,7 +70,7 @@
 		}
 		Node node = (Node) object;
 		if (isJSElementParent(node)) {
-			Object[] results = getJSElementsFromNode(node.getFirstChild());
+			Object[] results = getJSElementsFromNode(node.getFirstChild(), true);
 			
 			
 			return filter( results );
@@ -133,7 +136,10 @@
 	}
 	
 	private JavaElementLabelProvider getJavaElementLabelProvider() {
-		return new JavaElementLabelProvider();
+		if(javaElementLabelProvider==null) {
+			javaElementLabelProvider = new JavaElementLabelProvider();
+		}
+		return javaElementLabelProvider;
 	}
 	
 	private StandardJavaElementContentProvider getJavaElementProvider() {
@@ -179,7 +185,7 @@
 		return result;
 	}
 	
-	private synchronized Object[] getJSElementsFromNode(Node node) {
+	private synchronized Object[] getJSElementsFromNode(Node node, boolean ensureConsistant) {
 				
 		int startOffset = 0;
 		int endOffset = 0;
@@ -190,7 +196,12 @@
 			startOffset = ((NodeImpl) node).getStartOffset();
 			endOffset = ((NodeImpl) node).getEndOffset();
 			ICompilationUnit unit = getLazyCu(node);
-			
+			try {
+				if(ensureConsistant) unit.makeConsistent(getProgressMonitor());
+			} catch (JavaModelException ex1) {
+				// TODO Auto-generated catch block
+				ex1.printStackTrace();
+			}
 			try {
 				result = filterChildrenForRange(unit.getChildren(),node);
 			} catch (JavaModelException ex) {
@@ -205,6 +216,15 @@
 		return result;
 	}
 	
+	private IProgressMonitor getProgressMonitor() {
+		if(monitor==null) {
+			monitor = new NullProgressMonitor();
+		}
+		
+		return monitor;
+		
+	}
+	
 	private Object getJsNode(Node parent, IJavaElement root, Position position) {
 		JsJfaceNode instance = null;
 		if (root.getElementType() == IJavaElement.TYPE) {
@@ -215,6 +235,8 @@
 		} else {
 			instance = new JsJfaceNode(parent, root, position);
 		}
+		String name = getJavaElementLabelProvider().getText(root);
+		instance.setName(name);
 		// ((JsJfaceNode)instance).setAdapterRegistry(registry);
 		INodeAdapter adapter = (instance).getAdapterFor(IJFaceNodeAdapter.class);
 		if (!(adapter instanceof JFaceNodeAdapterForJs)) {
@@ -227,7 +249,7 @@
 	
 	public Image getLabelImage(Object node) {
 		if (node instanceof JsJfaceNode) {
-			return getJavaElementLabelProvider().getImage(((JsJfaceNode) node).getDirtyElement());
+			return ((JsJfaceNode) node).getImage();
 		}
 		if (node instanceof IJavaElement) {
 			return getJavaElementLabelProvider().getImage(node);
@@ -237,9 +259,9 @@
 	
 	
 	public String getLabelText(Object node) {
-		if (node instanceof JsJfaceNode) {
-			return getJavaElementLabelProvider().getText(((JsJfaceNode) node).getDirtyElement());
-		}
+//		if (node instanceof JsJfaceNode) {
+//			return ((JsJfaceNode) node).getName();
+//		}
 		if (node instanceof IJavaElement) {
 			return getJavaElementLabelProvider().getText(node);
 		}
@@ -301,16 +323,11 @@
 		}
 		Node node = (Node) object;
 		if (node instanceof IJavaWebNode) {
-			JavaElement enclosedElement = (JavaElement) ((IJavaWebNode) object).getDirtyElement();
-			if (enclosedElement != null) {
-				try {
-					return enclosedElement.hasChildren();
-				} catch (JavaModelException ex) {
-				}
-			}
+			return ((IJavaWebNode) object).hasChildren();
+			
 		}
 		if (isJSElementParent(node)) {
-			Object[] nodes = getJSElementsFromNode(node.getFirstChild());
+			Object[] nodes = getJSElementsFromNode(node.getFirstChild(),false);
 			boolean hasElements = (nodes != null && nodes.length > 0);
 			return hasElements;
 		}
diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/contentoutline/JsJfaceNode.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/contentoutline/JsJfaceNode.java
index 9103ae5..3a22899 100644
--- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/contentoutline/JsJfaceNode.java
+++ b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/contentoutline/JsJfaceNode.java
@@ -3,7 +3,12 @@
 import java.util.Collection;
 
 import org.eclipse.jface.text.Position;
+import org.eclipse.swt.graphics.Image;
 import org.eclipse.wst.jsdt.core.IJavaElement;
+import org.eclipse.wst.jsdt.core.JavaModelException;
+import org.eclipse.wst.jsdt.internal.core.JavaElement;
+import org.eclipse.wst.jsdt.internal.core.Openable;
+import org.eclipse.wst.jsdt.ui.JavaElementLabelProvider;
 import org.eclipse.wst.jsdt.web.core.internal.Logger;
 import org.eclipse.wst.jsdt.web.core.internal.java.IJsTranslation;
 import org.eclipse.wst.jsdt.web.core.internal.java.JsTranslation;
@@ -34,28 +39,52 @@
 	private JsAdaptableNode adaptableDomNode = new JsAdaptableNode();
 	private FactoryRegistry adapterRegistry;
 	private Position fDocPosition;
-	private Node parent;
+//	private Node parent;
 	private String typeName;
-	private IJavaElement dirtyElement;
+	//private IJavaElement dirtyElement;
+	private boolean hasChildren;
+	//private String name;
+	private Image me;
 	
 	public JsJfaceNode(Node parent, IJavaElement originalElement, Position structureDocLocation) {
 		this(parent, originalElement, structureDocLocation, null);
 	}
 	
 	public JsJfaceNode(Node parent, IJavaElement originalElement, Position structureDocLocation, String typeName) {
-		super();
-		// super((ElementImpl)parent);
+		//super();
+		super(((ElementImpl)parent));
 		// super(parentObject, parentObject.getElementName());
 		fDocPosition = structureDocLocation;
-		this.parent = parent;
+		//this.parent = parent;
 		this.typeName = typeName;
-		this.dirtyElement = originalElement;
+		try {
+			hasChildren=((JavaElement)originalElement).hasChildren();
+		} catch (JavaModelException ex) {
+			hasChildren=false;
+		}
+		removeAttributes();
+		me = (new JavaElementLabelProvider()).getImage(originalElement);
 	}
 	
-	public IJavaElement getDirtyElement() {
-		return this.dirtyElement;
+	public Image getImage() {
+		return me;
+	}
+
+	public boolean hasChildren() {
+//		try {
+//			return ((JavaElement)this.dirtyElement).hasChildren();
+//		} catch (JavaModelException ex) {
+//			// TODO Auto-generated catch block
+//			ex.printStackTrace();
+//		}
+		return hasChildren;
 	}
 	
+
+	public void setName(String name) {
+		super.setTagName(name);
+	}
+		
 	public void addAdapter(INodeAdapter adapter) {
 		adaptableDomNode.addAdapter(adapter);
 	}
@@ -69,7 +98,7 @@
 	
 	
 	public boolean equals(Object o) {
-		return (o != null && o instanceof JsJfaceNode && ((JsJfaceNode) o).parent == this.parent && ((JsJfaceNode) o).fDocPosition == this.fDocPosition);
+		return (o != null && o instanceof JsJfaceNode && ((JsJfaceNode) o).fDocPosition == this.fDocPosition);
 	}
 	
 // public static Object getInstance(Object parent, Position structureDocLocation
@@ -140,9 +169,6 @@
 	}
 	
 	
-	public short getNodeType() {
-		return parent.getNodeType();
-	}
 	
 	/*
 	 * (non-Javadoc)
@@ -150,14 +176,10 @@
 	 * @see org.eclipse.wst.xml.core.internal.document.NodeImpl#getOwnerDocument()
 	 */
 	
-	public Document getOwnerDocument() {
-		return parent.getOwnerDocument();
-	}
+
 	
 	
-	public Node getParentNode() {
-		return this.parent;
-	}
+
 	
 	
 	public int getStartOffset() {
@@ -202,9 +224,7 @@
 	 * @see org.eclipse.wst.xml.core.internal.document.NodeImpl#getStructuredDocument()
 	 */
 	
-	public IStructuredDocument getStructuredDocument() {
-		return ((NodeImpl) parent).getStructuredDocument();
-	}
+
 	
 	public JsTranslation getTranslation() {
 		IStructuredModel model = null;
@@ -212,7 +232,7 @@
 		IDOMDocument xmlDoc = null;
 		try {
 			if (modelManager != null) {
-				IStructuredDocument doc = ((NodeImpl) parent).getStructuredDocument();
+				IStructuredDocument doc = getStructuredDocument();
 				model = modelManager.getExistingModelForRead(doc);
 				// model = modelManager.getModelForRead(doc);
 			}