Author: scabanovich
Date: 2011-09-27 18:14:24 -0400 (Tue, 27 Sep 2011)
New Revision: 35089
Modified:
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/internal/ELValidatorContext.java
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/internal/LinkCollection.java
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/internal/ProjectValidationContext.java
Log:
JBIDE-9785
https://issues.jboss.org/browse/JBIDE-9785
KB model file storage is reduced.
Modified:
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/internal/ELValidatorContext.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/internal/ELValidatorContext.java 2011-09-27
22:06:37 UTC (rev 35088)
+++
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/internal/ELValidatorContext.java 2011-09-27
22:14:24 UTC (rev 35089)
@@ -168,8 +168,8 @@
* @see
org.jboss.tools.jst.web.kb.internal.validation.LinkCollection#store(org.w3c.dom.Element)
*/
@Override
- public synchronized void store(Element root) {
- super.store(root);
+ public synchronized void store(Element root, Map<String, String> pathIds) {
+ super.store(root, pathIds);
Set<String> variables = elsByVariableName.keySet();
for (String name: variables) {
Set<ELReference> els = elsByVariableName.get(name);
@@ -178,8 +178,8 @@
}
for (ELReference el: els) {
Element linkedEl = XMLUtilities.createElement(root, "linked-el");
//$NON-NLS-1$
- linkedEl.setAttribute("name", name); //$NON-NLS-1$
- el.store(linkedEl);
+ linkedEl.setAttribute("name", ELReference.getAlias(pathIds, name));
//$NON-NLS-1$
+ el.store(linkedEl, pathIds);
}
}
}
@@ -189,8 +189,8 @@
* @see
org.jboss.tools.jst.web.kb.internal.validation.LinkCollection#load(org.w3c.dom.Element)
*/
@Override
- public synchronized void load(Element root) {
- super.load(root);
+ public synchronized void load(Element root, Map<String, String> pathAliases) {
+ super.load(root, pathAliases);
if(root == null) {
return;
}
@@ -201,8 +201,9 @@
if(name == null || name.trim().length() == 0) {
continue;
}
+ name = ELReference.getPath(pathAliases, name);
ELReference el = new ValidationELReference();
- el.load(linkedEls[i]);
+ el.load(linkedEls[i], pathAliases);
el.setNeedToInitMarkers(true);
addLinkedEl(name, el);
}
Modified:
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/internal/LinkCollection.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/internal/LinkCollection.java 2011-09-27
22:06:37 UTC (rev 35088)
+++
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/internal/LinkCollection.java 2011-09-27
22:14:24 UTC (rev 35089)
@@ -17,6 +17,7 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
+import org.jboss.tools.common.el.core.ELReference;
import org.jboss.tools.common.validation.ValidationMessages;
import org.jboss.tools.common.xml.XMLUtilities;
import org.w3c.dom.Element;
@@ -255,23 +256,42 @@
* Store the collection to XML
* @param root
*/
- public synchronized void store(Element root) {
+ public synchronized void store(Element root, Map<String, String> pathAliases) {
Set<String> variables = resourcesByVariableName.keySet();
for (String name: variables) {
Set<IPath> paths = resourcesByVariableName.get(name);
if(paths == null) continue;
+ String nameAlias = ELReference.getAlias(pathAliases, name);
+ StringBuilder declarationFalsePaths = new StringBuilder();
+ StringBuilder declarationTruePaths = new StringBuilder();
for (IPath path: paths) {
- Element linkedResource = XMLUtilities.createElement(root,
"linked-resource"); //$NON-NLS-1$
- linkedResource.setAttribute("name", name); //$NON-NLS-1$
- linkedResource.setAttribute("path", path.toString()); //$NON-NLS-1$
+ String pathAlias = ELReference.getAlias(pathAliases, path.toString());
if(checkDeclaration(path, name)) {
- linkedResource.setAttribute("declaration", "true");
//$NON-NLS-1$ //$NON-NLS-2$
+ declarationTruePaths.append(pathAlias).append(";");
+ } else {
+ declarationFalsePaths.append(pathAlias).append(";");
}
}
+ if(declarationFalsePaths.length() > 0) {
+ Element linkedResource = XMLUtilities.createElement(root,
"linked-resource"); //$NON-NLS-1$
+ linkedResource.setAttribute("name", nameAlias); //$NON-NLS-1$
+ linkedResource.setAttribute("path", declarationFalsePaths.toString());
//$NON-NLS-1$
+ }
+ if(declarationTruePaths.length() > 0) {
+ Element linkedResource = XMLUtilities.createElement(root,
"linked-resource"); //$NON-NLS-1$
+ linkedResource.setAttribute("name", nameAlias); //$NON-NLS-1$
+ linkedResource.setAttribute("path", declarationTruePaths.toString());
//$NON-NLS-1$
+ linkedResource.setAttribute("declaration", "true"); //$NON-NLS-1$
//$NON-NLS-2$
+ }
}
+ StringBuilder unnamedPaths = new StringBuilder();
for (IPath unnamedPath: unnamedResources) {
+ String pathAlias = ELReference.getAlias(pathAliases, unnamedPath.toString());
+ unnamedPaths.append(pathAlias).append(";");
+ }
+ if(unnamedPaths.length() > 0) {
Element unnamedPathElement = XMLUtilities.createElement(root,
"unnamed-path"); //$NON-NLS-1$
- unnamedPathElement.setAttribute("path", unnamedPath.toString());
//$NON-NLS-1$
+ unnamedPathElement.setAttribute("path", ELReference.getAlias(pathAliases,
unnamedPaths.toString())); //$NON-NLS-1$
}
modifications = 0;
}
@@ -280,24 +300,33 @@
* Load the collection from XML
* @param root
*/
- public void load(Element root) {
+ public void load(Element root, Map<String, String> pathAliases) {
if(root == null) return;
Element[] linkedResources = XMLUtilities.getChildren(root,
"linked-resource"); //$NON-NLS-1$
if(linkedResources != null) for (int i = 0; i < linkedResources.length; i++) {
String name = linkedResources[i].getAttribute("name"); //$NON-NLS-1$
if(name == null || name.trim().length() == 0) continue;
- String path = linkedResources[i].getAttribute("path"); //$NON-NLS-1$
- if(path == null || path.trim().length() == 0) continue;
+ name = ELReference.getPath(pathAliases, name);
+ String path1 = linkedResources[i].getAttribute("path"); //$NON-NLS-1$
+ if(path1 == null || path1.trim().length() == 0) continue;
String declaration = linkedResources[i].getAttribute("declaration");
//$NON-NLS-1$
boolean declarationFlag = "true".equals(declaration); //$NON-NLS-1$
- IPath pathObject = new Path(path);
- addLinkedResource(name, pathObject, declarationFlag);
+ String[] paths = path1.split(";");
+ for (String path: paths) {
+ path = ELReference.getPath(pathAliases, path);
+ IPath pathObject = new Path(path);
+ addLinkedResource(name, pathObject, declarationFlag);
+ }
}
Element[] unnamedPathElement = XMLUtilities.getChildren(root,
"unnamed-path"); //$NON-NLS-1$
if(unnamedPathElement != null) for (int i = 0; i < unnamedPathElement.length; i++)
{
- String path = unnamedPathElement[i].getAttribute("path"); //$NON-NLS-1$
- IPath pathObject = new Path(path);
- addUnnamedResource(pathObject);
+ String path1 = unnamedPathElement[i].getAttribute("path"); //$NON-NLS-1$
+ String[] paths = path1.split(";");
+ for (String path: paths) {
+ path = ELReference.getPath(pathAliases, path);
+ IPath pathObject = new Path(path);
+ addUnnamedResource(pathObject);
+ }
}
modifications = 0;
}
Modified:
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/internal/ProjectValidationContext.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/internal/ProjectValidationContext.java 2011-09-27
22:06:37 UTC (rev 35088)
+++
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/internal/ProjectValidationContext.java 2011-09-27
22:14:24 UTC (rev 35089)
@@ -254,14 +254,23 @@
* @see
org.jboss.tools.jst.web.kb.validation.IValidationContext#store(org.w3c.dom.Element)
*/
public void store(Element root) {
+ Map<String, String> pathAliases = new HashMap<String, String>();
Element validation = XMLUtilities.createElement(root, "validation");
//$NON-NLS-1$
for (LinkCollection links : coreLinks.values()) {
Element core = XMLUtilities.createElement(validation, "core");
//$NON-NLS-1$
core.setAttribute("validator-id", links.getId()); //$NON-NLS-1$
- links.store(core);
+ links.store(core, pathAliases);
}
Element el = XMLUtilities.createElement(validation, "el"); //$NON-NLS-1$
- elLinks.store(el);
+ elLinks.store(el, pathAliases);
+
+ Element aliases = XMLUtilities.createElement(root, "aliases"); //$NON-NLS-1$
+ for (String path: pathAliases.keySet()) {
+ String value = pathAliases.get(path);
+ Element alias = XMLUtilities.createElement(aliases, "alias"); //$NON-NLS-1$
+ alias.setAttribute("path", path);
+ alias.setAttribute("value", value);
+ }
}
/*
@@ -269,18 +278,29 @@
* @see
org.jboss.tools.jst.web.kb.validation.IValidationContext#load(org.w3c.dom.Element)
*/
public void load(Element root) {
+ Map<String, String> pathAliases = new HashMap<String, String>();
+ Element aliases = XMLUtilities.getUniqueChild(root, "aliases");
//$NON-NLS-1$
+ if(aliases != null) {
+ Element[] aliasArray = XMLUtilities.getChildren(aliases, "alias");
//$NON-NLS-1$
+ for (Element alias: aliasArray) {
+ String path = alias.getAttribute("path");
+ String value = alias.getAttribute("value");
+ pathAliases.put(value, path);
+ }
+ }
+
Element validation = XMLUtilities.getUniqueChild(root, "validation");
//$NON-NLS-1$
if(validation == null) return;
Element[] cores = XMLUtilities.getChildren(validation, "core");
//$NON-NLS-1$
for (Element core : cores) {
String id = core.getAttribute("validator-id"); //$NON-NLS-1$
if(id!=null && id.trim().length()>0) {
- getCoreLinks(id).load(core);
+ getCoreLinks(id).load(core, pathAliases);
}
}
Element[] els = XMLUtilities.getChildren(validation, "el"); //$NON-NLS-1$
for (Element el : els) {
- elLinks.load(el);
+ elLinks.load(el, pathAliases);
}
}