/*
 * Copyright 2013, Bruce Mitchener, Jr.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.dylanfoundry.deft.filetypes.dylan.psi.impl;

import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElement;
import com.intellij.psi.util.PsiElementFilter;
import com.intellij.psi.util.PsiTreeUtil;
import org.dylanfoundry.deft.filetypes.dylan.psi.DylanHeader;
import org.dylanfoundry.deft.filetypes.dylan.psi.DylanHeaderValues;
import org.dylanfoundry.deft.filetypes.dylan.psi.DylanTypes;

public class DylanPsiImplUtil {
    public static String getKey(DylanHeader element) {
      ASTNode keyNode = element.getNode().findChildByType(DylanTypes.KEY);
      if (keyNode != null) {
        return keyNode.getText();
      } else {
        return null;
      }
    }

    public static PsiElement[] getValues(DylanHeaderValues element) {
      return PsiTreeUtil.collectElements(element, new PsiElementFilter() {
        @Override
        public boolean isAccepted(PsiElement e) {
          return (e.getNode().getElementType() == DylanTypes.VALUE);
        }
      });
    }
}

@@ -1035,18 +1035,16 @@
 lUtil %7B%0A
-  
   public
@@ -1084,26 +1084,24 @@
  element) %7B%0A
-  
     ASTNode 
@@ -1165,18 +1165,16 @@
 Y);%0A    
-  
 if (keyN
@@ -1184,26 +1184,24 @@
  != null) %7B%0A
-  
       return
@@ -1224,18 +1224,16 @@
 ();%0A    
-  
 %7D else %7B
@@ -1233,18 +1233,16 @@
  else %7B%0A
-  
       re
@@ -1260,21 +1260,15 @@
     
-  %7D%0A  
+%7D%0A
   %7D%0A%0A
-  
   pu
@@ -1327,26 +1327,24 @@
  element) %7B%0A
-  
     return P
@@ -1410,18 +1410,16 @@
 %7B%0A      
-  
 @Overrid
@@ -1420,18 +1420,16 @@
 verride%0A
-  
       pu
@@ -1472,26 +1472,24 @@
 ) %7B%0A        
-  
 return (e.ge
@@ -1545,22 +1545,18 @@
     
-  %7D%0A  
+%7D%0A
     %7D);%0A
     
@@ -1551,16 +1551,14 @@
     %7D);%0A
-  
   %7D%0A%7D%0A

Fix indentation.