Author: vrubezhny
Date: 2009-11-27 12:24:20 -0500 (Fri, 27 Nov 2009)
New Revision: 18893
Added:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/IXmlContext.java
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ELContext.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ELContextImpl.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/SimpleELContext.java
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/internal/JspContextImpl.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/XmlContextImpl.java
Log:
JBIDE-5119: Refactor PageContextFactory to improve perfomance of context creation
Context interfaces hierarchy is updated
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ELContext.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ELContext.java 2009-11-27
17:02:02 UTC (rev 18892)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ELContext.java 2009-11-27
17:24:20 UTC (rev 18893)
@@ -32,13 +32,6 @@
Var[] getVars();
/**
- * Returns "var" attributes which are available in particular offset.
- * @param offset
- * @return
- */
- Var[] getVars(int offset);
-
- /**
* Returns EL Resolvers which are declared for this resource
* @return
*/
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ELContextImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ELContextImpl.java 2009-11-27
17:02:02 UTC (rev 18892)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ELContextImpl.java 2009-11-27
17:24:20 UTC (rev 18893)
@@ -34,19 +34,6 @@
return allVars.toArray(new Var[allVars.size()]);
}
- /*
- * (non-Javadoc)
- */
- public Var[] getVars(int offset) {
- List<Var> result = new ArrayList<Var>();
- for (Region region : vars.keySet()) {
- if(offset>=region.getOffset() && offset<=region.getOffset() +
region.getLength()) {
- result.addAll(vars.get(region));
- }
- }
- return result.toArray(new Var[result.size()]);
- }
-
/**
* Adds new Var to the context
* @param region
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/SimpleELContext.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/SimpleELContext.java 2009-11-27
17:02:02 UTC (rev 18892)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/SimpleELContext.java 2009-11-27
17:24:20 UTC (rev 18893)
@@ -56,14 +56,6 @@
return vars.toArray(new Var[vars.size()]);
}
- /*
- * (non-Javadoc)
- * @see org.jboss.tools.common.el.core.resolver.ELContext#getVars(int)
- */
- public Var[] getVars(int i) {
- return getVars();
- }
-
/**
* @param vars
*/
Added:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/IXmlContext.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/IXmlContext.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/IXmlContext.java 2009-11-27
17:24:20 UTC (rev 18893)
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.jst.web.kb;
+
+import org.jboss.tools.common.el.core.resolver.ELContext;
+import org.jboss.tools.common.el.core.resolver.Var;
+
+/**
+ *
+ * @author Victor Rubezhny
+ *
+ */
+public interface IXmlContext extends ELContext {
+
+ /**
+ * Returns "var" attributes which are available in particular offset.
+ * @param offset
+ * @return
+ */
+ Var[] getVars(int offset);
+
+}
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/IXmlContext.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
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 2009-11-27
17:02:02 UTC (rev 18892)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/PageContextFactory.java 2009-11-27
17:24:20 UTC (rev 18893)
@@ -14,7 +14,6 @@
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collection;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/JspContextImpl.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/JspContextImpl.java 2009-11-27
17:02:02 UTC (rev 18892)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/JspContextImpl.java 2009-11-27
17:24:20 UTC (rev 18893)
@@ -20,6 +20,7 @@
import org.jboss.tools.jst.web.kb.IIncludedContextSupport;
import org.jboss.tools.jst.web.kb.IPageContext;
import org.jboss.tools.jst.web.kb.IResourceBundle;
+import org.jboss.tools.jst.web.kb.IXmlContext;
import org.jboss.tools.jst.web.kb.PageContextFactory.CSSStyleSheetDescriptor;
import org.jboss.tools.jst.web.kb.internal.taglib.NameSpace;
import org.jboss.tools.jst.web.kb.taglib.INameSpace;
@@ -95,7 +96,10 @@
List<ELContext> includedContexts = getIncludedContexts();
if (includedContexts != null) {
for (ELContext includedContext : includedContexts) {
- Var[] vars = includedContext.getVars(offset);
+ if (!(includedContext instanceof IXmlContext))
+ continue;
+
+ Var[] vars = ((IXmlContext)includedContext).getVars(offset);
if (vars != null) {
for (Var b : vars) {
includedVars.add(b);
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/XmlContextImpl.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/XmlContextImpl.java 2009-11-27
17:02:02 UTC (rev 18892)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/XmlContextImpl.java 2009-11-27
17:24:20 UTC (rev 18893)
@@ -10,15 +10,18 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.Region;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.part.FileEditorInput;
import org.eclipse.ui.texteditor.DocumentProviderRegistry;
import org.eclipse.ui.texteditor.IDocumentProvider;
import org.jboss.tools.common.el.core.resolver.ELContextImpl;
+import org.jboss.tools.common.el.core.resolver.Var;
+import org.jboss.tools.jst.web.kb.IXmlContext;
import org.jboss.tools.jst.web.kb.WebKbPlugin;
import org.jboss.tools.jst.web.kb.taglib.INameSpace;
-public class XmlContextImpl extends ELContextImpl {
+public class XmlContextImpl extends ELContextImpl implements IXmlContext {
protected IDocument document;
private FileEditorInput editorInput;
@@ -51,6 +54,21 @@
return document;
}
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.jst.web.kb.IXmlContext#getVars(int)
+ */
+ public Var[] getVars(int offset) {
+ List<Var> result = new ArrayList<Var>();
+ for (Region region : vars.keySet()) {
+ if(offset>=region.getOffset() && offset<=region.getOffset() +
region.getLength()) {
+ result.addAll(vars.get(region));
+ }
+ }
+ return result.toArray(new Var[result.size()]);
+ }
+
+
/*
* TODO: the visibility must differ between 'include'-like and
'template'-like inclusion
*
@@ -130,7 +148,7 @@
}
super.finalize();
}
-
+
private IDocument getConnectedDocument(IEditorInput input) {
IDocumentProvider provider=
DocumentProviderRegistry.getDefault().getDocumentProvider(input);
try {