getPackageFragmentRootLabel(root, ROOT_QUALIFIED, buf);
}
}
+
+ /**
+ * Returns the extended label for a JavaScript element with the flags as defined by this class.
+ * @param element The element to render.
+ * @param flags The rendering flags.
+ * @return the label of the JavaScript element
+ */
+ public static String getElementLabelExtend(IJavaScriptElement element, long flags) {
+ StringBuffer buf= new StringBuffer(60);
+ getElementLabelExtend(element, flags, buf);
+ return buf.toString();
+ }
+
+ /**
+ * Returns the extended label for a JavaScript element with the flags as defined by this class.
+ * @param element The element to render.
+ * @param flags The rendering flags.
+ * @param buf The buffer to append the resulting label to.
+ */
+ public static void getElementLabelExtend(IJavaScriptElement element, long flags, StringBuffer buf) {
+ int type= element.getElementType();
+ IPackageFragmentRoot root= null;
+
+ if (type != IJavaScriptElement.JAVASCRIPT_MODEL && type != IJavaScriptElement.JAVASCRIPT_PROJECT && type != IJavaScriptElement.PACKAGE_FRAGMENT_ROOT)
+ root= JavaModelUtil.getPackageFragmentRoot(element);
+ if (root != null && getFlag(flags, PREPEND_ROOT_PATH)) {
+ getPackageFragmentRootLabel(root, ROOT_QUALIFIED, buf);
+ buf.append(CONCAT_STRING);
+ }
+
+ switch (type) {
+ case IJavaScriptElement.METHOD:
+ getMethodLabel((IFunction) element, flags, buf);
+ break;
+ case IJavaScriptElement.FIELD:
+ getFieldLabel((IField) element, flags, buf);
+ break;
+ case IJavaScriptElement.LOCAL_VARIABLE:
+ getLocalVariableLabel((ILocalVariable) element, flags, buf);
+ break;
+ case IJavaScriptElement.INITIALIZER:
+ getInitializerLabel((IInitializer) element, flags, buf);
+ break;
+ case IJavaScriptElement.TYPE:
+ getTypeLabel((IType) element, flags, buf);
+ break;
+ case IJavaScriptElement.CLASS_FILE:
+ getClassFileLabel((IClassFile) element, flags, buf);
+ break;
+ case IJavaScriptElement.JAVASCRIPT_UNIT:
+ getCompilationUnitLabel((IJavaScriptUnit) element, flags, buf);
+ break;
+ case IJavaScriptElement.PACKAGE_FRAGMENT:
+ getPackageFragmentLabel((IPackageFragment) element, flags, buf);
+ break;
+ case IJavaScriptElement.PACKAGE_FRAGMENT_ROOT:
+ getPackageFragmentRootLabel((IPackageFragmentRoot) element, flags, buf);
+ break;
+ case IJavaScriptElement.IMPORT_CONTAINER:
+ case IJavaScriptElement.IMPORT_DECLARATION:
+ getDeclarationLabel(element, flags, buf);
+ break;
+ case IJavaScriptElement.JAVASCRIPT_PROJECT:
+ case IJavaScriptElement.JAVASCRIPT_MODEL:
+ buf.append(element.getDisplayName());
+ break;
+ default:
+ buf.append(element.getDisplayName());
+ }
+
+ if (root != null && getFlag(flags, APPEND_ROOT_PATH)) {
+ buf.append(CONCAT_STRING);
+ getPackageFragmentRootLabel(root, ROOT_QUALIFIED, buf);
+ if(root.getResource() instanceof IProject) {
+ // If the resource type of packageFragmentRoot is IProject then append missing paths
+ IPackageFragment pack = (IPackageFragment) element.getAncestor(IJavaScriptElement.PACKAGE_FRAGMENT);
+ if(pack!=null) {
+ buf.append('/');
+ buf.append(pack.getDisplayName());
+ }
+ }
+ }
+ }
/**
* Appends the label for a method to a {@link StringBuffer}. Considers the M_* flags.