org.eclipse.wst.jsdt.ui

## Class JavaScriptElementLabels

- java.lang.Object
- - org.eclipse.wst.jsdt.ui.JavaScriptElementLabels

    public class JavaScriptElementLabels
    extends java.lang.Object

`JavaScriptElementLabels` provides helper methods to render names of JavaScript elements. Provisional API: This class/interface is part of an interim API that is still under development and expected to change significantly before reaching stability. It is being made available at this early stage to solicit feedback from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken (repeatedly) as the API evolves.

### Field Summary

Fields
`static long` `ALL_CATEGORY` Show category for all elements.
`static long` `ALL_DEFAULT` Default options (M_PARAMETER_TYPES, M_APP_TYPE_PARAMETERS & T_TYPE_PARAMETERS enabled)
`static long` `ALL_FULLY_QUALIFIED` Qualify all elements
`static long` `ALL_POST_QUALIFIED` Post qualify all elements
`static long` `APPEND_ROOT_PATH` Add root path to all elements except Package Fragment Roots and JavaScript projects.
`static long` `CF_POST_QUALIFIED` Class file names are post qualified.
`static long` `CF_QUALIFIED` Class file names are fully qualified.
`static java.lang.String` `COMMA_STRING` User-readable string for separating list items (e.g. ", ").
`static java.lang.String` `CONCAT_STRING` User-readable string for separating post qualified names (e.g. " - ").
`static long` `CU_POST_QUALIFIED` Compilation unit names are post qualified.
`static long` `CU_QUALIFIED` Compilation unit names are fully qualified.
`static long` `D_POST_QUALIFIED` Declarations (import container / declaration, package declaration) are post qualified.
`static long` `D_QUALIFIED` Declarations (import container / declaration, package declaration) are qualified.
`static java.lang.String` `DECL_STRING` User-readable string for separating the return type (e.g. " : ").
`static java.lang.String` `DEFAULT_PACKAGE` User-readable string for the default package name (e.g.
`static long` `DEFAULT_POST_QUALIFIED` Default post qualify options (All except Root and Package)
`static long` `DEFAULT_QUALIFIED` Default qualify options (All except Root and Package)
`static java.lang.String` `ELLIPSIS_STRING` User-readable string for ellipsis ("...").
`static long` `F_APP_TYPE_SIGNATURE` Field names contain the declared type (appended) e.g.
`static long` `F_CATEGORY` Prepend first category (if any) to field.
`static long` `F_FULLY_QUALIFIED` Fields names are fully qualified.
`static long` `F_POST_QUALIFIED` Fields names are post qualified.
`static long` `F_PRE_TYPE_SIGNATURE` Field names contain the declared type (prepended) e.g.
`static long` `I_FULLY_QUALIFIED` Initializer names are fully qualified.
`static long` `I_POST_QUALIFIED` Type names are post qualified.
`static long` `M_APP_RETURNTYPE` Method names contain return type (appended) e.g.
`static long` `M_APP_TYPE_PARAMETERS` Method names contain type parameters appended.
`static long` `M_CATEGORY` Prepend first category (if any) to method.
`static long` `M_EXCEPTIONS` Method names contain thrown exceptions.
`static long` `M_FULLY_QUALIFIED` Method names are fully qualified.
`static long` `M_PARAMETER_NAMES` Method names contain parameter names.
`static long` `M_PARAMETER_TYPES` Method names contain parameter types.
`static long` `M_POST_QUALIFIED` Method names are post qualified.
`static long` `M_PRE_RETURNTYPE` Method names contain return type (appended) e.g.
`static long` `M_PRE_TYPE_PARAMETERS` Method names contain type parameters prepended.
`static long` `P_COMPRESSED` Package names are compressed.
`static long` `P_POST_QUALIFIED` Package names are post qualified.
`static long` `P_QUALIFIED` Package names are qualified.
`static long` `PREPEND_ROOT_PATH` Add root path to all elements except Package Fragment Roots and JavaScript projects.
`static long` `REFERENCED_ROOT_POST_QUALIFIED` Post qualify referenced package fragment roots.
`static long` `ROOT_POST_QUALIFIED` Package Fragment Roots contain the project name if not an archive (appended).
`static long` `ROOT_QUALIFIED` Package Fragment Roots contain the project name if not an archive (prepended).
`static long` `ROOT_VARIABLE` Package Fragment Roots contain variable name if from a variable.
`static long` `SHOW_TYPE` Deprecated. no longer used
`static long` `T_CATEGORY` Prepend first category (if any) to type.
`static long` `T_CONTAINER_QUALIFIED` Type names are type container qualified.
`static long` `T_FULLY_QUALIFIED` Type names are fully qualified.
`static long` `T_POST_QUALIFIED` Type names are post qualified.
`static long` `T_TYPE_PARAMETERS` Type names contain type parameters.
`static long` `USE_RESOLVED` Specified to use the resolved information of a IType, IFunction or IField.

### Method Summary

All Methods Static Methods Concrete Methods
`static void` `getClassFileLabel(IClassFile classFile, long flags, java.lang.StringBuffer buf)` Appends the label for a class file to a `StringBuffer`.
`static void` `getCompilationUnitLabel(IJavaScriptUnit cu, long flags, java.lang.StringBuffer buf)` Appends the label for a compilation unit to a `StringBuffer`.
`static java.lang.String` `getContainerEntryLabel(IPath containerPath, IJavaScriptProject project)` Returns the label of a classpath container
`static void` `getDeclarationLabel(IJavaScriptElement declaration, long flags, java.lang.StringBuffer buf)` Appends the label for a import container, import or package declaration to a `StringBuffer`.
`static java.lang.String` `getElementLabel(IJavaScriptElement element, long flags)` Returns the label for a JavaScript element with the flags as defined by this class.
`static void` `getElementLabel(IJavaScriptElement element, long flags, java.lang.StringBuffer buf)` Returns the label for a JavaScript element with the flags as defined by this class.
`static void` `getFieldLabel(IField field, long flags, java.lang.StringBuffer buf)` Appends the label for a field to a `StringBuffer`.
`static void` `getFileLabel(IMember member, long flags, java.lang.StringBuffer buf)`
`static void` `getInitializerLabel(IInitializer initializer, long flags, java.lang.StringBuffer buf)` Appends the label for a initializer to a `StringBuffer`.
`static void` `getLocalVariableLabel(ILocalVariable localVariable, long flags, java.lang.StringBuffer buf)` Appends the label for a local variable to a `StringBuffer`.
`static void` `getMethodLabel(IFunction method, long flags, java.lang.StringBuffer buf)` Appends the label for a method to a `StringBuffer`.
`static void` `getPackageFragmentLabel(IPackageFragment pack, long flags, java.lang.StringBuffer buf)` Appends the label for a package fragment to a `StringBuffer`.
`static void` `getPackageFragmentRootLabel(IPackageFragmentRoot root, long flags, java.lang.StringBuffer buf)` Appends the label for a package fragment root to a `StringBuffer`.
`static java.lang.String` `getTextLabel(java.lang.Object obj, long flags)` Returns the label of the given object.
`static void` `getTypeLabel(IType type, long flags, java.lang.StringBuffer buf)` Appends the label for a type to a `StringBuffer`.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### M_PARAMETER_TYPES

    public static final long M_PARAMETER_TYPES

Method names contain parameter types. e.g. `foo(int)`

See Also:
  Constant Field Values

#### M_PARAMETER_NAMES

    public static final long M_PARAMETER_NAMES

Method names contain parameter names. e.g. `foo(index)`

See Also:
  Constant Field Values

#### M_PRE_TYPE_PARAMETERS

    public static final long M_PRE_TYPE_PARAMETERS

Method names contain type parameters prepended. e.g. `<A> foo(A index)`

See Also:
  Constant Field Values

#### M_APP_TYPE_PARAMETERS

    public static final long M_APP_TYPE_PARAMETERS

Method names contain type parameters appended. e.g. `foo(A index) <A>`

See Also:
  Constant Field Values

#### M_EXCEPTIONS

    public static final long M_EXCEPTIONS

Method names contain thrown exceptions. e.g. `foo throws IOException`

See Also:
  Constant Field Values

#### M_APP_RETURNTYPE

    public static final long M_APP_RETURNTYPE

Method names contain return type (appended) e.g. `foo : int`

See Also:
  Constant Field Values

#### M_PRE_RETURNTYPE

    public static final long M_PRE_RETURNTYPE

Method names contain return type (appended) e.g. `int foo`

See Also:
  Constant Field Values

#### M_FULLY_QUALIFIED

    public static final long M_FULLY_QUALIFIED

Method names are fully qualified. e.g. `java.util.Vector.size`

See Also:
  Constant Field Values

#### M_POST_QUALIFIED

    public static final long M_POST_QUALIFIED

Method names are post qualified. e.g. `size - java.util.Vector`

See Also:
  Constant Field Values

#### I_FULLY_QUALIFIED

    public static final long I_FULLY_QUALIFIED

Initializer names are fully qualified. e.g. `java.util.Vector.{ ... }`

See Also:
  Constant Field Values

#### I_POST_QUALIFIED

    public static final long I_POST_QUALIFIED

Type names are post qualified. e.g. `{ ... } - java.util.Map`

See Also:
  Constant Field Values

#### F_APP_TYPE_SIGNATURE

    public static final long F_APP_TYPE_SIGNATURE

Field names contain the declared type (appended) e.g. `fHello : int`

See Also:
  Constant Field Values

#### F_PRE_TYPE_SIGNATURE

    public static final long F_PRE_TYPE_SIGNATURE

Field names contain the declared type (prepended) e.g. `int fHello`

See Also:
  Constant Field Values

#### F_FULLY_QUALIFIED

    public static final long F_FULLY_QUALIFIED

Fields names are fully qualified. e.g. `java.lang.System.out`

See Also:
  Constant Field Values

#### F_POST_QUALIFIED

    public static final long F_POST_QUALIFIED

Fields names are post qualified. e.g. `out - java.lang.System`

See Also:
  Constant Field Values

#### T_FULLY_QUALIFIED

    public static final long T_FULLY_QUALIFIED

Type names are fully qualified. e.g. `java.util.Map.MapEntry`

See Also:
  Constant Field Values

#### T_CONTAINER_QUALIFIED

    public static final long T_CONTAINER_QUALIFIED

Type names are type container qualified. e.g. `Map.MapEntry`

See Also:
  Constant Field Values

#### T_POST_QUALIFIED

    public static final long T_POST_QUALIFIED

Type names are post qualified. e.g. `MapEntry - java.util.Map`

See Also:
  Constant Field Values

#### T_TYPE_PARAMETERS

    public static final long T_TYPE_PARAMETERS

Type names contain type parameters. e.g. `Map<S, T>`

See Also:
  Constant Field Values

#### D_QUALIFIED

    public static final long D_QUALIFIED

Declarations (import container / declaration, package declaration) are qualified. e.g. `java.util.Vector.class/import container`

See Also:
  Constant Field Values

#### D_POST_QUALIFIED

    public static final long D_POST_QUALIFIED

Declarations (import container / declaration, package declaration) are post qualified. e.g. `import container - java.util.Vector.class`

See Also:
  Constant Field Values

#### CF_QUALIFIED

    public static final long CF_QUALIFIED

Class file names are fully qualified. e.g. `java.util.Vector.class`

See Also:
  Constant Field Values

#### CF_POST_QUALIFIED

    public static final long CF_POST_QUALIFIED

Class file names are post qualified. e.g. `Vector.class - java.util`

See Also:
  Constant Field Values

#### CU_QUALIFIED

    public static final long CU_QUALIFIED

Compilation unit names are fully qualified. e.g. `java.util.Vector.java`

See Also:
  Constant Field Values

#### CU_POST_QUALIFIED

    public static final long CU_POST_QUALIFIED

Compilation unit names are post qualified. e.g. `Vector.JavaScript - java.util`

See Also:
  Constant Field Values

#### P_QUALIFIED

    public static final long P_QUALIFIED

Package names are qualified. e.g. `MyProject/src/java.util`

See Also:
  Constant Field Values

#### P_POST_QUALIFIED

    public static final long P_POST_QUALIFIED

Package names are post qualified. e.g. `java.util - MyProject/src`

See Also:
  Constant Field Values

#### P_COMPRESSED

    public static final long P_COMPRESSED

Package names are compressed. e.g. `o*.e*.search`

See Also:
  Constant Field Values

#### ROOT_VARIABLE

    public static final long ROOT_VARIABLE

Package Fragment Roots contain variable name if from a variable. e.g. `JRE_LIB - c:\java\lib\rt.jar`

See Also:
  Constant Field Values

#### ROOT_QUALIFIED

    public static final long ROOT_QUALIFIED

Package Fragment Roots contain the project name if not an archive (prepended). e.g. `MyProject/src`

See Also:
  Constant Field Values

#### ROOT_POST_QUALIFIED

    public static final long ROOT_POST_QUALIFIED

Package Fragment Roots contain the project name if not an archive (appended). e.g. `src - MyProject`

See Also:
  Constant Field Values

#### APPEND_ROOT_PATH

    public static final long APPEND_ROOT_PATH

Add root path to all elements except Package Fragment Roots and JavaScript projects. e.g. `java.lang.Vector - c:\java\lib\rt.jar` Option only applies to getElementLabel

See Also:
  Constant Field Values

#### PREPEND_ROOT_PATH

    public static final long PREPEND_ROOT_PATH

Add root path to all elements except Package Fragment Roots and JavaScript projects. e.g. `java.lang.Vector - c:\java\lib\rt.jar` Option only applies to getElementLabel

See Also:
  Constant Field Values

#### REFERENCED_ROOT_POST_QUALIFIED

    public static final long REFERENCED_ROOT_POST_QUALIFIED

Post qualify referenced package fragment roots. For example `jdt.jar - org.eclipse.wst.jsdt.ui` if the jar is referenced from another project.

See Also:
  Constant Field Values

#### USE_RESOLVED

    public static final long USE_RESOLVED

Specified to use the resolved information of a IType, IFunction or IField. See `IType.isResolved()`. If resolved information is available, types will be rendered with type parameters of the instantiated type. Resolved method render with the parameter types of the method instance. `Vector<String>.get(String)`

See Also:
  Constant Field Values

#### F_CATEGORY

    public static final long F_CATEGORY

Prepend first category (if any) to field.

See Also:
  Constant Field Values

#### M_CATEGORY

    public static final long M_CATEGORY

Prepend first category (if any) to method.

See Also:
  Constant Field Values

#### T_CATEGORY

    public static final long T_CATEGORY

Prepend first category (if any) to type.

See Also:
  Constant Field Values

#### SHOW_TYPE

    public static final long SHOW_TYPE

Deprecated. no longer used

See Also:
  Constant Field Values

#### ALL_CATEGORY

    public static final long ALL_CATEGORY

Show category for all elements.

See Also:
  Constant Field Values

#### ALL_FULLY_QUALIFIED

    public static final long ALL_FULLY_QUALIFIED

Qualify all elements

See Also:
  Constant Field Values

#### ALL_POST_QUALIFIED

    public static final long ALL_POST_QUALIFIED

Post qualify all elements

See Also:
  Constant Field Values

#### ALL_DEFAULT

    public static final long ALL_DEFAULT

Default options (M_PARAMETER_TYPES, M_APP_TYPE_PARAMETERS & T_TYPE_PARAMETERS enabled)

See Also:
  Constant Field Values

#### DEFAULT_QUALIFIED

    public static final long DEFAULT_QUALIFIED

Default qualify options (All except Root and Package)

See Also:
  Constant Field Values

#### DEFAULT_POST_QUALIFIED

    public static final long DEFAULT_POST_QUALIFIED

Default post qualify options (All except Root and Package)

See Also:
  Constant Field Values

#### CONCAT_STRING

    public static final java.lang.String CONCAT_STRING

User-readable string for separating post qualified names (e.g. " - ").

#### COMMA_STRING

    public static final java.lang.String COMMA_STRING

User-readable string for separating list items (e.g. ", ").

#### DECL_STRING

    public static final java.lang.String DECL_STRING

User-readable string for separating the return type (e.g. " : ").

#### ELLIPSIS_STRING

    public static final java.lang.String ELLIPSIS_STRING

User-readable string for ellipsis ("...").

See Also:
  Constant Field Values

#### DEFAULT_PACKAGE

    public static final java.lang.String DEFAULT_PACKAGE

User-readable string for the default package name (e.g. "(default package)").

### Method Detail

#### getTextLabel

    public static java.lang.String getTextLabel(java.lang.Object obj,
                                                long flags)

Returns the label of the given object. The object must be of type `IJavaScriptElement` or adapt to `IWorkbenchAdapter`. The empty string is returned if the element type is not known.

Parameters:
  `obj` - Object to get the label from.
  `flags` - The rendering flags
Returns:
  Returns the label or the empty string if the object type is not supported.

#### getElementLabel

    public static java.lang.String getElementLabel(IJavaScriptElement element,
                                                   long flags)

Returns the label for a JavaScript element with the flags as defined by this class.

Parameters:
  `element` - The element to render.
  `flags` - The rendering flags.
Returns:
  the label of the JavaScript element

#### getElementLabel

    public static void getElementLabel(IJavaScriptElement element,
                                       long flags,
                                       java.lang.StringBuffer buf)

Returns the label for a JavaScript element with the flags as defined by this class.

Parameters:
  `element` - The element to render.
  `flags` - The rendering flags.
  `buf` - The buffer to append the resulting label to.

#### getMethodLabel

    public static void getMethodLabel(IFunction method,
                                      long flags,
                                      java.lang.StringBuffer buf)

Appends the label for a method to a `StringBuffer`. Considers the M_* flags.

Parameters:
  `method` - The element to render.
  `flags` - The rendering flags. Flags with names starting with 'M_' are considered.
  `buf` - The buffer to append the resulting label to.

#### getFieldLabel

    public static void getFieldLabel(IField field,
                                     long flags,
                                     java.lang.StringBuffer buf)

Appends the label for a field to a `StringBuffer`. Considers the F_* flags.

Parameters:
  `field` - The element to render.
  `flags` - The rendering flags. Flags with names starting with 'F_' are considered.
  `buf` - The buffer to append the resulting label to.

#### getLocalVariableLabel

    public static void getLocalVariableLabel(ILocalVariable localVariable,
                                             long flags,
                                             java.lang.StringBuffer buf)

Appends the label for a local variable to a `StringBuffer`.

Parameters:
  `localVariable` - The element to render.
  `flags` - The rendering flags. Flags with names starting with 'F_' are considered.
  `buf` - The buffer to append the resulting label to.

#### getInitializerLabel

    public static void getInitializerLabel(IInitializer initializer,
                                           long flags,
                                           java.lang.StringBuffer buf)

Appends the label for a initializer to a `StringBuffer`. Considers the I_* flags.

Parameters:
  `initializer` - The element to render.
  `flags` - The rendering flags. Flags with names starting with 'I_' are considered.
  `buf` - The buffer to append the resulting label to.

#### getTypeLabel

    public static void getTypeLabel(IType type,
                                    long flags,
                                    java.lang.StringBuffer buf)

Appends the label for a type to a `StringBuffer`. Considers the T_* flags.

Parameters:
  `type` - The element to render.
  `flags` - The rendering flags. Flags with names starting with 'T_' are considered.
  `buf` - The buffer to append the resulting label to.

#### getDeclarationLabel

    public static void getDeclarationLabel(IJavaScriptElement declaration,
                                           long flags,
                                           java.lang.StringBuffer buf)

Appends the label for a import container, import or package declaration to a `StringBuffer`. Considers the D_* flags.

Parameters:
  `declaration` - The element to render.
  `flags` - The rendering flags. Flags with names starting with 'D_' are considered.
  `buf` - The buffer to append the resulting label to.

#### getClassFileLabel

    public static void getClassFileLabel(IClassFile classFile,
                                         long flags,
                                         java.lang.StringBuffer buf)

Appends the label for a class file to a `StringBuffer`. Considers the CF_* flags.

Parameters:
  `classFile` - The element to render.
  `flags` - The rendering flags. Flags with names starting with 'CF_' are considered.
  `buf` - The buffer to append the resulting label to.

#### getCompilationUnitLabel

    public static void getCompilationUnitLabel(IJavaScriptUnit cu,
                                               long flags,
                                               java.lang.StringBuffer buf)

Appends the label for a compilation unit to a `StringBuffer`. Considers the CU_* flags.

Parameters:
  `cu` - The element to render.
  `flags` - The rendering flags. Flags with names starting with 'CU_' are considered.
  `buf` - The buffer to append the resulting label to.

#### getFileLabel

    public static void getFileLabel(IMember member,
                                    long flags,
                                    java.lang.StringBuffer buf)

#### getPackageFragmentLabel

    public static void getPackageFragmentLabel(IPackageFragment pack,
                                               long flags,
                                               java.lang.StringBuffer buf)

Appends the label for a package fragment to a `StringBuffer`. Considers the P_* flags.

Parameters:
  `pack` - The element to render.
  `flags` - The rendering flags. Flags with names starting with P_' are considered.
  `buf` - The buffer to append the resulting label to.

#### getPackageFragmentRootLabel

    public static void getPackageFragmentRootLabel(IPackageFragmentRoot root,
                                                   long flags,
                                                   java.lang.StringBuffer buf)

Appends the label for a package fragment root to a `StringBuffer`. Considers the ROOT_* flags.

Parameters:
  `root` - The element to render.
  `flags` - The rendering flags. Flags with names starting with ROOT_' are considered.
  `buf` - The buffer to append the resulting label to.

#### getContainerEntryLabel

    public static java.lang.String getContainerEntryLabel(IPath containerPath,
                                                          IJavaScriptProject project)
                                                   throws JavaScriptModelException

Returns the label of a classpath container

Parameters:
  `containerPath` - The path of the container.
  `project` - The project the container is resolved in.
Returns:
  Returns the label of the classpath container
Throws:
  `JavaScriptModelException` - Thrown when the resolving of the container failed.