Format the code in the given region.

@param resource the resource to format.
@param offset the offset of the text to format.
@param length the length of the text.
430370
public void formatRegion(XtextResource resource, int offset, int length) {
		assert resource != null;
		assert offset >= 0;
		assert length >= 0;
		final String result = formatResourceRegion(resource, offset, length);
		// Write back to the resource
		try (StringInputStream stringInputStream = new StringInputStream(result)) {
			resource.load(stringInputStream, Collections.emptyMap());
		} catch (Exception exception) {
			throw Exceptions.sneakyThrow(exception);
		}
	}
941139
protected void _format(SarlCapacityUses capacityUses, IFormattableDocument document) {
		final ISemanticRegionsFinder regionFor = this.textRegionExtensions.regionFor(capacityUses);
		document.append(regionFor.keyword(this.keywords.getUsesKeyword()), ONE_SPACE);
		formatCommaSeparatedList(capacityUses.getCapacities(), document);
		document.prepend(regionFor.keyword(this.keywords.getSemicolonKeyword()), NO_SPACE);
	}
200139
public void setBytes(long memoryOffset, byte[] buffer, int bufferOffset, int count)
    {
        if (buffer == null)
            throw new NullPointerException();
        else if (bufferOffset < 0
                 || count < 0
                 || bufferOffset + count > buffer.length)
            throw new IndexOutOfBoundsException();
        else if (count == 0)
            return;

        long end = memoryOffset + count;
        checkBounds(memoryOffset, end);

        unsafe.copyMemory(buffer, BYTE_ARRAY_BASE_OFFSET + bufferOffset, null, peer + memoryOffset, count);
    }
393667
public static void writeBytes(byte b[], int offset, byte[] value) {
    System.arraycopy(value, 0, b, offset, value.length);
  }
134780
private int ensureBuffer(int offset, int length) throws IOException {
		final int lastPos = offset + length - 1;
		final int desiredSize = ((lastPos / BUFFER_SIZE) + 1) * BUFFER_SIZE;
		final int currentSize = this.buffer.length;

		if (desiredSize > currentSize) {
			final byte[] readBuffer = new byte[desiredSize - currentSize];
			final int count = this.in.read(readBuffer);

			if (count > 0) {
				final byte[] newBuffer = new byte[currentSize + count];
				System.arraycopy(this.buffer, 0, newBuffer, 0, currentSize);
				System.arraycopy(readBuffer, 0, newBuffer, currentSize, count);
				this.buffer = newBuffer;
			}
			return (lastPos < this.buffer.length) ? length : length - (lastPos - this.buffer.length + 1);
		}
		return length;
	}
364464
private void writeTypedBytes(final int type, final byte[] data, final int offset, final int length)
    {
        int totalLength = 1 + length;
        if (length < 14)
        {
            buffer.writeUInt8(type | length);
        }
        else
        {
            // need to specify length explicitly
            buffer.writeUInt8(type | 0xE);
            final int sizeLength = buffer.writeVarUInt(length);
            totalLength += sizeLength;
        }
        updateLength(totalLength);
        buffer.writeBytes(data, offset, length);
    }
442064
protected void _format(SarlEvent event, IFormattableDocument document) {
		formatAnnotations(event, document, XbaseFormatterPreferenceKeys.newLineAfterClassAnnotations);
		formatModifiers(event, document);

		final ISemanticRegionsFinder regionFor = this.textRegionExtensions.regionFor(event);
		document.append(regionFor.keyword(this.keywords.getEventKeyword()), ONE_SPACE);

		document.surround(regionFor.keyword(this.keywords.getExtendsKeyword()), ONE_SPACE);
		document.format(event.getExtends());

		formatBody(event, document);
	}
1069331
public boolean regionMatchesIgnoreCase(char []cb, int offset, int length)
  {
    int pos = getIndex();

    char ch = current();
    for (int i = 0; i < length; i++) {
      if (ch == DONE) {
        setIndex(pos);
        return false;
      }

      if (Character.toLowerCase(cb[i + offset]) != Character.toLowerCase(ch)) {
        setIndex(pos);
        return false;
      }

      ch = next();
    }

    return true;
  }
279521
protected function doWrite(string $data, int $offset, int $length)
    {
        $this->content = substr($this->content, 0, $offset)
                       . $data
                       . substr($this->content, $offset + $length);
    }
914763
public void setFormat(final String format) {
        if (format == null && this.format == null) {
            return;
        } else if (format == null) {
            removeChild(this.format);
            this.format = null;
        } else if (this.format == null) {
            this.format = new KeyValueNode<String>(CommonConstants.CS_FORMAT_TITLE, format);
            appendChild(this.format, false);
        } else {
            this.format.setValue(format);
        }
    }
1214759
protected long checkRegions(long offset, int length) throws IOException {
        if (offset + length > filledUpTo)
            throw new IOException("Can't access memory outside the file size (" + filledUpTo
                    + " bytes). You've requested portion " + offset + "-" + (offset + length) + " bytes. File: "
                    + osFile.getAbsolutePath() + "\n" + "actual Filesize: " + size + "\n" + "actual filledUpTo: "
                    + filledUpTo);
        return offset;
    }
428204
@Override
  public void write(byte[] buffer, int offset, int length)
  {
    try {
      OutputStream os = _os;

      if (os != null) {
        os.write(buffer, offset, length);
      }
    } catch (Exception e) {
      log.log(Level.FINER, e.toString(), e);
    }
  }
943053
public void setLocalizationInfo(String resourceBundleName, String resourceKey, Object[] formatArguments) {
        this.resourceBundleName = resourceBundleName;
        this.resourceKey = resourceKey;
        this.formatArguments = formatArguments;
    }
736221
public void parse(String uri, int offset, int length) {
        clear();
        int end = offset + length;
        _uri = uri.substring(offset, end);
        parse(State.START, uri, offset, end);
    }
220579
public void setBuffer (byte[] bytes, int offset, int count) {
		if (bytes == null) throw new IllegalArgumentException("bytes cannot be null.");
		buffer = bytes;
		position = offset;
		limit = offset + count;
		capacity = bytes.length;
		total = 0;
		inputStream = null;
	}
266346
public void prewrite(byte[] b,int offset, int length)
    {
        ensureReserve(length);
        System.arraycopy(b,offset,_buf,_start-length,length);
        _start-=length;
    }
443925
public void set(byte[] newData, int offset, int length) {
    setSize(0);
    setSize(length);
    System.arraycopy(newData, offset, bytes, 0, size);
  }