# Path: omelette/compiler/code.py
# class Code(object):
#     """Class representing the code divided into objects."""
# 
#     def __init__(self, code=""):
#         self.__objects = [_CodeObject(-1, "")]
#         self.__lexer = Lexer()
# 
#         lines = code.split("\n") if code else []
# 
#         for number, line in enumerate(lines):
#             self.insert_line(number, line)
# 
#     def objects(self, condition=None):
#         return filter(condition, self.__objects)
# 
#     def __is_header(self, line):
#         try:
#             header = self.__lexer["header"] + StringEnd()
#             header.parseString(line)
#             return True
#         except ParseException:
#             return False
# 
#     def __shift(self, position, offset):
#         for object in self.objects(_after(position)):
#             object.position += offset
# 
#     def insert_line(self, number, line):
#         self.__shift(number, 1)
# 
#         if self.__is_header(line):
#             object = _CodeObject(number, line)
# 
#             previous = self.objects(_before(number))[-1]
#             previous.transfer_lines(object, number)
# 
#             self.__objects.append(object)
#             self.__objects.sort()
#         else:
#             object = self.objects(_before(number))[-1]
#             object.insert_line(number, line)
# 
#     def update_line(self, number, line):
#         object = self.objects(_before(number))[-1]
#         updated_line = object.lines[number - object.position]
# 
#         if self.__is_header(line) == self.__is_header(updated_line):
#             object.update_line(number, line)
#         else:
#             self.remove_line(number)
#             self.insert_line(number, line)
# 
#     def remove_line(self, number):
#         object = self.objects(_before(number))[-1]
#         object.remove_line(number)
# 
#         if object.position == number:
#             previous = self.objects(_before(number))[-2]
#             object.transfer_lines(previous, number)
# 
#             self.__objects.remove(object)
# 
#         self.__shift(number, -1)
# 
# Path: omelette/compiler/compiler.py
# class Compiler(object):
# 
#     def __init__(self, libraries=[]):
#         self.__library_uml_objects = {}
#         self.__uml_objects = {}
# 
#         self.__parser = Parser()
#         self.__resolver = DependencyResolver(self.__uml_objects)
# 
#         for library in libraries:
#             self.compile(library)
# 
#     def compile(self, code):
#         code_objects = code.objects(lambda o: o.modified)
#         uml_objects = self.__parser.parse(code_objects)
# 
#         for code_object in code_objects:
#             code_object.modified = False
# 
#         if isinstance(code, Library):
#             self.__library_uml_objects.update(uml_objects)
# 
#         self.__uml_objects.update(uml_objects)
#         self.__resolver.resolve()
# 
#         for name, uml_object in uml_objects.items():
#             if uml_object.is_prototype:
#                 del uml_objects[name]
# 
#         Validator(uml_objects).validate()
# 
#         return uml_objects
# 
#     def clear(self):
#         self.__uml_objects.clear()
#         self.__uml_objects.update(self.__library_uml_objects)
# 
# Path: omelette/compiler/logging.py
# def getLogger(name):
#     def __init__(self):
#     def info(self, msg, object=None):
#     def warning(self, msg, object=None):
#     def error(self, msg, object=None):
#     def critical(self, msg, object=None):
#     def flush(self):
#     def is_empty(self):
#     def get_events(self, levels="INFO WARNING ERROR CRITICAL"):
#     def has(self, level):
#     def __init__(self, msg, level, object):
#     def __str__(self):
# class Logger:
# class Event:


import unittest
from omelette.compiler.code import Code
from omelette.compiler.compiler import Compiler
from omelette.compiler import logging

        result = instance.compile(code)

        self.assertEquals(len(result), 2)
        self.assertEquals(len(result["Student"].attributes()), 1)
        self.assertEquals(len(result["Student"].operations()), 1)

    def test_compile_modified_object(self):
        instance = Compiler()
        code = Code("""base class
            class Student
            class University""")

        instance.compile(code)

        code.insert_line(2, "   - name : String")
        result = instance.compile(code)

        self.assertEquals(len(result), 1)
        self.assertEquals(len(result["Student"].attributes()), 1)

    def test_compile_library(self):
        instance = Compiler([Code("base class")])
        result = instance.compile(Code("class Student"))

        self.assertTrue("Student" in result)
        self.assertEquals(result["Student"].type, "class")

    def test_compile_prototype(self):
        instance = Compiler()

# Path: omelette/compiler/code.py
# class Code(object):
#     """Class representing the code divided into objects."""
# 
#     def __init__(self, code=""):
#         self.__objects = [_CodeObject(-1, "")]
#         self.__lexer = Lexer()
# 
#         lines = code.split("\n") if code else []
# 
#         for number, line in enumerate(lines):
#             self.insert_line(number, line)
# 
#     def objects(self, condition=None):
#         return filter(condition, self.__objects)
# 
#     def __is_header(self, line):
#         try:
#             header = self.__lexer["header"] + StringEnd()
#             header.parseString(line)
#             return True
#         except ParseException:
#             return False
# 
#     def __shift(self, position, offset):
#         for object in self.objects(_after(position)):
#             object.position += offset
# 
#     def insert_line(self, number, line):
#         self.__shift(number, 1)
# 
#         if self.__is_header(line):
#             object = _CodeObject(number, line)
# 
#             previous = self.objects(_before(number))[-1]
#             previous.transfer_lines(object, number)
# 
#             self.__objects.append(object)
#             self.__objects.sort()
#         else:
#             object = self.objects(_before(number))[-1]
#             object.insert_line(number, line)
# 
#     def update_line(self, number, line):
#         object = self.objects(_before(number))[-1]
#         updated_line = object.lines[number - object.position]
# 
#         if self.__is_header(line) == self.__is_header(updated_line):
#             object.update_line(number, line)
#         else:
#             self.remove_line(number)
#             self.insert_line(number, line)
# 
#     def remove_line(self, number):
#         object = self.objects(_before(number))[-1]
#         object.remove_line(number)
# 
#         if object.position == number:
#             previous = self.objects(_before(number))[-2]
#             object.transfer_lines(previous, number)
# 
#             self.__objects.remove(object)
# 
#         self.__shift(number, -1)
# 
# Path: omelette/compiler/compiler.py
# class Compiler(object):
# 
#     def __init__(self, libraries=[]):
#         self.__library_uml_objects = {}
#         self.__uml_objects = {}
# 
#         self.__parser = Parser()
#         self.__resolver = DependencyResolver(self.__uml_objects)
# 
#         for library in libraries:
#             self.compile(library)
# 
#     def compile(self, code):
#         code_objects = code.objects(lambda o: o.modified)
#         uml_objects = self.__parser.parse(code_objects)
# 
#         for code_object in code_objects:
#             code_object.modified = False
# 
#         if isinstance(code, Library):
#             self.__library_uml_objects.update(uml_objects)
# 
#         self.__uml_objects.update(uml_objects)
#         self.__resolver.resolve()
# 
#         for name, uml_object in uml_objects.items():
#             if uml_object.is_prototype:
#                 del uml_objects[name]
# 
#         Validator(uml_objects).validate()
# 
#         return uml_objects
# 
#     def clear(self):
#         self.__uml_objects.clear()
#         self.__uml_objects.update(self.__library_uml_objects)
# 
# Path: omelette/compiler/logging.py
# def getLogger(name):
#     def __init__(self):
#     def info(self, msg, object=None):
#     def warning(self, msg, object=None):
#     def error(self, msg, object=None):
#     def critical(self, msg, object=None):
#     def flush(self):
#     def is_empty(self):
#     def get_events(self, levels="INFO WARNING ERROR CRITICAL"):
#     def has(self, level):
#     def __init__(self, msg, level, object):
#     def __str__(self):
# class Logger:
# class Event:


# Path: omelette/compiler/test/test_compiler.py
import unittest
from omelette.compiler.code import Code
from omelette.compiler.compiler import Compiler
from omelette.compiler import logging


        result = instance.compile(code)

        self.assertEquals(len(result), 2)
        self.assertEquals(len(result["Student"].attributes()), 1)
        self.assertEquals(len(result["Student"].operations()), 1)

    def test_compile_modified_object(self):
        instance = Compiler()
        code = Code("""base class
            class Student
            class University""")

        instance.compile(code)

        code.insert_line(2, "   - name : String")
        result = instance.compile(code)

        self.assertEquals(len(result), 1)
        self.assertEquals(len(result["Student"].attributes()), 1)

    def test_compile_library(self):
        instance = Compiler([Code("base class")])
        result = instance.compile(Code("class Student"))

        self.assertTrue("Student" in result)
        self.assertEquals(result["Student"].type, "class")

    def test_compile_prototype(self):
        instance = Compiler()

        code = Code("""prototype base class