Author: dgeraskov
Date: 2011-03-04 09:37:05 -0500 (Fri, 04 Mar 2011)
New Revision: 29510
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaBasicMapping.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaBasicMappingImpl.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/TypeImpl.java
Log:
https://issues.jboss.org/browse/JBIDE-8512
Added Type completion proposals and TypeDefContainer support to BasicMapping
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaBasicMapping.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaBasicMapping.java 2011-03-04
09:54:54 UTC (rev 29509)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaBasicMapping.java 2011-03-04
14:37:05 UTC (rev 29510)
@@ -22,4 +22,6 @@
*/
public interface HibernateJavaBasicMapping extends JavaBasicMapping, Generated,
IndexHolder, TypeHolder {
+ HibernateJavaTypeDefContainer getTypeDefContainer();
+
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaBasicMappingImpl.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaBasicMappingImpl.java 2011-03-04
09:54:54 UTC (rev 29509)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaBasicMappingImpl.java 2011-03-04
14:37:05 UTC (rev 29510)
@@ -11,12 +11,14 @@
package org.jboss.tools.hibernate.jpt.core.internal.context.java;
+import java.util.Iterator;
import java.util.List;
import java.util.Vector;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
import org.eclipse.jpt.core.internal.context.java.AbstractJavaBasicMapping;
+import org.eclipse.jpt.utility.Filter;
import org.eclipse.wst.validation.internal.provisional.core.IMessage;
import org.eclipse.wst.validation.internal.provisional.core.IReporter;
import org.jboss.tools.hibernate.jpt.core.internal.HibernateAbstractJpaFactory;
@@ -34,6 +36,8 @@
public class HibernateJavaBasicMappingImpl extends AbstractJavaBasicMapping
implements HibernateJavaBasicMapping {
+ protected final HibernateJavaTypeDefContainer typeDefContainer;
+
protected GenerationTime specifiedGenerationTime;
protected JavaIndex index;
@@ -42,6 +46,7 @@
public HibernateJavaBasicMappingImpl(JavaPersistentAttribute parent) {
super(parent);
+ this.typeDefContainer = getJpaFactory().buildJavaTypeDefContainer(parent);
}
@Override
@@ -59,6 +64,7 @@
@Override
protected void initialize() {
super.initialize();
+ this.typeDefContainer.initialize(this.getResourcePersistentAttribute());
this.specifiedGenerationTime = this.getResourceGenerationTime();
this.initializeIndex();
this.initializeType();
@@ -67,11 +73,16 @@
@Override
protected void update() {
super.update();
+ this.typeDefContainer.update(this.getResourcePersistentAttribute());
this.setGenerationTime_(this.getResourceGenerationTime());
this.updateIndex();
this.updateType();
}
+ public HibernateJavaTypeDefContainer getTypeDefContainer() {
+ return this.typeDefContainer;
+ }
+
public GeneratedAnnotation getResourceGenerated() {
return (GeneratedAnnotation)
getResourcePersistentAttribute().getAnnotation(GeneratedAnnotation.ANNOTATION_NAME);
}
@@ -250,14 +261,51 @@
protected TypeAnnotation getTypeResource() {
return (TypeAnnotation)
this.getResourcePersistentAttribute().getAnnotation(TypeAnnotation.ANNOTATION_NAME);
}
-
- /* (non-Javadoc)
- * @see
org.eclipse.jpt.core.internal.context.java.AbstractJavaBasicMapping#validate(java.util.List,
org.eclipse.wst.validation.internal.provisional.core.IReporter,
org.eclipse.jdt.core.dom.CompilationUnit)
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jpt.core.internal.context.java.AbstractJavaBasicMapping#
+ * javaCompletionProposals(int, org.eclipse.jpt.utility.Filter,
+ * org.eclipse.jdt.core.dom.CompilationUnit)
*/
@Override
+ public Iterator<String> javaCompletionProposals(int pos,
+ Filter<String> filter, CompilationUnit astRoot) {
+ Iterator<String> result = super.javaCompletionProposals(pos, filter,
+ astRoot);
+ if (result != null) {
+ return result;
+ }
+ result = this.getTypeDefContainer().javaCompletionProposals(pos,
+ filter, astRoot);
+ if (result != null) {
+ return result;
+ }
+ if (this.getType() != null) {
+ result = this.getType().javaCompletionProposals(pos, filter,
+ astRoot);
+ if (result != null) {
+ return result;
+ }
+ }
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.jpt.core.internal.context.java.AbstractJavaBasicMapping#validate
+ * (java.util.List,
+ * org.eclipse.wst.validation.internal.provisional.core.IReporter,
+ * org.eclipse.jdt.core.dom.CompilationUnit)
+ */
+ @Override
public void validate(List<IMessage> messages, IReporter reporter,
CompilationUnit astRoot) {
super.validate(messages, reporter, astRoot);
+ this.typeDefContainer.validate(messages, reporter, astRoot);
if (this.index != null){
this.index.validate(messages, reporter, astRoot);
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/TypeImpl.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/TypeImpl.java 2011-03-04
09:54:54 UTC (rev 29509)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/TypeImpl.java 2011-03-04
14:37:05 UTC (rev 29510)
@@ -10,6 +10,8 @@
******************************************************************************/
package org.jboss.tools.hibernate.jpt.core.internal.context.java;
+import java.util.Arrays;
+import java.util.Iterator;
import java.util.List;
import org.eclipse.jdt.core.IType;
@@ -18,6 +20,9 @@
import org.eclipse.jpt.core.context.java.JavaJpaContextNode;
import org.eclipse.jpt.core.internal.context.java.AbstractJavaJpaContextNode;
import org.eclipse.jpt.core.utility.TextRange;
+import org.eclipse.jpt.utility.Filter;
+import org.eclipse.jpt.utility.internal.StringTools;
+import org.eclipse.jpt.utility.internal.iterables.FilteringIterable;
import org.eclipse.wst.validation.internal.provisional.core.IMessage;
import org.eclipse.wst.validation.internal.provisional.core.IReporter;
import org.jboss.tools.hibernate.jpt.core.internal.context.HibernatePersistenceUnit;
@@ -83,6 +88,7 @@
validateType(messages, reporter, astRoot);
}
+ @Override
public HibernatePersistenceUnit getPersistenceUnit() {
return (HibernatePersistenceUnit) this.getParent().getPersistenceUnit();
}
@@ -91,6 +97,40 @@
return this.typeResource.getTypeTextRange(astRoot);
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.jpt.core.internal.context.java.AbstractJavaJpaContextNode
+ * #javaCompletionProposals(int, org.eclipse.jpt.utility.Filter,
+ * org.eclipse.jdt.core.dom.CompilationUnit)
+ */
+ @Override
+ public Iterator<String> javaCompletionProposals(int pos,
+ Filter<String> filter, CompilationUnit astRoot) {
+ Iterator<String> result = super.javaCompletionProposals(pos, filter,
+ astRoot);
+ if (result != null) {
+ return result;
+ }
+ System.out.println(getPersistenceUnit().uniqueTypeDefNames());
+ TextRange typeRange = getTypeTextRange(astRoot);
+ if (typeRange != null && typeRange.touches(pos)) {
+ return getJavaCandidateNames(filter).iterator();
+ }
+ return null;
+ }
+
+ private Iterable<String> getJavaCandidateNames(Filter<String> filter) {
+ return StringTools.convertToJavaStringLiterals(this
+ .getCandidateNames(filter));
+ }
+
+ private Iterable<String> getCandidateNames(Filter<String> filter) {
+ return new FilteringIterable<String>(Arrays.asList(getPersistenceUnit()
+ .uniqueTypeDefNames()), filter);
+ }
+
/**
* @param messages
* @param reporter