Synchronize the Source with an update. This method applies changes to the
 code, parses the new code's AST, and returns the resulting Source object.

 @param updater [Source::Updater]
 @return [Source]
498468
def synchronize updater
      raise 'Invalid synchronization' unless updater.filename == filename
      real_code = updater.write(@code)
      if real_code == @code
        @version = updater.version
        return self
      end
      synced = Source.new(real_code, filename)
      if synced.parsed?
        synced.version = updater.version
        return synced
      end
      incr_code = updater.repair(@repaired)
      synced = Source.new(incr_code, filename)
      synced.error_ranges.concat (error_ranges + updater.changes.map(&:range))
      synced.code = real_code
      synced.version = updater.version
      synced
    end
307725
public function doUpdate(Updater $updater)
    {
        $config = Config::getInstance();
        $config->Plugins_Tracker = array();
        $config->forceSave();
    }
444050
public synchronized U update(int i, Function<U, U> updater) {
    U updated = updater.apply(this.get(i));
    set(i, updated);
    return updated;
  }
452463
def _requires_update(self, old_object, new_object):
        
        old_encoded = self.manager._encode(old_object)
        new_encoded = self.manager._encode(new_object)
        return _compare_recursive(old_encoded, new_encoded)
1179273
public static Updater createUpdater(String expression) {
        try {
            return INSTANCE.ctorUpdater.newInstance(expression);
        }
        catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
478290
def update!(**kwords)
      kwords = kwords.map { |k, v| [k.to_s.capitalize, v] }.to_h
      response = @connection.send(:put,
                                  "/snapshots/#{self.Name}",
                                  body: JSON.generate(kwords))
      hash = JSON.parse(response.body, symbolize_names: true)
      return nil if hash == marshal_dump
      marshal_load(hash)
      self
    end
80404
protected final void doUpdates(
            final Map<K, Function<? super V, ? extends V>> mutators) {
        apply(mutators.isEmpty() ? Nop.instance() : new Update<>(mutators));
    }
769555
function refreshSyncers(keys) {
	if (typeof keys === 'string') {
		keys = [keys]
	}
	if (!keys) {
		keys = Object.keys(this._syncers)
	}
	return Promise.all(keys.map(key => {
		return this._syncers[key].refresh()
	}))
}
500631
function getUpdates() {
		return _client.method('WaitForUpdatesEx', {
			_this: _client._updatesCollector,
			version: _client._updatesVersion,
			options: {
				maxWaitSeconds: 0
			}
		})
		.then(function(set) {
			if (set) {

				// update the version
				_client._updatesVersion = set.version;
				
				// get only the updates
				var updates   = [];
				var filterSet = _.get(set, 'filterSet');
				filterSet     = Array.isArray(filterSet) ? filterSet : [filterSet];
				
				// loop through the filter sets
				_.forEach(filterSet, function(f) {
					
					var objectSet = _.get(f, 'objectSet');
					objectSet     = Array.isArray(objectSet) ? objectSet : [objectSet];
					
					// format the objects
					_.forEach(objectSet, function(u) {
						u.obj = {
							type: _.get(u, 'obj.attributes.type'),
							id: _.get(u, 'obj.$value')
						};
						
						// make the change set an array
						u.changeSet = Array.isArray(u.changeSet) ? u.changeSet : [u.changeSet];
						
						// update change set
						_.forEach(u.changeSet, function(c) {
							c.val = _.get(c, 'val.$value');
						});
						
						// push the update
						updates.push(u);
					});
				});

				// emit the results
				_client.emit('updates', updates);
			}
		});
	}
837973
def atomic_update(clazz, updates = {})
      @adds += updates.keys.length
      indexer.add_atomic_update(clazz, updates)
    end
610041
def update_version
      return create_version unless v = versions.last
      v.modifications_will_change!
      v.update_attribute(:modifications, v.changes.append_changes(version_changes))
      reset_version_changes
      reset_version
    end
1311662
function(updater) {
        for (var i = 0; i < buffer.length; ++i) {
          var _cfg = updater(buffer[i].config);
          if (_cfg !== false)
            retryHttpRequest(_cfg, buffer[i].deferred);
        }
        buffer = [];
      }
1349773
def updater():
    
    print('%s Checking for updates' % run)
    # Changes must be separated by ;
    changes = '''major bug fixes;removed ninja mode;dropped python < 3.2 support;fixed unicode output;proxy support;more intels'''
    latest_commit = requester('https://raw.githubusercontent.com/s0md3v/Photon/master/core/updater.py', host='raw.githubusercontent.com')
    # Just a hack to see if a new version is available
    if changes not in latest_commit:
        changelog = re.search(r"changes = '''(.*?)'''", latest_commit)
        # Splitting the changes to form a list
        changelog = changelog.group(1).split(';')
        print('%s A new version of Photon is available.' % good)
        print('%s Changes:' % info)
        for change in changelog: # print changes
            print('%s>%s %s' % (green, end, change))

        current_path = os.getcwd().split('/') # if you know it, you know it
        folder = current_path[-1] # current directory name
        path = '/'.join(current_path) # current directory path
        choice = input('%s Would you like to update? [Y/n] ' % que).lower()

        if choice != 'n':
            print('%s Updating Photon' % run)
            os.system('git clone --quiet https://github.com/s0md3v/Photon %s'
                      % (folder))
            os.system('cp -r %s/%s/* %s && rm -r %s/%s/ 2>/dev/null'
                      % (path, folder, path, path, folder))
            print('%s Update successful!' % good)
    else:
        print('%s Photon is up to date!' % good)
419765
function updateSourceCode(code, changes) {
  // Summary:
  //  This must be called before code is changed some places else rather than ast

  changes.sort((c1, c2) => c2.start - c1.start);
  // Remove same or overlapped changes
  const newChanges = _.reduce(
    changes,
    (cleanChanges, curr) => {
      const last = _.last(cleanChanges);

      if (!cleanChanges.length || last.start > curr.end) {
        cleanChanges.push(curr);
      } else if (last.start === last.end && last.end === curr.start && curr.start === curr.end) {
        // insert code at the same position, merge them
        last.replacement += curr.replacement;
      }
      return cleanChanges;
    },
    [],
  );

  const chars = code.split('');
  newChanges.forEach(c => {
    // Special case: after the change, two empty lines occurs, should delete one line
    if (
      c.replacement === '' &&
      (c.start === 0 || chars[c.start - 1] === '\n') &&
      chars[c.end] === '\n'
    ) {
      c.end += 1;
    }
    chars.splice(c.start, c.end - c.start, c.replacement);
  });
  return chars.join('');
}
428192
def sync_events(sync_m, *args)
      if args[0].is_a?(PredictionIO::AsyncResponse)
        response = args[0].get
      else
        response = send(sync_m, *args).get
      end
      return response if response.is_a?(Net::HTTPCreated)
      begin
        msg = response.body
      rescue
        raise NotCreatedError, response
      end
      fail NotCreatedError, msg
    end
1003570
def update
      unless File.exist?(@source_file)
        raise FileNotFoundError.new("Source file deleted")
      end

      markdown_render = @preview_pipeline.call(IO.read(@source_file), @pipeline_context, {})[:output].to_s
      preview_html = wrap_preview(markdown_render)

      File.open(@preview_file, 'w') do |f|
        f.write(preview_html)
      end

      @update_callbacks.each { |callback| callback.call }
    end
225401
public synchronized void registerUpdater(final Updater updater) {
    if (!updaters.containsKey(updater)) {
      updaters.put(updater, Boolean.TRUE);
    }
  }