aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDawid Pakuła2018-08-07 09:33:29 -0400
committerDawid Pakuła2018-08-07 09:35:39 -0400
commit8614fe3a80f564dceb6007dd27c9b283ecb15e63 (patch)
tree4df509a6ae2c34fb682f7a9f1d8b72df12cb10cb
parent54a9f0b23863d2f5d90ca14ab7ac899abd036928 (diff)
downloadorg.eclipse.pdt-8614fe3a80f564dceb6007dd27c9b283ecb15e63.tar.gz
org.eclipse.pdt-8614fe3a80f564dceb6007dd27c9b283ecb15e63.tar.xz
org.eclipse.pdt-8614fe3a80f564dceb6007dd27c9b283ecb15e63.zip
Bug 530596 - ModelException below NewPHPTypePage.firstSegmentsToRemoveForNamespace
Signed-off-by: Dawid Pakuła <zulus@w3des.net>
-rw-r--r--plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/wizards/types/NewPHPTypePage.java34
1 files changed, 20 insertions, 14 deletions
diff --git a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/wizards/types/NewPHPTypePage.java b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/wizards/types/NewPHPTypePage.java
index f79f25f6b..f0d492e3b 100644
--- a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/wizards/types/NewPHPTypePage.java
+++ b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/wizards/types/NewPHPTypePage.java
@@ -38,6 +38,7 @@ import org.eclipse.dltk.ui.dialogs.TypeSelectionExtension;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.viewers.*;
import org.eclipse.jface.window.Window;
+import org.eclipse.php.core.PHPToolkitUtil;
import org.eclipse.php.core.PHPVersion;
import org.eclipse.php.core.compiler.PHPFlags;
import org.eclipse.php.core.project.ProjectOptions;
@@ -460,6 +461,7 @@ public abstract class NewPHPTypePage extends BasicPHPWizardPage implements IDial
}
IFile existingFile = getExisitngFile();
String sourceFolder = getSourceText();
+
if (!sourceFolder.isEmpty()) {
IPath sourcePath = new Path(sourceFolder);
removedSegmentNumber = firstSegmentsToRemoveForNamespace(sourcePath);
@@ -491,7 +493,11 @@ public abstract class NewPHPTypePage extends BasicPHPWizardPage implements IDial
private int firstSegmentsToRemoveForNamespace(IPath sourcePath) {
try {
- for (IProjectFragment projectFragment : getProject().getProjectFragments()) {
+ IScriptProject project = getProject();
+ if (!project.exists() || !PHPToolkitUtil.isFromPHPProject(project)) {
+ return 1;
+ }
+ for (IProjectFragment projectFragment : project.getProjectFragments()) {
int matching = projectFragment.getPath().matchingFirstSegments(sourcePath);
if (matching > 1) {
return matching;
@@ -693,16 +699,16 @@ public abstract class NewPHPTypePage extends BasicPHPWizardPage implements IDial
}
/**
- * Denotes whether the new PHP element is inserted in an existing PHP file (if
- * true) or in a new php file (if false).
+ * Denotes whether the new PHP element is inserted in an existing PHP file
+ * (if true) or in a new php file (if false).
*/
public boolean isInExistingPHPFile() {
return existingFileBtn.getSelection();
}
/**
- * Denotes whether the created element will be inserted in the 1st block of the
- * existing PHP file , OR (if false) as a new PHP block
+ * Denotes whether the created element will be inserted in the 1st block of
+ * the existing PHP file , OR (if false) as a new PHP block
*/
public boolean isInFirstPHPBlock() {
return firstBlockBtn.getSelection();
@@ -723,9 +729,9 @@ public abstract class NewPHPTypePage extends BasicPHPWizardPage implements IDial
}
/**
- * Returns a HashMap that represents the state of modifiers for the PHP element.
- * Key - the string name of the modifier. Value - a Boolean object , whether the
- * modifier is selected or not.
+ * Returns a HashMap that represents the state of modifiers for the PHP
+ * element. Key - the string name of the modifier. Value - a Boolean object
+ * , whether the modifier is selected or not.
*/
public Map<String, Boolean> getModifiers() {
if (modifiers == null) {
@@ -819,8 +825,8 @@ public abstract class NewPHPTypePage extends BasicPHPWizardPage implements IDial
}
/**
- * Initializes the source folder field with a valid root. The root is computed
- * from the given PHPlement.
+ * Initializes the source folder field with a valid root. The root is
+ * computed from the given PHPlement.
*
* @param elem
* the PHP Element used to compute the initial root used as the
@@ -1410,8 +1416,8 @@ public abstract class NewPHPTypePage extends BasicPHPWizardPage implements IDial
}
/**
- * Since source folder changing affects the PHP model, it should be overriden by
- * this class children.
+ * Since source folder changing affects the PHP model, it should be
+ * overriden by this class children.
*/
protected void sourceFolderChanged() {
sourceFolderStatus = new StatusInfo();
@@ -1631,8 +1637,8 @@ public abstract class NewPHPTypePage extends BasicPHPWizardPage implements IDial
}
/**
- * Uses the standard container selection dialog to choose the new value for the
- * Source Folder field.
+ * Uses the standard container selection dialog to choose the new value for
+ * the Source Folder field.
*/
private void chooseNewSourceFolder() {
final ContainerSelectionDialog dialog = new ContainerSelectionDialog(getShell(),