Skip to content
This repository
Browse code

Merge pull request #19 from clanehin/master

Tweaks to outline view.
  • Loading branch information...
commit e2772f7a54926a02cadcf6c1de0790c67d948bc2 2 parents bbe20df + 20b8650
JP Moresmau authored
BIN  net.sf.eclipsefp.haskell.ui/icons/obj16/constructordecl.gif
30 net.sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/internal/views/outline/OutlineCP.java
@@ -6,6 +6,7 @@
6 6 import java.util.List;
7 7 import java.util.Map;
8 8 import net.sf.eclipsefp.haskell.scion.types.OutlineDef;
  9 +import net.sf.eclipsefp.haskell.scion.types.OutlineDef.OutlineDefType;
9 10 import org.eclipse.jface.viewers.ITreeContentProvider;
10 11 import org.eclipse.jface.viewers.Viewer;
11 12
@@ -17,8 +18,35 @@
17 18 public class OutlineCP implements ITreeContentProvider{
18 19 private Map<String,List<OutlineDef>> input;
19 20
  21 + /**
  22 + * For elements that expand into an identically-named single element with an obvious
  23 + * type, we could just expand directly into that child element's children.
  24 + */
  25 + public boolean hasSingularChild( final Object o ){
  26 + if( ((OutlineDef)o).getType() != OutlineDefType.DATA ) {
  27 + return false;
  28 + }
  29 +
  30 + Object[] children = getRawChildren( o );
  31 +
  32 + if( children.length != 1 ) {
  33 + return false;
  34 + }
  35 +
  36 + return ((OutlineDef)children[0]).getType() == OutlineDefType.CONSTRUCTOR &&
  37 + ((OutlineDef)children[0]).getName().equals( ((OutlineDef)o).getName() );
  38 + }
  39 +
20 40 public Object[] getChildren( final Object parentElement ) {
21   - //return input.toArray();
  41 + Object[] result = getRawChildren( parentElement );
  42 + if( hasSingularChild( parentElement ) ) {
  43 + return getChildren( result[0] );
  44 + } else {
  45 + return result;
  46 + }
  47 + }
  48 +
  49 + public Object[] getRawChildren( final Object parentElement ) {
22 50 List<OutlineDef> l=input.get(((OutlineDef )parentElement).getID());
23 51 if (l!=null){
24 52 return l.toArray();
2  ...sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/internal/views/outline/OutlineLabelProvider.java
@@ -25,7 +25,7 @@
25 25 imageKeysByType.put(OutlineDef.OutlineDefType.SYN,IImageNames.TYPE_DECL);
26 26 imageKeysByType.put(OutlineDef.OutlineDefType.INSTANCE,IImageNames.INSTANCE_DECL);
27 27 imageKeysByType.put(OutlineDef.OutlineDefType.FIELD,IImageNames.FIELD_DECL);
28   - imageKeysByType.put(OutlineDef.OutlineDefType.CONSTRUCTOR,IImageNames.DATA_DECL);
  28 + imageKeysByType.put(OutlineDef.OutlineDefType.CONSTRUCTOR,IImageNames.CONSTRUCTOR_DECL);
29 29 }
30 30
31 31
1  net.sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/util/HaskellUIImages.java
@@ -91,6 +91,7 @@ private static void declareImages() {
91 91 declare( FUNCTION_BINDING, OBJECT + "functionbinding.gif" ); //$NON-NLS-1$
92 92 declare( PATTERN_BINDING, OBJECT + "patternbinding.gif" ); //$NON-NLS-1$
93 93 declare( DATA_DECL, OBJECT + "datadecl.gif" ); //$NON-NLS-1$
  94 + declare( CONSTRUCTOR_DECL, OBJECT + "constructordecl.gif" ); //$NON-NLS-1$
94 95 declare( TYPE_DECL, OBJECT + "typedecl.gif" ); //$NON-NLS-1$
95 96 declare( NEWTYPE_DECL, OBJECT + "typedecl.gif" ); //$NON-NLS-1$
96 97 declare( TYPE_SIGNATURE, OBJECT + "typesig.gif" ); //$NON-NLS-1$
1  net.sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/util/IImageNames.java
@@ -48,6 +48,7 @@
48 48 String FUNCTION_BINDING = ID + ".FUNCTION_BINDING"; //$NON-NLS-1$
49 49 String PATTERN_BINDING = ID + ".PATTERN_BINDING"; //$NON-NLS-1$
50 50 String DATA_DECL = ID + ".DATA_DECL"; //$NON-NLS-1$
  51 + String CONSTRUCTOR_DECL = ID + ".CONSTRUCTOR_DECL"; //$NON-NLS-1$
51 52 String TYPE_SIGNATURE = ID + ".TYPE_SIGNATURE"; //$NON-NLS-1$
52 53 String TYPE_DECL = ID + ".TYPE_DECL"; //$NON-NLS-1$
53 54 String NEWTYPE_DECL = ID + ".NEWTYPE_DECL"; //$NON-NLS-1$

0 comments on commit e2772f7

Please sign in to comment.
Something went wrong with that request. Please try again.