mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-24 09:25:31 +02:00
Bug 399014 - "Enclosing namespace does not exist" error is too harsh
This commit is contained in:
parent
f1ca02367b
commit
a861f63691
3 changed files with 20 additions and 21 deletions
|
@ -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;
|
||||
|
|
|
@ -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}.
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Add table
Reference in a new issue