Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkmoore2012-03-22 07:54:14 -0400
committerkmoore2012-03-22 07:54:14 -0400
commit1cb338cc0c64a8ae8e6e9c7f266a57b4414a45a1 (patch)
treef87f45b85d9e3732cb8cc014720e09367d3c49e5
parent241e40fa3c2f5c20df4971fe27f651ed82cdb513 (diff)
downloadwebtools.dali-1cb338cc0c64a8ae8e6e9c7f266a57b4414a45a1.tar.gz
webtools.dali-1cb338cc0c64a8ae8e6e9c7f266a57b4414a45a1.tar.xz
webtools.dali-1cb338cc0c64a8ae8e6e9c7f266a57b4414a45a1.zip
Bug 363080 - refactoring class reference in xml from the default package causes exception
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/AbstractXmlRelationshipMapping.java15
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/AbstractXmlTypeMapping.java11
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlClassReference.java15
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlElementCollection.java13
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/persistence/XmlJavaClassRef.java15
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/resource/orm/XmlConverter.java13
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/resource/orm/XmlObjectTypeConverter.java24
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/resource/orm/XmlStructConverter.java13
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/resource/orm/XmlTypeConverter.java24
9 files changed, 107 insertions, 36 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/AbstractXmlRelationshipMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/AbstractXmlRelationshipMapping.java
index df317ff85f..c7e73f0765 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/AbstractXmlRelationshipMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/AbstractXmlRelationshipMapping.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2010 Oracle. All rights reserved.
+ * Copyright (c) 2007, 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.
@@ -391,10 +391,19 @@ public abstract class AbstractXmlRelationshipMapping extends AbstractXmlAttribut
return new ReplaceEdit(offset + nameIndex, originalName.length(), newName);
}
- public ReplaceEdit createRenameTargetEntityPackageEdit(String newName) {
+ public ReplaceEdit createRenameTargetEntityPackageEdit(String newPackageName) {
int packageLength = this.targetEntity.lastIndexOf('.');
+ if (newPackageName == "") {//$NON-NLS-1$
+ //moving to the default package, remove the '.'
+ packageLength++;
+ }
+ if (packageLength == -1) {
+ //moving from the default package or unspecified package
+ packageLength = 0;
+ newPackageName = newPackageName + '.';
+ }
int offset = getAttributeNode(JPA.TARGET_ENTITY).getValueRegionStartOffset() + 1; // +1 = opening double quote
- return new ReplaceEdit(offset, packageLength, newName);
+ return new ReplaceEdit(offset, packageLength, newPackageName);
}
} // RelationshipMapping
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/AbstractXmlTypeMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/AbstractXmlTypeMapping.java
index 54f7b4b194..fb759529b2 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/AbstractXmlTypeMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/AbstractXmlTypeMapping.java
@@ -540,14 +540,19 @@ public abstract class AbstractXmlTypeMapping extends AbstractJpaEObject implemen
return new ReplaceEdit(offset + nameIndex, originalName.length(), newName);
}
- public ReplaceEdit createRenamePackageEdit(String newName) {
+ public ReplaceEdit createRenamePackageEdit(String newPackageName) {
int packageLength = this.className.lastIndexOf('.');
+ if (newPackageName == "") {//$NON-NLS-1$
+ //moving to the default package, remove the '.'
+ packageLength++;
+ }
if (packageLength == -1) {
+ //moving from the default package or unspecified package
packageLength = 0;
- newName = newName + '.';
+ newPackageName = newPackageName + '.';
}
int offset = getAttributeNode(JPA.CLASS).getValueRegionStartOffset() + 1; // +1 = opening double quote
- return new ReplaceEdit(offset, packageLength, newName);
+ return new ReplaceEdit(offset, packageLength, newPackageName);
}
// *********** content assist ************
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlClassReference.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlClassReference.java
index bfb459df82..e27127c2a2 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlClassReference.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlClassReference.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 Oracle.
+ * 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
@@ -237,10 +237,19 @@ public class XmlClassReference extends AbstractJpaEObject implements JpaEObject
return new ReplaceEdit(offset + nameIndex, originalName.length(), newName);
}
- public ReplaceEdit createRenamePackageEdit(String newName) {
+ public ReplaceEdit createRenamePackageEdit(String newPackageName) {
int packageLength = this.className.lastIndexOf('.');
+ if (newPackageName == "") {//$NON-NLS-1$
+ //moving to the default package, remove the '.'
+ packageLength++;
+ }
+ if (packageLength == -1) {
+ //moving from the default package or unspecified package
+ packageLength = 0;
+ newPackageName = newPackageName + '.';
+ }
int offset = getAttributeNode(JPA.CLASS).getValueRegionStartOffset() + 1; // +1 = opening double quote
- return new ReplaceEdit(offset, packageLength, newName);
+ return new ReplaceEdit(offset, packageLength, newPackageName);
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlElementCollection.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlElementCollection.java
index 9dc71dfa7c..ab7a99742f 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlElementCollection.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlElementCollection.java
@@ -1674,10 +1674,19 @@ public class XmlElementCollection extends AbstractXmlAttributeMapping implements
return getMapKeyClass().createRenameEdit(originalType, newName);
}
- public ReplaceEdit createRenameTargetClassPackageEdit(String newName) {
+ public ReplaceEdit createRenameTargetClassPackageEdit(String newPackageName) {
int packageLength = this.targetClass.lastIndexOf('.');
+ if (newPackageName == "") {//$NON-NLS-1$
+ //moving to the default package, remove the '.'
+ packageLength++;
+ }
+ if (packageLength == -1) {
+ //moving from the default package or unspecified package
+ packageLength = 0;
+ newPackageName = newPackageName + '.';
+ }
int offset = getAttributeNode(JPA2_0.TARGET_CLASS).getValueRegionStartOffset() + 1; // +1 = opening double quote
- return new ReplaceEdit(offset, packageLength, newName);
+ return new ReplaceEdit(offset, packageLength, newPackageName);
}
public ReplaceEdit createRenameMapKeyClassPackageEdit(String newName) {
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/persistence/XmlJavaClassRef.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/persistence/XmlJavaClassRef.java
index 47a0881b54..876b169bcb 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/persistence/XmlJavaClassRef.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/persistence/XmlJavaClassRef.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2011 Oracle. All rights reserved.
+ * Copyright (c) 2006, 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.
@@ -241,9 +241,18 @@ public class XmlJavaClassRef extends AbstractJpaEObject implements JpaEObject
return new ReplaceEdit(offset + nameIndex, originalName.length(), newName);
}
- public ReplaceEdit createRenamePackageEdit(String newName) {
+ public ReplaceEdit createRenamePackageEdit(String newPackageName) {
int packageLength = this.javaClass.lastIndexOf('.');
+ if (newPackageName == "") {//$NON-NLS-1$
+ //moving to the default package, remove the '.'
+ packageLength++;
+ }
+ if (packageLength == -1) {
+ //moving from the default package or unspecified package
+ packageLength = 0;
+ newPackageName = newPackageName + '.';
+ }
int offset = getTextNode().getStartOffset();
- return new ReplaceEdit(offset, packageLength, newName);
+ return new ReplaceEdit(offset, packageLength, newPackageName);
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/resource/orm/XmlConverter.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/resource/orm/XmlConverter.java
index 581f386de0..4461506109 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/resource/orm/XmlConverter.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/resource/orm/XmlConverter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2010 Oracle. All rights reserved.
+ * Copyright (c) 2008, 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.
@@ -238,14 +238,19 @@ public class XmlConverter extends XmlNamedConverter
return new ReplaceEdit(offset + nameIndex, originalName.length(), newName);
}
- public ReplaceEdit createRenamePackageEdit(String newName) {
+ public ReplaceEdit createRenamePackageEdit(String newPackageName) {
int packageLength = this.className.lastIndexOf('.');
+ if (newPackageName == "") {//$NON-NLS-1$
+ //moving to the default package, remove the '.'
+ packageLength++;
+ }
if (packageLength == -1) {
+ //moving from the default package or unspecified package
packageLength = 0;
- newName = newName + '.';
+ newPackageName = newPackageName + '.';
}
int offset = getAttributeNode(EclipseLink.CONVERTER__CLASS).getValueRegionStartOffset() + 1; // +1 = opening double quote
- return new ReplaceEdit(offset, packageLength, newName);
+ return new ReplaceEdit(offset, packageLength, newPackageName);
}
} // XmlConverter
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/resource/orm/XmlObjectTypeConverter.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/resource/orm/XmlObjectTypeConverter.java
index 07e6ef6e5d..003aa315bc 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/resource/orm/XmlObjectTypeConverter.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/resource/orm/XmlObjectTypeConverter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2010 Oracle. All rights reserved.
+ * Copyright (c) 2008, 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.
@@ -447,14 +447,19 @@ public class XmlObjectTypeConverter extends XmlNamedConverter
return new ReplaceEdit(offset + nameIndex, originalName.length(), newName);
}
- public ReplaceEdit createRenameDataTypePackageEdit(String newName) {
+ public ReplaceEdit createRenameDataTypePackageEdit(String newPackageName) {
int packageLength = this.dataType.lastIndexOf('.');
+ if (newPackageName == "") {//$NON-NLS-1$
+ //moving to the default package, remove the '.'
+ packageLength++;
+ }
if (packageLength == -1) {
+ //moving from the default package or unspecified package
packageLength = 0;
- newName = newName + '.';
+ newPackageName = newPackageName + '.';
}
int offset = getAttributeNode(EclipseLink.OBJECT_TYPE_CONVERTER__DATA_TYPE).getValueRegionStartOffset() + 1; // +1 = opening double quote
- return new ReplaceEdit(offset, packageLength, newName);
+ return new ReplaceEdit(offset, packageLength, newPackageName);
}
public ReplaceEdit createRenameObjectTypeEdit(IType originalType, String newName) {
@@ -464,14 +469,19 @@ public class XmlObjectTypeConverter extends XmlNamedConverter
return new ReplaceEdit(offset + nameIndex, originalName.length(), newName);
}
- public ReplaceEdit createRenameObjectTypePackageEdit(String newName) {
+ public ReplaceEdit createRenameObjectTypePackageEdit(String newPackageName) {
int packageLength = this.objectType.lastIndexOf('.');
+ if (newPackageName == "") {//$NON-NLS-1$
+ //moving to the default package, remove the '.'
+ packageLength++;
+ }
if (packageLength == -1) {
+ //moving from the default package or unspecified package
packageLength = 0;
- newName = newName + '.';
+ newPackageName = newPackageName + '.';
}
int offset = getAttributeNode(EclipseLink.OBJECT_TYPE_CONVERTER__OBJECT_TYPE).getValueRegionStartOffset() + 1; // +1 = opening double quote
- return new ReplaceEdit(offset, packageLength, newName);
+ return new ReplaceEdit(offset, packageLength, newPackageName);
}
} // XmlObjectTypeConverter
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/resource/orm/XmlStructConverter.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/resource/orm/XmlStructConverter.java
index b7028939fb..9b2715fa6a 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/resource/orm/XmlStructConverter.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/resource/orm/XmlStructConverter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2010 Oracle. All rights reserved.
+ * Copyright (c) 2008, 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.
@@ -243,13 +243,18 @@ public class XmlStructConverter extends XmlNamedConverter
return new ReplaceEdit(offset + nameIndex, originalName.length(), newName);
}
- public ReplaceEdit createRenamePackageEdit(String newName) {
+ public ReplaceEdit createRenamePackageEdit(String newPackageName) {
int packageLength = this.converter.lastIndexOf('.');
+ if (newPackageName == "") {//$NON-NLS-1$
+ //moving to the default package, remove the '.'
+ packageLength++;
+ }
if (packageLength == -1) {
+ //moving from the default package or unspecified package
packageLength = 0;
- newName = newName + '.';
+ newPackageName = newPackageName + '.';
}
int offset = getAttributeNode(EclipseLink.STRUCT_CONVERTER__CONVERTER).getValueRegionStartOffset() + 1; // +1 = opening double quote
- return new ReplaceEdit(offset, packageLength, newName);
+ return new ReplaceEdit(offset, packageLength, newPackageName);
}
} // XmlStructConverter
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/resource/orm/XmlTypeConverter.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/resource/orm/XmlTypeConverter.java
index 6ed61ef56f..7096edbd93 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/resource/orm/XmlTypeConverter.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/resource/orm/XmlTypeConverter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2010 Oracle. All rights reserved.
+ * Copyright (c) 2008, 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.
@@ -309,14 +309,19 @@ public class XmlTypeConverter extends XmlNamedConverter
return new ReplaceEdit(offset + nameIndex, originalName.length(), newName);
}
- public ReplaceEdit createRenameDataTypePackageEdit(String newName) {
+ public ReplaceEdit createRenameDataTypePackageEdit(String newPackageName) {
int packageLength = this.dataType.lastIndexOf('.');
+ if (newPackageName == "") {//$NON-NLS-1$
+ //moving to the default package, remove the '.'
+ packageLength++;
+ }
if (packageLength == -1) {
+ //moving from the default package or unspecified package
packageLength = 0;
- newName = newName + '.';
+ newPackageName = newPackageName + '.';
}
int offset = getAttributeNode(EclipseLink.TYPE_CONVERTER__DATA_TYPE).getValueRegionStartOffset() + 1; // +1 = opening double quote
- return new ReplaceEdit(offset, packageLength, newName);
+ return new ReplaceEdit(offset, packageLength, newPackageName);
}
public ReplaceEdit createRenameObjectTypeEdit(IType originalType, String newName) {
@@ -326,14 +331,19 @@ public class XmlTypeConverter extends XmlNamedConverter
return new ReplaceEdit(offset + nameIndex, originalName.length(), newName);
}
- public ReplaceEdit createRenameObjectTypePackageEdit(String newName) {
+ public ReplaceEdit createRenameObjectTypePackageEdit(String newPackageName) {
int packageLength = this.objectType.lastIndexOf('.');
+ if (newPackageName == "") {//$NON-NLS-1$
+ //moving to the default package, remove the '.'
+ packageLength++;
+ }
if (packageLength == -1) {
+ //moving from the default package or unspecified package
packageLength = 0;
- newName = newName + '.';
+ newPackageName = newPackageName + '.';
}
int offset = getAttributeNode(EclipseLink.TYPE_CONVERTER__OBJECT_TYPE).getValueRegionStartOffset() + 1; // +1 = opening double quote
- return new ReplaceEdit(offset, packageLength, newName);
+ return new ReplaceEdit(offset, packageLength, newPackageName);
}
} // XmlTypeConverter

Back to the top