org.eclipse.cdt.internal.ui.wizards.classwizard
Class NewClassWizardUtil

java.lang.Object
  extended by org.eclipse.cdt.internal.ui.wizards.classwizard.NewClassWizardUtil

public class NewClassWizardUtil
extends java.lang.Object


Field Summary
static int SEARCH_MATCH_ERROR
           
static int SEARCH_MATCH_FOUND_ANOTHER_NAMESPACE
           
static int SEARCH_MATCH_FOUND_ANOTHER_TYPE
           
static int SEARCH_MATCH_FOUND_EXACT
           
static int SEARCH_MATCH_FOUND_EXACT_ANOTHER_TYPE
           
static int SEARCH_MATCH_NOTFOUND
           
 
Constructor Summary
NewClassWizardUtil()
           
 
Method Summary
static java.lang.String createHeaderFileName(java.lang.String className)
          Creates a header file name from the given class name.
static java.lang.String createSourceFileName(java.lang.String className)
          Creates a source file name from the given class name.
static org.eclipse.cdt.core.model.ICElement getCElementFromEditor()
          Returns the C Element which corresponds to the active editor.
static org.eclipse.cdt.core.model.ICElement getCElementFromSelection(org.eclipse.jface.viewers.IStructuredSelection selection)
          Returns the C Element which corresponds to the given selection.
static org.eclipse.cdt.core.model.ISourceRoot getFirstSourceRoot(org.eclipse.cdt.core.model.ICProject cproject)
          Returns the first source root in the given project.
static org.eclipse.cdt.core.model.ICElement getNamespace(org.eclipse.cdt.core.model.ICElement element)
          Returns the parent namespace for the given element.
static org.eclipse.cdt.core.browser.ITypeInfo[] getReachableClasses(org.eclipse.cdt.core.model.ICProject cProject)
          Returns all classes/structs which are accessible from the include paths of the given project.
static org.eclipse.cdt.core.model.ICContainer getSourceFolder(org.eclipse.cdt.core.model.ICElement element)
          Returns the parent source folder of the given element.
static org.eclipse.cdt.core.model.ICContainer getSourceFolder(org.eclipse.core.runtime.IPath path)
          Returns the parent source folder for the given path.
static org.eclipse.cdt.core.model.ICContainer getSourceFolder(org.eclipse.core.resources.IResource resource)
          Returns the parent source folder for the given resource.
static org.eclipse.core.resources.IWorkspaceRoot getWorkspaceRoot()
          Returns the workspace root.
static boolean isTypeReachable(org.eclipse.cdt.core.browser.ITypeInfo type, org.eclipse.cdt.core.model.ICProject project, java.lang.String[] includePaths)
          Checks whether the given type can be found in the given project or the given include paths.
static org.eclipse.cdt.core.browser.ITypeReference resolveClassLocation(org.eclipse.cdt.core.browser.ITypeInfo type, org.eclipse.jface.operation.IRunnableContext context)
          Resolve the location of the given class.
static int searchForCppType(org.eclipse.cdt.core.browser.IQualifiedTypeName typeName, org.eclipse.cdt.core.model.ICProject project, java.lang.Class queryType)
          Search for the given qualified name of the give
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SEARCH_MATCH_ERROR

public static final int SEARCH_MATCH_ERROR
See Also:
Constant Field Values

SEARCH_MATCH_NOTFOUND

public static final int SEARCH_MATCH_NOTFOUND
See Also:
Constant Field Values

SEARCH_MATCH_FOUND_EXACT

public static final int SEARCH_MATCH_FOUND_EXACT
See Also:
Constant Field Values

SEARCH_MATCH_FOUND_EXACT_ANOTHER_TYPE

public static final int SEARCH_MATCH_FOUND_EXACT_ANOTHER_TYPE
See Also:
Constant Field Values

SEARCH_MATCH_FOUND_ANOTHER_NAMESPACE

public static final int SEARCH_MATCH_FOUND_ANOTHER_NAMESPACE
See Also:
Constant Field Values

SEARCH_MATCH_FOUND_ANOTHER_TYPE

public static final int SEARCH_MATCH_FOUND_ANOTHER_TYPE
See Also:
Constant Field Values
Constructor Detail

NewClassWizardUtil

public NewClassWizardUtil()
Method Detail

getSourceFolder

public static org.eclipse.cdt.core.model.ICContainer getSourceFolder(org.eclipse.cdt.core.model.ICElement element)
Returns the parent source folder of the given element. If the given element is already a source folder, the element itself is returned.

Parameters:
element - the C Element
Returns:
the source folder

getSourceFolder

public static org.eclipse.cdt.core.model.ICContainer getSourceFolder(org.eclipse.core.runtime.IPath path)
Returns the parent source folder for the given path. If the given path is already a source folder, the corresponding C element is returned.

Parameters:
path - the path
Returns:
the source folder

getSourceFolder

public static org.eclipse.cdt.core.model.ICContainer getSourceFolder(org.eclipse.core.resources.IResource resource)
Returns the parent source folder for the given resource. If the given resource is already a source folder, the corresponding C element is returned.

Parameters:
resource - the resource
Returns:
the source folder

getFirstSourceRoot

public static org.eclipse.cdt.core.model.ISourceRoot getFirstSourceRoot(org.eclipse.cdt.core.model.ICProject cproject)
Returns the first source root in the given project. If the project has no source roots as children, the project itself is returned.

Parameters:
cproject -
Returns:
the source root

getCElementFromSelection

public static org.eclipse.cdt.core.model.ICElement getCElementFromSelection(org.eclipse.jface.viewers.IStructuredSelection selection)
Returns the C Element which corresponds to the given selection.

Parameters:
selection - the selection to be inspected
Returns:
a C element matching the selection, or null if no C element exists in the given selection

getCElementFromEditor

public static org.eclipse.cdt.core.model.ICElement getCElementFromEditor()
Returns the C Element which corresponds to the active editor.

Returns:
a C element matching the active editor, or null if no C element can be found

getNamespace

public static org.eclipse.cdt.core.model.ICElement getNamespace(org.eclipse.cdt.core.model.ICElement element)
Returns the parent namespace for the given element. If the given element is already a namespace, the element itself is returned.

Parameters:
element - the given C Element
Returns:
the C Element for the namespace, or null if not found

createHeaderFileName

public static java.lang.String createHeaderFileName(java.lang.String className)
Creates a header file name from the given class name. This is the file name to be used when the class is created. eg. "MyClass" -> "MyClass.h"

Parameters:
className - the class name
Returns:
the header file name for the given class

createSourceFileName

public static java.lang.String createSourceFileName(java.lang.String className)
Creates a source file name from the given class name. This is the file name to be used when the class is created. eg. "MyClass" -> "MyClass.cpp"

Parameters:
className - the class name
Returns:
the source file name for the given class

getWorkspaceRoot

public static org.eclipse.core.resources.IWorkspaceRoot getWorkspaceRoot()
Returns the workspace root.

Returns:
the workspace root

resolveClassLocation

public static org.eclipse.cdt.core.browser.ITypeReference resolveClassLocation(org.eclipse.cdt.core.browser.ITypeInfo type,
                                                                               org.eclipse.jface.operation.IRunnableContext context)
Resolve the location of the given class.

Parameters:
type - the class to resolve
context - the runnable context
Returns:
the class location, or null if not found

getReachableClasses

public static org.eclipse.cdt.core.browser.ITypeInfo[] getReachableClasses(org.eclipse.cdt.core.model.ICProject cProject)
Returns all classes/structs which are accessible from the include paths of the given project.

Parameters:
cProject - the given project
Returns:
array of classes/structs

isTypeReachable

public static boolean isTypeReachable(org.eclipse.cdt.core.browser.ITypeInfo type,
                                      org.eclipse.cdt.core.model.ICProject project,
                                      java.lang.String[] includePaths)
Checks whether the given type can be found in the given project or the given include paths.

Parameters:
type - the type
project - the project
includePaths - the include paths
Returns:
true if the given type is found

searchForCppType

public static int searchForCppType(org.eclipse.cdt.core.browser.IQualifiedTypeName typeName,
                                   org.eclipse.cdt.core.model.ICProject project,
                                   java.lang.Class queryType)
Search for the given qualified name of the give

Parameters:
typeName - qualified name of the type to search
project -
queryType - Class of interface type to search for (e.g. ICPPClassType.class)
Returns:
one of SEARCH_MATCH_ERROR, SEARCH_MATCH_FOUND_ANOTHER_NAMESPACE, SEARCH_MATCH_FOUND_ANOTHER_TYPE, SEARCH_MATCH_FOUND_EXACT_ANOTHER_TYPE, SEARCH_MATCH_FOUND_EXACT or SEARCH_MATCH_NOTFOUND.