All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.fulib.scenarios.ast.scope.PatternReferenceCollectingScope Maven / Gradle / Ivy

The newest version!
package org.fulib.scenarios.ast.scope;

import org.fulib.scenarios.ast.decl.Decl;
import org.fulib.scenarios.ast.decl.VarDecl;
import org.fulib.scenarios.ast.pattern.Pattern;

import java.util.Set;

public class PatternReferenceCollectingScope extends DelegatingScope
{
   private final Set patterns;

   public PatternReferenceCollectingScope(Scope outer, Set patterns)
   {
      super(outer);
      this.patterns = patterns;
   }

   @Override
   public Decl resolve(String name)
   {
      final Decl result = super.resolve(name);
      if (result instanceof VarDecl)
      {
         final Pattern pattern = ((VarDecl) result).getPattern();
         if (pattern != null)
         {
            this.patterns.add(pattern);
         }
      }
      return result;
   }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy