|
From: <caw...@us...> - 2007-04-04 15:01:35
|
Revision: 2274
http://svn.sourceforge.net/rubyeclipse/?rev=2274&view=rev
Author: cawilliams
Date: 2007-04-04 08:01:25 -0700 (Wed, 04 Apr 2007)
Log Message:
-----------
fix bug that threw errors on creating a new Ruby class via wizard (positions are off by one in SourceParser for type and module). Also fix so when a new class is created, it is opened in editor
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceParser.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/wizards/NewTypeWizardPage.java
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceParser.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceParser.java 2007-04-04 14:35:34 UTC (rev 2273)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceParser.java 2007-04-04 15:01:25 UTC (rev 2274)
@@ -120,7 +120,7 @@
Instruction ins = super.visitClassNode(iVisited);
- requestor.exitType(iVisited.getPosition().getEndOffset());
+ requestor.exitType(iVisited.getPosition().getEndOffset() - 1);
return ins;
}
@@ -139,7 +139,7 @@
Instruction ins = super.visitModuleNode(iVisited);
- requestor.exitType(iVisited.getPosition().getEndOffset());
+ requestor.exitType(iVisited.getPosition().getEndOffset() - 1);
return ins;
}
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/wizards/NewTypeWizardPage.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/wizards/NewTypeWizardPage.java 2007-04-04 14:35:34 UTC (rev 2273)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/wizards/NewTypeWizardPage.java 2007-04-04 15:01:25 UTC (rev 2274)
@@ -31,6 +31,7 @@
import org.rubypeople.rdt.core.RubyConventions;
import org.rubypeople.rdt.core.RubyModelException;
import org.rubypeople.rdt.core.formatter.CodeFormatter;
+import org.rubypeople.rdt.internal.core.RubyProject;
import org.rubypeople.rdt.internal.corext.codemanipulation.StubUtility;
import org.rubypeople.rdt.internal.corext.util.CodeFormatterUtil;
import org.rubypeople.rdt.internal.corext.util.Messages;
@@ -118,9 +119,9 @@
protected IStatus fSuperInterfacesStatus;
private int fTypeKind;
- private ISourceFolder fCurrPackage;
+ private ISourceFolder fCurrSourceFolder;
- private boolean fCanModifyPackage;
+ private boolean fCanModifySourceFolder;
/**
* Constant to signal that the created type is a class.
@@ -230,7 +231,7 @@
ISourceFolderRoot root= getSourceFolderRoot();
if (root != null) {
- fCurrPackage= root.getSourceFolder(packName);
+ fCurrSourceFolder= root.getSourceFolder(packName);
} else {
status.setError(""); //$NON-NLS-1$
}
@@ -535,7 +536,7 @@
* could not be resolved.
*/
public ISourceFolder getSourceFolder() {
- return fCurrPackage;
+ return fCurrSourceFolder;
}
/**
@@ -547,8 +548,8 @@
* editable; otherwise it is read-only.
*/
public void setSourceFolder(ISourceFolder pack, boolean canBeModified) {
- fCurrPackage= pack;
- fCanModifyPackage= canBeModified;
+ fCurrSourceFolder= pack;
+ fCanModifySourceFolder= canBeModified;
String str= (pack == null) ? "" : pack.getElementName(); //$NON-NLS-1$
fPackageDialogField.setText(str);
updateEnableState();
@@ -559,7 +560,7 @@
*/
private void updateEnableState() {
boolean enclosing= isEnclosingTypeSelected();
- fPackageDialogField.setEnabled(fCanModifyPackage && !enclosing);
+ fPackageDialogField.setEnabled(fCanModifySourceFolder && !enclosing);
}
private boolean isEnclosingTypeSelected() {
@@ -830,13 +831,17 @@
ArrayList initSuperinterfaces= new ArrayList(5);
IRubyProject project= null;
- ISourceFolder pack= null;
+ ISourceFolder folder= null;
IType enclosingType= null;
if (elem != null) {
// evaluate the enclosing type
project= elem.getRubyProject();
- pack= (ISourceFolder) elem.getAncestor(IRubyElement.SOURCE_FOLDER);
+ if (elem instanceof RubyProject) {
+ folder = getSourceFolderRoot().getSourceFolder(new String[0]);
+ } else {
+ folder= (ISourceFolder) elem.getAncestor(IRubyElement.SOURCE_FOLDER);
+ }
IType typeInCU= (IType) elem.getAncestor(IRubyElement.TYPE);
if (typeInCU != null) {
if (typeInCU.getRubyScript() != null) {
@@ -878,7 +883,7 @@
}
}
-// setPackageFragment(pack, true);
+ setSourceFolder(folder, true);
setTypeName(typeName, true);
setSuperClass(initSuperclass, true);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|