add class for annotations / registering methods, etc? class Interface should move the whole context-thingie right into scope
329276
function Scope(node,parent){
	this._nr = STACK.incr('scopes');
	this._head = [];
	this._node = node;
	this._parent = parent;
	this._vars = new VariableDeclaration([]);
	this._meta = {};
	this._annotations = [];
	this._closure = this;
	this._virtual = false;
	this._counter = 0;
	this._varmap = {};
	this._counters = {};
	this._varpool = [];
	this.setup();
}
1357659
public AnnotatedTypeBuilder<X> addToMethod(Method method, Annotation annotation) {
       if (methods.get(method) == null) {
           methods.put(method, new AnnotationBuilder());
       }
       methods.get(method).add(annotation);
       return this;
   }
215787
private function registerAnnotation($class)
    {
        /** @var CustomField $annotation */
        if ($annotation = $this->annotationReader->getClassAnnotation(
            new \ReflectionClass($class),
            'Lullabot\Mpx\DataService\Annotation\CustomField'
        )) {
            if (!is_subclass_of($class, CustomFieldInterface::class)) {
                throw new \RuntimeException(sprintf('%s must implement %s.', $class, CustomFieldInterface::class));
            }

            $this->customFields[$annotation->service][$annotation->objectType][$annotation->namespace] = new DiscoveredCustomField(
                $class, $annotation
            );
        }
    }
508586
public AnnotationEntityDataModelFactory addClass(Class<?> cls) {
        EdmEntity entityAnnotation = cls.getAnnotation(EdmEntity.class);
        EdmComplex complexAnnotation = cls.getAnnotation(EdmComplex.class);
        EdmFunction functionAnnotation = cls.getAnnotation(EdmFunction.class);
        EdmFunctionImport functionImportAnnotation = cls.getAnnotation(EdmFunctionImport.class);
        EdmAction actionAnnotation = cls.getAnnotation(EdmAction.class);
        EdmActionImport actionImportAnnotation = cls.getAnnotation(EdmActionImport.class);
        EdmEnum enumAnnotation = cls.getAnnotation(EdmEnum.class);

        Set<Annotation> annotations = new HashSet<>();

        annotations.add(entityAnnotation);
        annotations.add(complexAnnotation);
        annotations.add(functionAnnotation);
        annotations.add(functionImportAnnotation);
        annotations.add(actionAnnotation);
        annotations.add(actionImportAnnotation);
        annotations.add(enumAnnotation);

        checkClassPrecondition(annotations, cls);

        if (entityAnnotation != null) {
            entityClasses.add(cls);
        } else if (complexAnnotation != null) {
            complexClasses.add(cls);
        } else if (functionAnnotation != null) {
            functionClasses.add(cls);
        } else if (functionImportAnnotation != null) {
            functionImportClasses.add(cls);
        } else if (actionAnnotation != null) {
            actionClasses.add(cls);
        } else if (actionImportAnnotation != null) {
            actionImportClasses.add(cls);
        } else if (enumAnnotation != null) {
            if (!cls.isEnum()) {
                throw new IllegalArgumentException("The EdmEnum annotation must only be used on enum classes: " +
                        cls.getName());
            }
            enumClasses.add(cls);
        }
        return this;
    }
576864
def register(cls, instance_class, name=None):
        
        if name is None:
            name = instance_class.__name__
        cls.INSTANCE_CLASSES[name] = instance_class
829740
public void addScopeBindings(Map<Class<? extends Annotation>, Scope> bindings) {
        if (scopeCleaner.isRunning()) {
            scopeBindings.putAll(bindings);
        }
    }
963603
def register_named_scope! # :nodoc
      @klass.define_singleton_method(:search_for) do |query = '', options = {}|
        # klass may be different to @klass if the scope is called on a subclass
        klass = self
        definition = klass.scoped_search_definition

        search_scope = klass.all
        find_options = ScopedSearch::QueryBuilder.build_query(definition, query || '', options)
        search_scope = search_scope.where(find_options[:conditions])   if find_options[:conditions]
        search_scope = search_scope.includes(find_options[:include])   if find_options[:include]
        search_scope = search_scope.joins(find_options[:joins])        if find_options[:joins]
        search_scope = search_scope.reorder(find_options[:order])      if find_options[:order]
        search_scope = search_scope.references(find_options[:include]) if find_options[:include]

        search_scope
      end
    end
267364
def register(self, obj, autogenerate=False):
        
        scope = self._scope

        # register a module
        if type(obj).__name__ == 'module':
            for key, value in vars(obj).items():
                # register a climethod
                if isinstance(value, climethod):
                    value.interface = self
                    scope[key] = value

                # register a function
                elif inspect.isfunction(value) and autogenerate:
                    meth = climethod(value)
                    meth.interface = self
                    scope[key] = meth

        # register a climethod
        elif isinstance(obj, climethod):
            obj.interface = self
            scope[obj.__name__] = obj

        # register a function
        elif inspect.isfunction(obj) and autogenerate:
            meth = climethod(obj)
            meth.interface = self
            scope[meth.__name__] = meth
606214
private void registerControllerMethods(Map<Method, Class<? extends Annotation>> discoveredMethods) {

        Collection<Method> methods = sortMethods(discoveredMethods.keySet());

        Map<Class<? extends Controller>, Set<String>> controllers = new HashMap<>();
        for (Method method : methods) {
            Class<? extends Controller> controllerClass = (Class<? extends Controller>) method.getDeclaringClass();
            if (!controllers.containsKey(controllerClass)) {
                Set<String> paths = collectPaths(controllerClass);
                controllers.put(controllerClass, paths);
            }

            Class<? extends Annotation> httpMethodAnnotationClass = discoveredMethods.get(method);
            Annotation httpMethodAnnotation = method.getAnnotation(httpMethodAnnotationClass);

            String httpMethod = httpMethodAnnotation.annotationType().getAnnotation(HttpMethod.class).value();
            String[] methodPaths = ClassUtil.executeDeclaredMethod(httpMethodAnnotation, "value");

            Set<String> controllerPaths = controllers.get(controllerClass);
            if (controllerPaths.isEmpty()) {
                // add an empty string to allow controllerPaths iteration
                controllerPaths.add("");
            }

            for (String controllerPath : controllerPaths) {

                if (methodPaths.length == 0) {
                    // method does not specify a path, inherit from controller
                    String fullPath = StringUtils.addStart(StringUtils.removeEnd(controllerPath, "/"), "/");
                    ControllerHandler handler = new ControllerHandler(injector, controllerClass, method.getName());
                    handler.validateMethodArgs(fullPath);

                    RouteRegistration registration = new RouteRegistration(httpMethod, fullPath, handler);
                    configureRegistration(registration, method);
                    routeRegistrations.add(registration);
                } else {
                    // method specifies one or more paths, concatenate with controller paths
                    for (String methodPath : methodPaths) {
                        String path = Joiner.on("/").skipNulls().join(StringUtils.removeEnd(controllerPath, "/"), StringUtils.removeStart(methodPath, "/"));
                        String fullPath = StringUtils.addStart(StringUtils.removeEnd(path, "/"), "/");

                        ControllerHandler handler = new ControllerHandler(injector, controllerClass, method.getName());
                        handler.validateMethodArgs(fullPath);

                        RouteRegistration registration = new RouteRegistration(httpMethod, fullPath, handler);
                        configureRegistration(registration, method);
                        routeRegistrations.add(registration);
                    }
                }

            }

        }
    }
672472
public <T> RestBuilder addProvider(Class<T> clazz, Class<? extends ContextProvider<T>> provider) {

		Assert.notNull(clazz, "Missing provided class type!");
		Assert.notNull(provider, "Missing context provider!");
		registeredProviders.put(clazz, provider);
		return this;
	}
866140
def class_register(cls):
    """"""
    cls.handler_registry = {}
    for method_name in dir(cls):
        method = getattr(cls, method_name)
        if hasattr(method, '_handle'):
            cls.handler_registry.update({method._handle: method_name})
    return cls
38529
protected static <T extends Annotation> T getAnnotationFromContext(InvocationContext context, Class<T> clazz) {
        T result = context.getMethod().getAnnotation(clazz);
        return result != null ? result : context.getTarget().getClass().getAnnotation(clazz);
    }
66141
def add_page(self, pattern, classname):
        
        if not self._loaded:
            raise PluginManagerNotLoadedException()
        self._app.add_mapping(pattern, classname)
306043
def add_scope(self, scope_type, scope_name, scope_start, is_method=False):
        """"""
        if self._curr is not None:
            self._curr['end'] = scope_start - 1  # close last scope
        self._curr = {
            'type': scope_type, 'name': scope_name,
            'start': scope_start, 'end': scope_start
        }

        if is_method and self._positions:
            last = self._positions[-1]
            if not 'methods' in last:
                last['methods'] = []
            last['methods'].append(self._curr)
        else:
            self._positions.append(self._curr)
1010879
@Override
    public void visitClassContext(ClassContext classContext) {
        try {
            JavaClass cls = classContext.getJavaClass();
            if ((serializableClass != null) && (cls.implementationOf(serializableClass))) {
                Field[] fields = cls.getFields();
                setupVisitorForClass(cls);
                for (Field f : fields) {
                    if (!f.isStatic() && f.isFinal() && f.isTransient()) {
                        bugReporter.reportBug(new BugInstance(this, BugType.NFF_NON_FUNCTIONAL_FIELD.name(), Priorities.NORMAL_PRIORITY).addClass(this)
                                .addField(cls.getClassName(), f.getName(), f.getSignature(), f.getAccessFlags()));
                    }
                }
            }
        } catch (ClassNotFoundException cnfe) {
            bugReporter.reportMissingClass(cnfe);
        }
    }
783393
public void registerFilters() {
    boolean acceptAllInterfaces = true;

    // if specified, use the given annotation and / or marker interface
    if (this.annotationClass != null) {
      addIncludeFilter(new AnnotationTypeFilter(this.annotationClass));
      acceptAllInterfaces = false;
    }

    // override AssignableTypeFilter to ignore matches on the actual marker interface
    if (this.markerInterface != null) {
      addIncludeFilter(new AssignableTypeFilter(this.markerInterface) {
        @Override
        protected boolean matchClassName(String className) {
          return false;
        }
      });
      acceptAllInterfaces = false;
    }

    if (acceptAllInterfaces) {
      // default include filter that accepts all classes
      addIncludeFilter(new TypeFilter() {
        public boolean match(MetadataReader metadataReader, MetadataReaderFactory metadataReaderFactory) throws IOException {
          return true;
        }
      });
    }

    // exclude package-info.java
    addExcludeFilter(new TypeFilter() {
      public boolean match(MetadataReader metadataReader, MetadataReaderFactory metadataReaderFactory) throws IOException {
        String className = metadataReader.getClassMetadata().getClassName();
        return className.endsWith("package-info");
      }
    });
  }
1328722
def add_method(self, m, **kwargs):
        
        if isinstance(m, types.FunctionType):
            self['function', id(m)] = m
        else:
            f, obj = get_method_vars(m)
            wrkey = (f, id(obj))
            self[wrkey] = obj