Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpfullbright2012-04-25 17:57:31 -0400
committerpfullbright2012-04-25 17:57:31 -0400
commit3c2f5164b42cda3bf0c1ef1264525ef892658682 (patch)
treeb5e0b809cb66aa4ff7bad2696563f72ed96322ff
parentec220d9b3139427e9332e495aab3c395fe63b433 (diff)
downloadwebtools.dali-3c2f5164b42cda3bf0c1ef1264525ef892658682.tar.gz
webtools.dali-3c2f5164b42cda3bf0c1ef1264525ef892658682.tar.xz
webtools.dali-3c2f5164b42cda3bf0c1ef1264525ef892658682.zip
completed package level annotation content assist
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlNs.java29
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlSchema.java7
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlNs.java122
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlSchema.java18
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlNsAnnotation.java20
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/XmlNsAnnotation.java31
6 files changed, 161 insertions, 66 deletions
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlNs.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlNs.java
index c83049ccc9..2957f574d8 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlNs.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlNs.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 Oracle. All rights reserved.
+ * Copyright (c) 2010, 2012 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.
@@ -9,6 +9,7 @@
******************************************************************************/
package org.eclipse.jpt.jaxb.core.context;
+import org.eclipse.jpt.jaxb.core.context.java.JavaContextNode;
import org.eclipse.jpt.jaxb.core.resource.java.XmlNsAnnotation;
/**
@@ -24,18 +25,26 @@ import org.eclipse.jpt.jaxb.core.resource.java.XmlNsAnnotation;
* @since 3.0
*/
public interface XmlNs
- extends
- JaxbContextNode
-{
+ extends JavaContextNode {
+
+
XmlNsAnnotation getResourceXmlNs();
-
- // ********** namespaceURI **********
+
+
+ // ***** namespaceURI *****
+
+ String NAMESPACE_URI_PROPERTY = "namespaceURI"; //$NON-NLS-1$
+
String getNamespaceURI();
+
void setNamespaceURI(String namespaceURI);
- String NAMESPACE_URI_PROPERTY = "namespaceURI"; //$NON-NLS-1$
-
- // ********** prefix **********
+
+
+ // ***** prefix *****
+
+ String PREFIX_PROPERTY = "prefix"; //$NON-NLS-1$
+
String getPrefix();
+
void setPrefix(String prefix);
- String PREFIX_PROPERTY = "prefix"; //$NON-NLS-1$
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlSchema.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlSchema.java
index 60c10d28e6..02be8d7833 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlSchema.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlSchema.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 Oracle. All rights reserved.
+ * Copyright (c) 2010, 2012 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.
@@ -27,6 +27,11 @@ import org.eclipse.jpt.jaxb.core.context.java.JavaContextNode;
public interface XmlSchema
extends JavaContextNode {
+ JaxbPackageInfo getJaxbPackageInfo();
+
+
+ // ***** namespace *****
+
/**
* Return the specified namespace or "" (default value)
*/
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlNs.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlNs.java
index 6535eeaec4..d317dffb14 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlNs.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlNs.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 Oracle. All rights reserved.
+ * Copyright (c) 2010, 2012 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.
@@ -9,100 +9,148 @@
******************************************************************************/
package org.eclipse.jpt.jaxb.core.internal.context.java;
+import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.common.core.resource.java.JavaResourcePackage;
+import org.eclipse.jpt.common.core.utility.TextRange;
+import org.eclipse.jpt.common.utility.Filter;
+import org.eclipse.jpt.common.utility.internal.CollectionTools;
+import org.eclipse.jpt.common.utility.internal.StringTools;
+import org.eclipse.jpt.common.utility.internal.iterables.CompositeIterable;
+import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable;
+import org.eclipse.jpt.common.utility.internal.iterables.SingleElementIterable;
import org.eclipse.jpt.jaxb.core.context.JaxbPackageInfo;
import org.eclipse.jpt.jaxb.core.context.XmlNs;
import org.eclipse.jpt.jaxb.core.context.XmlSchema;
-import org.eclipse.jpt.jaxb.core.internal.context.AbstractJaxbContextNode;
import org.eclipse.jpt.jaxb.core.resource.java.XmlNsAnnotation;
+import org.eclipse.jpt.jaxb.core.xsd.XsdSchema;
public class GenericJavaXmlNs
- extends AbstractJaxbContextNode
- implements XmlNs
-{
-
+ extends AbstractJavaContextNode
+ implements XmlNs {
+
protected final XmlNsAnnotation resourceXmlNs;
-
+
protected String namespaceURI;
-
+
protected String prefix;
-
+
+
public GenericJavaXmlNs(XmlSchema parent, XmlNsAnnotation xmlNsAnnotation) {
super(parent);
this.resourceXmlNs = xmlNsAnnotation;
this.namespaceURI = this.getResourceNamespaceURI();
this.prefix = this.getResourcePrefix();
}
-
+
+
public XmlNsAnnotation getResourceXmlNs() {
return this.resourceXmlNs;
}
-
- // ********** synchronize/update **********
-
+
+
+ // ***** synchronize/update *****
+
@Override
public void synchronizeWithResourceModel() {
super.synchronizeWithResourceModel();
this.setNamespaceURI_(this.getResourceNamespaceURI());
this.setPrefix_(this.getResourcePrefix());
}
-
-
- @Override
- public JaxbPackageInfo getParent() {
- return (JaxbPackageInfo) super.getParent();
+
+
+ protected JaxbPackageInfo getJaxbPackageInfo() {
+ return getXmlSchema().getJaxbPackageInfo();
}
-
+
+ protected XmlSchema getXmlSchema() {
+ return (XmlSchema) getParent();
+ }
+
protected JavaResourcePackage getResourcePackage() {
- return getParent().getResourcePackage();
+ return getJaxbPackageInfo().getResourcePackage();
}
-
-
- // ********** namespaceURI **********
-
+
+
+ // ***** namespaceURI *****
+
public String getNamespaceURI() {
return this.namespaceURI;
}
-
+
public void setNamespaceURI(String namespace) {
this.resourceXmlNs.setNamespaceURI(namespace);
this.setNamespaceURI_(namespace);
}
-
+
protected void setNamespaceURI_(String namespaceURI) {
String old = this.namespaceURI;
this.namespaceURI = namespaceURI;
this.firePropertyChanged(NAMESPACE_URI_PROPERTY, old, namespaceURI);
}
-
+
protected String getResourceNamespaceURI() {
return this.resourceXmlNs.getNamespaceURI();
}
-
- // ********** prefix **********
-
+
+
+ // ***** prefix *****
+
public String getPrefix() {
return this.prefix;
}
-
+
public void setPrefix(String prefix) {
this.resourceXmlNs.setPrefix(prefix);
this.setPrefix_(prefix);
}
-
+
protected void setPrefix_(String prefix) {
String old = this.prefix;
this.prefix = prefix;
this.firePropertyChanged(PREFIX_PROPERTY, old, prefix);
}
-
+
protected String getResourcePrefix() {
return this.resourceXmlNs.getPrefix();
}
-
-
- //****************** miscellaneous ********************
-
+
+
+ // ***** content assist *****
+
+ @Override
+ public Iterable<String> getJavaCompletionProposals(
+ int pos, Filter<String> filter, CompilationUnit astRoot) {
+
+ if (getResourceXmlNs().namespaceURITouches(pos, astRoot)) {
+ return getNamespaceURICompletionProposals(pos, filter, astRoot);
+ }
+ return EmptyIterable.instance();
+ }
+
+ protected Iterable<String> getNamespaceURICompletionProposals(
+ int pos, Filter<String> filter, CompilationUnit astRoot) {
+
+ String packageNamespace = getJaxbPackageInfo().getJaxbPackage().getNamespace();
+ Iterable<String> result = (StringTools.stringIsEmpty(packageNamespace)) ?
+ EmptyIterable.instance() : new SingleElementIterable(StringTools.convertToJavaStringLiteral(packageNamespace));
+ XsdSchema schema = getJaxbPackageInfo().getJaxbPackage().getXsdSchema();
+ if (schema != null) {
+ result = new CompositeIterable<String>(result, schema.getNamespaceProposals(filter));
+ }
+ return CollectionTools.set(result);
+ }
+
+
+ // ***** validation *****
+
+ @Override
+ public TextRange getValidationTextRange(CompilationUnit astRoot) {
+ return getResourceXmlNs().getTextRange(astRoot);
+ }
+
+
+ // ***** miscellaneous *****
+
@Override
public void toString(StringBuilder sb) {
super.toString(sb);
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlSchema.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlSchema.java
index 11d1258286..3c7603548c 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlSchema.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlSchema.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2011 Oracle. All rights reserved.
+ * Copyright (c) 2010, 2012 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.
@@ -76,17 +76,16 @@ public class GenericJavaXmlSchema
this.updateXmlNsPrefixes();
}
- @Override
- public JaxbPackageInfo getParent() {
- return (JaxbPackageInfo) super.getParent();
+ public JaxbPackageInfo getJaxbPackageInfo() {
+ return (JaxbPackageInfo) getParent();
}
public JaxbPackage getJaxbPackage() {
- return getParent().getJaxbPackage();
+ return getJaxbPackageInfo().getJaxbPackage();
}
protected JavaResourcePackage getResourcePackage() {
- return getParent().getResourcePackage();
+ return getJaxbPackageInfo().getResourcePackage();
}
@@ -262,6 +261,13 @@ public class GenericJavaXmlSchema
return getNamespaceProposals(filter);
}
+ for (XmlNs xmlns : getXmlNsPrefixes()) {
+ result = xmlns.getJavaCompletionProposals(pos, filter, astRoot);
+ if (! CollectionTools.isEmpty(result)) {
+ return result;
+ }
+ }
+
return EmptyIterable.instance();
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlNsAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlNsAnnotation.java
index aec42f8b62..890f2fb793 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlNsAnnotation.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlNsAnnotation.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 Oracle. All rights reserved.
+ * Copyright (c) 2010, 2012 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
@@ -84,7 +84,7 @@ public class SourceXmlNsAnnotation
}
- // **************** namespace *********************************************
+ // ***** namespace *****
public String getNamespaceURI() {
return this.namespaceURI;
@@ -108,11 +108,15 @@ public class SourceXmlNsAnnotation
}
public TextRange getNamespaceURITextRange(CompilationUnit astRoot) {
- return this.getElementTextRange(this.namespaceURIDeclarationAdapter, astRoot);
+ return getElementTextRange(this.namespaceURIDeclarationAdapter, astRoot);
+ }
+
+ public boolean namespaceURITouches(int pos, CompilationUnit astRoot) {
+ return elementTouches(this.namespaceURIDeclarationAdapter, pos, astRoot);
}
- // **************** prefix ************************************************
+ // ***** prefix *****
public String getPrefix() {
return this.prefix;
@@ -136,11 +140,15 @@ public class SourceXmlNsAnnotation
}
public TextRange getPrefixTextRange(CompilationUnit astRoot) {
- return this.getElementTextRange(this.prefixDeclarationAdapter, astRoot);
+ return getElementTextRange(this.prefixDeclarationAdapter, astRoot);
+ }
+
+ public boolean prefixTouches(int pos, CompilationUnit astRoot) {
+ return elementTouches(this.prefixDeclarationAdapter, pos, astRoot);
}
- // **************** NestableAnnotation impl *******************************
+ // ***** NestableAnnotation impl *****
@Override
public void moveAnnotation(int newIndex) {
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/XmlNsAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/XmlNsAnnotation.java
index dffd0ffe49..fc9a9d8232 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/XmlNsAnnotation.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/XmlNsAnnotation.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 Oracle. All rights reserved.
+ * Copyright (c) 2010, 2012 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
@@ -29,13 +29,16 @@ import org.eclipse.jpt.common.core.utility.TextRange;
public interface XmlNsAnnotation
extends NestableAnnotation {
+ // ***** namespaceURI *****
+
+ String NAMESPACE_URI_PROPERTY = "namespaceURI"; //$NON-NLS-1$
+
/**
* Corresponds to the 'namespaceURI' element of the XmlNs annotation.
* Return null if the element does not exist in Java.
*/
String getNamespaceURI();
- String NAMESPACE_URI_PROPERTY = "namespaceURI"; //$NON-NLS-1$
-
+
/**
* Corresponds to the 'namespaceURI' element of the XmlNs annotation.
* Set to null to remove the element.
@@ -43,18 +46,28 @@ public interface XmlNsAnnotation
void setNamespaceURI(String namespaceURI);
/**
- * Return the {@link TextRange} for the 'namespace' element. If the element
+ * Return the {@link TextRange} for the 'namespaceURI' element. If the element
* does not exist return the {@link TextRange} for the XmlNs annotation.
*/
TextRange getNamespaceURITextRange(CompilationUnit astRoot);
/**
+ * Return whether the specified position touches the 'namespaceURI' element.
+ * Return false if the element does not exist.
+ */
+ boolean namespaceURITouches(int pos, CompilationUnit astRoot);
+
+
+ // ***** prefix *****
+
+ String PREFIX_PROPERTY = "prefix"; //$NON-NLS-1$
+
+ /**
* Corresponds to the 'prefix' element of the XmlNs annotation.
* Return null if the element does not exist in Java.
*/
String getPrefix();
- String PREFIX_PROPERTY = "prefix"; //$NON-NLS-1$
-
+
/**
* Corresponds to the 'prefix' element of the XmlNs annotation.
* Set to null to remove the element.
@@ -66,4 +79,10 @@ public interface XmlNsAnnotation
* does not exist return the {@link TextRange} for the XmlNs annotation.
*/
TextRange getPrefixTextRange(CompilationUnit astRoot);
+
+ /**
+ * Return whether the specified position touches the 'prefix' element.
+ * Return false if the element does not exist.
+ */
+ boolean prefixTouches(int pos, CompilationUnit astRoot);
}

Back to the top