[Title] JSDT : Missing path in Adv. Declaration View is fixed.
authorJaeheung Kim <jaeheung.kim@samsung.com>
Fri, 21 Dec 2012 01:27:50 +0000 (10:27 +0900)
committerhyukmin kwon <hyukmin0530.kwon@samsung.com>
Fri, 28 Dec 2012 09:00:45 +0000 (18:00 +0900)
[Desc.] Appends missing paths if the resource type of PackageFragmentRoot is IProject.
[Issue] REDMINE-7482
Change-Id: Iab88b8cfa6f8102885f48d54b66cff5f6dda3be0

org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/ui/JavaScriptElementLabels.java

index 2b4caf9..fa1fed6 100644 (file)
@@ -472,6 +472,89 @@ public class JavaScriptElementLabels {
                        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.