summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaren Butzke2013-02-01 14:08:40 (EST)
committerKaren Butzke2013-02-01 14:08:40 (EST)
commit2c4a19212e4946be514a00b148761a0f23628e51 (patch)
tree2e8335d70d96ac3583d5f4e31f85553e98440dff
parent50c2b78ef67686c8c5fb8375ecf7b382615e0a84 (diff)
downloadwebtools.dali-2c4a19212e4946be514a00b148761a0f23628e51.zip
webtools.dali-2c4a19212e4946be514a00b148761a0f23628e51.tar.gz
webtools.dali-2c4a19212e4946be514a00b148761a0f23628e51.tar.bz2
Further refactored JpaStructureNode to add containsOffset(int) API. Removed this API from all sub-interfaces of JpaStructureNode
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/JpaStructureNode.java7
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/java/JavaPersistentAttribute.java8
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/orm/EntityMappings.java4
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/orm/OrmAttributeMapping.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/orm/OrmPersistentType.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/orm/OrmReadOnlyPersistentAttribute.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/orm/OrmTypeMapping.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/persistence/ClassRef.java6
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/persistence/JarFileRef.java7
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/persistence/MappingFileRef.java6
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/persistence/Persistence.java10
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/persistence/PersistenceUnit.java6
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaPersistentAttribute.java18
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaPersistentType.java10
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractEntityMappings.java38
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmAttributeMapping.java4
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmTypeMapping.java4
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/SpecifiedOrmPersistentAttribute.java4
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/SpecifiedOrmPersistentType.java14
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/VirtualOrmPersistentAttribute.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractJarFileRef.java8
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractPersistenceUnit.java62
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/GenericClassRef.java25
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/GenericOrmXmlRef.java6
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/GenericPersistence.java35
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/VirtualOrmXmlRef.java8
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/VirtualJavaPersistentAttribute.java7
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/VirtualJavaPersistentType.java4
28 files changed, 129 insertions, 182 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/JpaStructureNode.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/JpaStructureNode.java
index 8aa8ab3..d2b5a9d 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/JpaStructureNode.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/JpaStructureNode.java
@@ -31,6 +31,13 @@ import org.eclipse.jpt.jpa.core.context.JpaContextNode;
public interface JpaStructureNode
extends JpaContextNode
{
+
+ /**
+ * Return whether the text representation of this structure node contains
+ * the given text offset
+ */
+ boolean containsOffset(int textOffset);
+
/**
* Return the structure node at the specified offset in the structure node's
* corresponding text file.
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/java/JavaPersistentAttribute.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/java/JavaPersistentAttribute.java
index a9d7601..614164c 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/java/JavaPersistentAttribute.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/java/JavaPersistentAttribute.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2012 Oracle. All rights reserved.
+ * Copyright (c) 2006, 2013 Oracle. All rights reserved.
* This program and the accompanying materials are 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.
@@ -62,12 +62,6 @@ public interface JavaPersistentAttribute
*/
boolean isFor(JavaResourceMethod resourceGetter, JavaResourceMethod resourceSetter);
- /**
- * Return whether the attribute contains the given offset into its Java
- * source code file.
- */
- boolean contains(int offset);
-
// ********** type **********
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/orm/EntityMappings.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/orm/EntityMappings.java
index e74dd79..0ff0562 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/orm/EntityMappings.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/orm/EntityMappings.java
@@ -38,7 +38,7 @@ import org.eclipse.jpt.jpa.db.SchemaContainer;
* pioneering adopters on the understanding that any code that uses this API
* will almost certainly be broken (repeatedly) as the API evolves.
*
- * @version 3.0
+ * @version 3.3
* @since 2.0
*/
public interface EntityMappings
@@ -153,8 +153,6 @@ public interface EntityMappings
void changeMapping(OrmPersistentType ormPersistentType, OrmTypeMapping oldMapping, OrmTypeMapping newMapping);
- boolean containsOffset(int textOffset);
-
/**
* Return the Java resource type for the specified class name
* found in the JPA project. Prepend the default package name
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/orm/OrmAttributeMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/orm/OrmAttributeMapping.java
index 9a66f6a..f4a9095 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/orm/OrmAttributeMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/orm/OrmAttributeMapping.java
@@ -72,8 +72,6 @@ public interface OrmAttributeMapping
void removeXmlAttributeMappingFrom(Attributes resourceAttributes);
- boolean contains(int textOffset);
-
TextRange getSelectionTextRange();
TextRange getNameTextRange();
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/orm/OrmPersistentType.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/orm/OrmPersistentType.java
index af6f6cb..4d75cc6 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/orm/OrmPersistentType.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/orm/OrmPersistentType.java
@@ -134,8 +134,6 @@ public interface OrmPersistentType
// ********** misc **********
- boolean contains(int textOffset);
-
/**
* Return the Java persistent type that is referred to by the
* <code>orm.xml</code> persistent type.
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/orm/OrmReadOnlyPersistentAttribute.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/orm/OrmReadOnlyPersistentAttribute.java
index 1ddf5e1..33d6ba4 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/orm/OrmReadOnlyPersistentAttribute.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/orm/OrmReadOnlyPersistentAttribute.java
@@ -80,8 +80,6 @@ public interface OrmReadOnlyPersistentAttribute
boolean isFor(JavaResourceMethod javaResourceGetter, JavaResourceMethod javaResourceSetter);
- boolean contains(int textOffset);
-
// ********** virtual -> specified **********
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/orm/OrmTypeMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/orm/OrmTypeMapping.java
index e8750d3..cc9f464 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/orm/OrmTypeMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/orm/OrmTypeMapping.java
@@ -121,8 +121,6 @@ public interface OrmTypeMapping
TextRange getClassTextRange();
TextRange getAttributesTextRange();
-
- boolean containsOffset(int textOffset);
// ********** Java type mapping **********
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/persistence/ClassRef.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/persistence/ClassRef.java
index ab134f2..a46579c 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/persistence/ClassRef.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/persistence/ClassRef.java
@@ -56,12 +56,6 @@ public interface ClassRef
*/
XmlJavaClassRef getXmlClassRef();
- /**
- * Return whether the text representation of this persistence unit contains
- * the given text offset
- */
- boolean containsOffset(int textOffset);
-
// ********** class name **********
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/persistence/JarFileRef.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/persistence/JarFileRef.java
index b74ac23..3ba3845 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/persistence/JarFileRef.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/persistence/JarFileRef.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2012 Oracle. All rights reserved.
+ * Copyright (c) 2009, 2013 Oracle. All rights reserved.
* This program and the accompanying materials are 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.
@@ -90,9 +90,4 @@ public interface JarFileRef
XmlJarFileRef getXmlJarFileRef();
- /**
- * Return whether the text representation of the JAR file ref contains
- * the specified text offset.
- */
- boolean containsOffset(int textOffset);
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/persistence/MappingFileRef.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/persistence/MappingFileRef.java
index 0321465..7a21eed 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/persistence/MappingFileRef.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/persistence/MappingFileRef.java
@@ -119,12 +119,6 @@ public interface MappingFileRef
boolean isDefault();
/**
- * Return whether the specified text offset is within
- * the text representation of the mapping file.
- */
- boolean containsOffset(int textOffset);
-
- /**
* @see MappingFile#getMappingFileQueries()
*/
Iterable<Query> getMappingFileQueries();
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/persistence/Persistence.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/persistence/Persistence.java
index 892c954..99b74a3 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/persistence/Persistence.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/persistence/Persistence.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2011 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2013 Oracle. All rights reserved.
* This program and the accompanying materials are 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.
@@ -85,12 +85,4 @@ public interface Persistence
*/
void removePersistenceUnit(int index);
-
- // ********** text range **********
-
- /**
- * Return whether the text representation of this persistence contains
- * the specified text offset.
- */
- boolean containsOffset(int textOffset);
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/persistence/PersistenceUnit.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/persistence/PersistenceUnit.java
index 09ca0ce..0d275bc 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/persistence/PersistenceUnit.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/persistence/PersistenceUnit.java
@@ -762,12 +762,6 @@ public interface PersistenceUnit
Embeddable getEmbeddable(String typeName);
/**
- * Return whether the text representation of this persistence unit contains
- * the given text offset
- */
- boolean containsOffset(int textOffset);
-
- /**
* Synchronize the persistence unit's list of specified classes with the
* types in the project currently annotated.
*/
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaPersistentAttribute.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaPersistentAttribute.java
index 0295be5..180113f 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaPersistentAttribute.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaPersistentAttribute.java
@@ -461,6 +461,15 @@ public abstract class AbstractJavaPersistentAttribute
return 0;
}
+ public boolean containsOffset(int offset) {
+ TextRange fullTextRange = this.getResourceAttribute().getTextRange();
+ // 'fullTextRange' will be null if the attribute no longer exists in the java;
+ // the context model can be out of sync with the resource model
+ // when a selection event occurs before the context model has a
+ // chance to sync with the resource model via the update thread
+ return (fullTextRange == null) ? false : fullTextRange.includes(offset);
+ }
+
public JpaStructureNode getStructureNode(int textOffset) {
return this;
}
@@ -612,15 +621,6 @@ public abstract class AbstractJavaPersistentAttribute
}
return null;
}
-
- public boolean contains(int offset) {
- TextRange fullTextRange = this.getResourceAttribute().getTextRange();
- // 'fullTextRange' will be null if the attribute no longer exists in the java;
- // the context model can be out of sync with the resource model
- // when a selection event occurs before the context model has a
- // chance to sync with the resource model via the update thread
- return (fullTextRange == null) ? false : fullTextRange.includes(offset);
- }
@Override
public void toString(StringBuilder sb) {
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaPersistentType.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaPersistentType.java
index 8e9329c..3020014 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaPersistentType.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaPersistentType.java
@@ -946,10 +946,10 @@ public abstract class AbstractJavaPersistentType
*/
public JpaStructureNode getStructureNode(int offset) {
this.resourceType.getJavaResourceCompilationUnit().synchronizeWithJavaSourceIfNecessary(); //TODO this new API? or just check isConsistent() right here?
- if (this.contains(offset)) {
- for (JavaPersistentAttribute persistentAttribute : this.getAttributes()) {
- if (persistentAttribute.contains(offset)) {
- return persistentAttribute;
+ if (this.containsOffset(offset)) {
+ for (JpaStructureNode child : this.getChildren()) {
+ if (child.containsOffset(offset)) {
+ return child;
}
}
return this;
@@ -957,7 +957,7 @@ public abstract class AbstractJavaPersistentType
return null;
}
- protected boolean contains(int offset) {
+ public boolean containsOffset(int offset) {
TextRange fullTextRange = this.resourceType.getTextRange();
// 'fullTextRange' will be null if the type no longer exists in the java;
// the context model can be out of sync with the resource model
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractEntityMappings.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractEntityMappings.java
index 682350d..4050dcb 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractEntityMappings.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractEntityMappings.java
@@ -217,25 +217,10 @@ public abstract class AbstractEntityMappings
return EntityMappings.class;
}
- public JpaStructureNode getStructureNode(int textOffset) {
- for (OrmPersistentType persistentType: this.getPersistentTypes()) {
- if (persistentType.contains(textOffset)) {
- return persistentType.getStructureNode(textOffset);
- }
- }
- return this;
- }
-
public TextRange getSelectionTextRange() {
return this.xmlEntityMappings.getSelectionTextRange();
}
- public void dispose() {
- for (OrmPersistentType ormPersistentType : this.getPersistentTypes()) {
- ormPersistentType.dispose();
- }
- }
-
//TODO I think children needs to include all managed types,
//thus JPA 2.1 converters are going to appear in the structure and project explorer views??
protected void initializeChildren() {
@@ -254,6 +239,25 @@ public abstract class AbstractEntityMappings
return this.children.size();
}
+ public boolean containsOffset(int textOffset) {
+ return (this.xmlEntityMappings != null) && this.xmlEntityMappings.containsOffset(textOffset);
+ }
+
+ public JpaStructureNode getStructureNode(int textOffset) {
+ for (JpaStructureNode child : this.getChildren()) {
+ if (child.containsOffset(textOffset)) {
+ return child.getStructureNode(textOffset);
+ }
+ }
+ return this;
+ }
+
+ public void dispose() {
+ for (JpaStructureNode child : this.getChildren()) {
+ child.dispose();
+ }
+ }
+
// ********** PersistentType.Owner implementation **********
@@ -315,10 +319,6 @@ public abstract class AbstractEntityMappings
return (textRange != null) ? textRange : this.getOrmXml().getValidationTextRange();
}
- public boolean containsOffset(int textOffset) {
- return (this.xmlEntityMappings != null) && this.xmlEntityMappings.containsOffset(textOffset);
- }
-
// ********** description **********
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmAttributeMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmAttributeMapping.java
index d5a4f91..e73e524 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmAttributeMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmAttributeMapping.java
@@ -321,10 +321,6 @@ public abstract class AbstractOrmAttributeMapping<X extends XmlAttributeMapping>
return this.getTypeMapping().validatesAgainstDatabase();
}
- public boolean contains(int textOffset) {
- return this.xmlAttributeMapping.containsOffset(textOffset);
- }
-
public TextRange getSelectionTextRange() {
return this.xmlAttributeMapping.getSelectionTextRange();
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmTypeMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmTypeMapping.java
index ae37511..e74c68b 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmTypeMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmTypeMapping.java
@@ -471,10 +471,6 @@ public abstract class AbstractOrmTypeMapping<X extends XmlTypeMapping>
public TextRange getNameTextRange() {
return this.getValidationTextRange(this.xmlTypeMapping.getNameTextRange());
}
-
- public boolean containsOffset(int textOffset) {
- return this.xmlTypeMapping.containsOffset(textOffset);
- }
// ********** refactoring **********
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/SpecifiedOrmPersistentAttribute.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/SpecifiedOrmPersistentAttribute.java
index 7122be0..9975a83 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/SpecifiedOrmPersistentAttribute.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/SpecifiedOrmPersistentAttribute.java
@@ -458,8 +458,8 @@ public abstract class SpecifiedOrmPersistentAttribute
return this;
}
- public boolean contains(int textOffset) {
- return this.mapping.contains(textOffset);
+ public boolean containsOffset(int textOffset) {
+ return this.getXmlAttributeMapping().containsOffset(textOffset);
}
public TextRange getSelectionTextRange() {
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/SpecifiedOrmPersistentType.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/SpecifiedOrmPersistentType.java
index 68dc2b7..91d6338 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/SpecifiedOrmPersistentType.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/SpecifiedOrmPersistentType.java
@@ -1132,10 +1132,14 @@ public abstract class SpecifiedOrmPersistentType
return this.children.size();
}
+ public boolean containsOffset(int textOffset) {
+ return this.getXmlTypeMapping().containsOffset(textOffset);
+ }
+
public JpaStructureNode getStructureNode(int textOffset) {
- for (OrmPersistentAttribute attribute : this.getSpecifiedAttributes()) {
- if (attribute.contains(textOffset)) {
- return attribute;
+ for (JpaStructureNode child : this.getChildren()) {
+ if (child.containsOffset(textOffset)) {
+ return child;
}
}
return this;
@@ -1344,10 +1348,6 @@ public abstract class SpecifiedOrmPersistentType
return (lastPeriod == -1) ? this.getDefaultPackage() : className.substring(0, lastPeriod);
}
- public boolean contains(int textOffset) {
- return this.mapping.containsOffset(textOffset);
- }
-
public PersistentType getOverriddenPersistentType() {
return this.mapping.isMetadataComplete() ? null : this.javaPersistentType;
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/VirtualOrmPersistentAttribute.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/VirtualOrmPersistentAttribute.java
index 371f655..5ca0445 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/VirtualOrmPersistentAttribute.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/VirtualOrmPersistentAttribute.java
@@ -312,7 +312,7 @@ public class VirtualOrmPersistentAttribute
return this;
}
- public boolean contains(int textOffset) {
+ public boolean containsOffset(int textOffset) {
return false;
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractJarFileRef.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractJarFileRef.java
index 02ab666..ccb9b42 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractJarFileRef.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractJarFileRef.java
@@ -107,6 +107,10 @@ public abstract class AbstractJarFileRef
return 0;
}
+ public boolean containsOffset(int textOffset) {
+ return (this.xmlJarFileRef != null) && this.xmlJarFileRef.containsOffset(textOffset);
+ }
+
public JpaStructureNode getStructureNode(int textOffset) {
return this;
}
@@ -304,10 +308,6 @@ public abstract class AbstractJarFileRef
return (this.jarFile == null) ? null : this.jarFile.getPersistentType(typeName);
}
- public boolean containsOffset(int textOffset) {
- return (this.xmlJarFileRef != null) && this.xmlJarFileRef.containsOffset(textOffset);
- }
-
// ********** PersistentTypeContainer implementation **********
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractPersistenceUnit.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractPersistenceUnit.java
index bc46995..e6f1974 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractPersistenceUnit.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractPersistenceUnit.java
@@ -347,18 +347,6 @@ public abstract class AbstractPersistenceUnit
return this.xmlPersistenceUnit.getSelectionTextRange();
}
- public void dispose() {
- for (ClassRef classRef : this.getClassRefs()) {
- classRef.dispose();
- }
- for (JarFileRef jarFileRef : this.getJarFileRefs()) {
- jarFileRef.dispose();
- }
- for (MappingFileRef mappingFileRef : this.getMappingFileRefs()) {
- mappingFileRef.dispose();
- }
- }
-
protected void initializeChildren() {
CollectionTools.addAll(this.children, this.getMappingFileRefs());
CollectionTools.addAll(this.children, this.getSpecifiedClassRefs());
@@ -386,6 +374,33 @@ public abstract class AbstractPersistenceUnit
return this.children.size();
}
+ public boolean containsOffset(int textOffset) {
+ return (this.xmlPersistenceUnit != null) && this.xmlPersistenceUnit.containsOffset(textOffset);
+ }
+
+ public JpaStructureNode getStructureNode(int textOffset) {
+ for (JpaStructureNode child : this.getChildren()) {
+ if (child.containsOffset(textOffset)) {
+ return child;
+ }
+ }
+ return this;
+ }
+
+ public void dispose() {
+ //I assume we also need to dispose implied class refs, so I am not using the getChildren() api
+ //right now since that currently only builds specified class refs.
+ for (ClassRef classRef : this.getClassRefs()) {
+ classRef.dispose();
+ }
+ for (JarFileRef jarFileRef : this.getJarFileRefs()) {
+ jarFileRef.dispose();
+ }
+ for (MappingFileRef mappingFileRef : this.getMappingFileRefs()) {
+ mappingFileRef.dispose();
+ }
+ }
+
// ********** name **********
@@ -2098,29 +2113,6 @@ public abstract class AbstractPersistenceUnit
return this.xmlPersistenceUnit;
}
- public JpaStructureNode getStructureNode(int textOffset) {
- for (JarFileRef jarFileRef : this.getJarFileRefs()) {
- if (jarFileRef.containsOffset(textOffset)) {
- return jarFileRef;
- }
- }
- for (MappingFileRef mappingFileRef : this.getMappingFileRefs()) {
- if (mappingFileRef.containsOffset(textOffset)) {
- return mappingFileRef;
- }
- }
- for (ClassRef classRef : this.getClassRefs()) {
- if (classRef.containsOffset(textOffset)) {
- return classRef;
- }
- }
- return this;
- }
-
- public boolean containsOffset(int textOffset) {
- return (this.xmlPersistenceUnit != null) && this.xmlPersistenceUnit.containsOffset(textOffset);
- }
-
protected HashSet<String> convertToNames(Collection<? extends JpaNamedContextNode> nodes) {
HashSet<String> names = new HashSet<String>(nodes.size());
for (JpaNamedContextNode node : nodes) {
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/GenericClassRef.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/GenericClassRef.java
index 4fd02b9..c256206 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/GenericClassRef.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/GenericClassRef.java
@@ -127,15 +127,6 @@ public class GenericClassRef
}
}
- public Iterable<JpaStructureNode> getChildren() {
- return EmptyIterable.instance();
- }
-
- public int getChildrenSize() {
- return 0;
- }
-
-
// ********** class name **********
@@ -250,10 +241,6 @@ public class GenericClassRef
return ! this.isVirtual();
}
- public boolean containsOffset(int textOffset) {
- return this.isNotVirtual() && this.xmlJavaClassRef.containsOffset(textOffset);
- }
-
@Override
public void toString(StringBuilder sb) {
sb.append(this.getJavaClassName());
@@ -270,6 +257,18 @@ public class GenericClassRef
return ClassRef.class;
}
+ public Iterable<JpaStructureNode> getChildren() {
+ return EmptyIterable.instance();
+ }
+
+ public int getChildrenSize() {
+ return 0;
+ }
+
+ public boolean containsOffset(int textOffset) {
+ return this.isNotVirtual() && this.xmlJavaClassRef.containsOffset(textOffset);
+ }
+
public JpaStructureNode getStructureNode(int textOffset) {
return this;
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/GenericOrmXmlRef.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/GenericOrmXmlRef.java
index 63b6571..dab8ca6 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/GenericOrmXmlRef.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/GenericOrmXmlRef.java
@@ -79,13 +79,13 @@ public class GenericOrmXmlRef
return false;
}
+
+ // ********** JpaStructureNode implementation **********
+
public boolean containsOffset(int textOffset) {
return this.xmlMappingFileRef.containsOffset(textOffset);
}
-
- // ********** JpaStructureNode implementation **********
-
public TextRange getSelectionTextRange() {
return this.xmlMappingFileRef.getFileNameTextRange();
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/GenericPersistence.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/GenericPersistence.java
index 4f896e6..59a8029 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/GenericPersistence.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/GenericPersistence.java
@@ -16,6 +16,7 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jpt.common.core.utility.TextRange;
+import org.eclipse.jpt.common.utility.internal.collection.CollectionTools;
import org.eclipse.jpt.common.utility.internal.iterable.EmptyListIterable;
import org.eclipse.jpt.common.utility.internal.iterable.IterableTools;
import org.eclipse.jpt.common.utility.internal.iterable.SingleElementListIterable;
@@ -222,10 +223,6 @@ public class GenericPersistence
return this.xmlPersistence;
}
- public boolean containsOffset(int textOffset) {
- return (this.xmlPersistence == null) ? false : this.xmlPersistence.containsOffset(textOffset);
- }
-
// ********** XmlContextNode implementation **********
@@ -254,27 +251,25 @@ public class GenericPersistence
return Persistence.class;
}
- public JpaStructureNode getStructureNode(int textOffset) {
- for (PersistenceUnit pu : this.getPersistenceUnits()) {
- if (pu.containsOffset(textOffset)) {
- return pu.getStructureNode(textOffset);
- }
- }
- return this;
- }
-
public TextRange getSelectionTextRange() {
return this.xmlPersistence.getSelectionTextRange();
}
- public void dispose() {
- for (PersistenceUnit pu : this.getPersistenceUnits()) {
- pu.dispose();
+ public boolean containsOffset(int textOffset) {
+ return (this.xmlPersistence == null) ? false : this.xmlPersistence.containsOffset(textOffset);
+ }
+
+ public JpaStructureNode getStructureNode(int textOffset) {
+ for (JpaStructureNode child : this.getChildren()) {
+ if (child.containsOffset(textOffset)) {
+ return child.getStructureNode(textOffset);
+ }
}
+ return this;
}
protected void initializeChildren() {
- this.children.add(this.persistenceUnit);
+ CollectionTools.addAll(this.children, this.getPersistenceUnits());
}
protected void updateChildren() {
@@ -289,6 +284,12 @@ public class GenericPersistence
return this.children.size();
}
+ public void dispose() {
+ for (JpaStructureNode child : this.getChildren()) {
+ child.dispose();
+ }
+ }
+
// ********** validation **********
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/VirtualOrmXmlRef.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/VirtualOrmXmlRef.java
index 76103f3..ebb26f3 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/VirtualOrmXmlRef.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/VirtualOrmXmlRef.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2013 Oracle. All rights reserved.
* This program and the accompanying materials are 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.
@@ -50,13 +50,13 @@ public class VirtualOrmXmlRef
throw new UnsupportedOperationException("Cannot set an implied mapping file ref's 'fileName': " + fileName); //$NON-NLS-1$
}
+
+ // ********** JpaStructureNode implementation **********
+
public boolean containsOffset(int textOffset) {
return false;
}
-
- // ********** JpaStructureNode implementation **********
-
public TextRange getSelectionTextRange() {
return null;
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/VirtualJavaPersistentAttribute.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/VirtualJavaPersistentAttribute.java
index 0cf0552..5c387d2 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/VirtualJavaPersistentAttribute.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/VirtualJavaPersistentAttribute.java
@@ -95,10 +95,6 @@ public class VirtualJavaPersistentAttribute
return false;
}
- public boolean contains(int offset) {
- throw new UnsupportedOperationException();
- }
-
public String getTypeName() {
String typeName = this.xmlAttributeMapping.getAttributeType();
return typeName == null ? null : this.getEntityMappings().getFullyQualifiedName(typeName);
@@ -148,6 +144,9 @@ public class VirtualJavaPersistentAttribute
// ********** JpaStructureNode implementation **********
+ public boolean containsOffset(int offset) {
+ throw new UnsupportedOperationException();
+ }
public JpaStructureNode getStructureNode(int textOffset) {
throw new UnsupportedOperationException("There is no resource for a virtual java persistent attribute"); //$NON-NLS-1$
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/VirtualJavaPersistentType.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/VirtualJavaPersistentType.java
index 69a4979..0eaa5cd 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/VirtualJavaPersistentType.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/VirtualJavaPersistentType.java
@@ -278,6 +278,10 @@ public class VirtualJavaPersistentType
throw new UnsupportedOperationException("There is no resource for a virtual java persistent type"); //$NON-NLS-1$
}
+ public boolean containsOffset(int textOffset) {
+ throw new UnsupportedOperationException("There is no resource for a virtual java persistent type"); //$NON-NLS-1$
+ }
+
public JpaStructureNode getStructureNode(int textOffset) {
throw new UnsupportedOperationException("There is no resource for a virtual java persistent type"); //$NON-NLS-1$
}