Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergey Prigogin2013-01-24 20:27:02 +0000
committerSergey Prigogin2013-01-24 20:46:15 +0000
commit07f6ab573f3141f3bb3706e1e4167e213c5920ba (patch)
treec18fff1d14a81890a52cb391612a5f61986eed17
parent79c3d6556ba7992d00236b1b491ce8e2e4ee2c89 (diff)
downloadorg.eclipse.cdt-07f6ab573f3141f3bb3706e1e4167e213c5920ba.tar.gz
org.eclipse.cdt-07f6ab573f3141f3bb3706e1e4167e213c5920ba.tar.xz
org.eclipse.cdt-07f6ab573f3141f3bb3706e1e4167e213c5920ba.zip
Bug 399014 - "Enclosing namespace does not exist" error is too harsh
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardMessages.java3
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardMessages.properties5
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewClassCreationWizardPage.java33
3 files changed, 20 insertions, 21 deletions
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardMessages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardMessages.java
index b2cd29b36cf..c4d0357ad3d 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardMessages.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardMessages.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2011 QNX Software Systems and others.
+ * Copyright (c) 2004, 2013 QNX Software Systems and others.
* 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
@@ -29,7 +29,6 @@ public final class NewClassWizardMessages extends NLS {
public static String NewClassCreationWizardPage_namespace_label;
public static String NewClassCreationWizardPage_namespace_button;
public static String NewClassCreationWizardPage_error_EnterNamespace;
- public static String NewClassCreationWizardPage_error_EnclosingNamespaceNotExists;
public static String NewClassCreationWizardPage_error_NamespaceExistsDifferentCase;
public static String NewClassCreationWizardPage_error_TypeMatchingNamespaceExists;
public static String NewClassCreationWizardPage_error_TypeMatchingNamespaceExistsDifferentCase;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardMessages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardMessages.properties
index ff35ba93539..34b3bdbb72e 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardMessages.properties
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardMessages.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2004, 2011 QNX Software Systems and others.
+# Copyright (c) 2004, 2013 QNX Software Systems and others.
# 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
@@ -34,11 +34,10 @@ NewClassCreationWizardPage_namespace_label=&Namespace:
NewClassCreationWizardPage_namespace_button=Bro&wse...
NewClassCreationWizardPage_error_EnterNamespace=Namespace is empty.
-NewClassCreationWizardPage_error_EnclosingNamespaceNotExists=Enclosing namespace does not exist.
NewClassCreationWizardPage_error_NamespaceExistsDifferentCase=Namespace with the same name exists in a different scope.
NewClassCreationWizardPage_error_TypeMatchingNamespaceExists=Another type with the same name as specified namespace exists.
NewClassCreationWizardPage_error_TypeMatchingNamespaceExistsDifferentCase=Another type with the same name as specified namespace exists in a different scope.
-NewClassCreationWizardPage_warning_NamespaceNotExists=Namespace does not exist. A new namespace will be created.
+NewClassCreationWizardPage_warning_NamespaceNotExists=Namespace ''{0}'' does not exist. A new namespace will be created.
NewClassCreationWizardPage_error_InvalidNamespace=Namespace is not valid. {0}.
NewClassCreationWizardPage_warning_NamespaceDiscouraged=Namespace is discouraged. {0}.
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewClassCreationWizardPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewClassCreationWizardPage.java
index 4ce3ebc734d..58b995452c2 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewClassCreationWizardPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewClassCreationWizardPage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2011 QNX Software Systems and others.
+ * Copyright (c) 2004, 2013 QNX Software Systems and others.
* 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
@@ -1591,17 +1591,8 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
ICProject project = getCurrentProject();
if (project != null) {
- /* search for parent name space first */
- int searchResult;
- if (typeName.isQualified()) {
- searchResult = NewClassWizardUtil.searchForCppType(typeName.getEnclosingTypeName(),project, ICPPNamespace.class);
- if (searchResult != NewClassWizardUtil.SEARCH_MATCH_FOUND_EXACT) {
- status.setError(NewClassWizardMessages.NewClassCreationWizardPage_error_EnclosingNamespaceNotExists);
- return status;
- }
- }
- searchResult = NewClassWizardUtil.searchForCppType(typeName, project, ICPPNamespace.class);
- switch(searchResult) {
+ int searchResult = NewClassWizardUtil.searchForCppType(typeName, project, ICPPNamespace.class);
+ switch (searchResult) {
case NewClassWizardUtil.SEARCH_MATCH_FOUND_EXACT:
status.setOK();
return status;
@@ -1615,7 +1606,17 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
status.setWarning(NewClassWizardMessages.NewClassCreationWizardPage_error_TypeMatchingNamespaceExistsDifferentCase);
return status;
case NewClassWizardUtil.SEARCH_MATCH_NOTFOUND:
- status.setWarning(NewClassWizardMessages.NewClassCreationWizardPage_warning_NamespaceNotExists);
+ // Find the highest ancestor namespace that does not exist.
+ IQualifiedTypeName ns = typeName;
+ while (ns.isQualified()) {
+ IQualifiedTypeName ns1 = ns.getEnclosingTypeName();
+ if (NewClassWizardUtil.searchForCppType(ns1, project, ICPPNamespace.class) == NewClassWizardUtil.SEARCH_MATCH_FOUND_EXACT) {
+ break;
+ }
+ ns = ns1;
+ }
+ status.setWarning(NLS.bind(NewClassWizardMessages.NewClassCreationWizardPage_warning_NamespaceNotExists,
+ ns.getFullyQualifiedName()));
break;
}
}
@@ -1638,7 +1639,7 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
StatusInfo status = new StatusInfo();
String className = getClassName();
- // must not be empty
+ // Must not be empty.
if (className == null || className.length() == 0) {
status.setError(NewClassWizardMessages.NewClassCreationWizardPage_error_EnterClassName);
return status;
@@ -1669,7 +1670,7 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
}
}
int searchResult = NewClassWizardUtil.searchForCppType(fullyQualifiedName, project, ICPPClassType.class);
- switch(searchResult) {
+ switch (searchResult) {
case NewClassWizardUtil.SEARCH_MATCH_FOUND_EXACT:
status.setError(NewClassWizardMessages.NewClassCreationWizardPage_error_ClassNameExists);
return status;
@@ -1729,7 +1730,7 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
MultiStatus status = new MultiStatus(CUIPlugin.getPluginId(), IStatus.OK, "", null); //$NON-NLS-1$
IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(project.getProject());
if (provider != null) {
- //TODO get the scanner info for the actual source folder
+ // TODO Get the scanner info for the actual source folder.
IScannerInfo info = provider.getScannerInformation(project.getProject());
if (info != null) {
String[] includePaths = info.getIncludePaths();

Back to the top