def from_path(cls, path):
     '''Returns a `PubspecFile` ready for use, or `None` if no pubspec
     file was found.
     '''
     p = find_pubspec_path(path)
     if p:
         return cls(os.path.join(p, 'pubspec.yaml'))
 def from_path(cls, path):
     '''Returns a `PubspecFile` ready for use, or `None` if no pubspec
     file was found.
     '''
     p = find_pubspec_path(path)
     if p:
         return cls(os.path.join(p, 'pubspec.yaml'))
示例#3
0
    def add_root(self, path):
        """Adds `path` to the monitored roots if it is unknown.

        If a `pubspec.yaml` is found in the path, its parent is monitored.
        Otherwise the passed-in directory name is monitored.

        @path
          Can be a directory or a file path.
        """
        if not path:
            _logger.debug('not a valid path: %s', path)
            return

        new_root_path = find_pubspec_path(path)
        if not new_root_path:
            # It seems we're not in a pub package, so we're probably looking
            # at a loose .dart file.
            new_root_path = os.path.dirname(path)
            _logger.debug('did not find pubspec.yaml in path: %s', path)
            _logger.debug('set root to: %s', new_root_path)

        with AnalysisServer._op_lock:
            if new_root_path not in self.roots:
                _logger.debug('adding new root: %s', new_root_path)
                self.roots.append(new_root_path)
                self.send_set_roots(self.roots)
                return

        _logger.debug('root already known: %s', new_root_path)
示例#4
0
    def add_root(self, path):
        """Adds `path` to the monitored roots if it is unknown.

        If a `pubspec.yaml` is found in the path, its parent is monitored.
        Otherwise the passed-in directory name is monitored.

        @path
          Can be a directory or a file path.
        """
        if not path:
            _logger.debug('not a valid path: %s', path)
            return

        p = find_pubspec_path(path)
        if not p:
            _logger.debug('did not found pubspec.yaml in path: %s', path)
            return

        with AnalysisServer._op_lock:
            if p not in self.roots:
                _logger.debug('adding new root: %s', p)
                self.roots.append(p)
                self.send_set_roots(self.roots)
                return

        _logger.debug('root already known: %s', p)
示例#5
0
    def add_root(self, path):
        """Adds `path` to the monitored roots if it is unknown.

        If a `pubspec.yaml` is found in the path, its parent is monitored.
        Otherwise the passed-in directory name is monitored.

        @path
          Can be a directory or a file path.
        """
        if not path:
            _logger.debug('not a valid path: %s', path)
            return

        p = find_pubspec_path(path)
        if not p:
            _logger.debug('did not found pubspec.yaml in path: %s', path)
            return

        with AnalysisServer._op_lock:
            if p not in self.roots:
                _logger.debug('adding new root: %s', p)
                self.roots.append(p)
                self.send_set_roots(self.roots)
                return

        _logger.debug('root already known: %s', p)
示例#6
0
    def add_root(self, view, path):
        """
        Adds `path` to the monitored roots if it is unknown.

        If a `pubspec.yaml` is found in the path, its parent is monitored.
        Otherwise the passed-in directory name is monitored.

        @path
          Can be a directory or a file path.
        """

        if not path:
            _logger.debug('not a valid path: %s', path)
            return

        new_root_path = find_pubspec_path(path)
        if not new_root_path:
            # It seems we're not in a pub package, so we're probably looking
            # at a loose .dart file.
            new_root_path = os.path.dirname(path)
            _logger.debug('did not find pubspec.yaml in path: %s', path)
            _logger.debug('set root to: %s', new_root_path)

        with AnalysisServer._op_lock:
            if new_root_path not in self.roots:
                _logger.debug('adding new root: %s', new_root_path)
                self.roots.append(new_root_path)
                self.send_set_roots(view, self.roots)
                return

        _logger.debug('root already known: %s', new_root_path)