def resolve_const_spec(self, name, lineno):
        """Finds and links the ConstSpec with the given name."""

        if name in self.const_specs:
            return self.const_specs[name].link(self)

        if '.' in name:
            include_name, component = name.split('.', 1)
            if include_name in self.included_scopes:
                return self.included_scopes[include_name].resolve_const_spec(
                    component, lineno
                )

        raise ThriftCompilerError(
            'Unknown constant "%s" referenced at line %d%s' % (
                name, lineno, self.__in_path()
            )
        )