Java Code Examples for org.eclipse.jdt.core.compiler.CharOperation#isWhitespace()

The following examples show how to use org.eclipse.jdt.core.compiler.CharOperation#isWhitespace() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PublicScanner.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public final boolean jumpOverUnicodeWhiteSpace() throws InvalidInputException {
	//BOOLEAN
	//handle the case of unicode. Jump over the next whiteSpace
	//making startPosition pointing on the next available char
	//On false, the currentCharacter is filled up with a potential
	//correct char

	this.wasAcr = false;
	getNextUnicodeChar();
	return CharOperation.isWhitespace(this.currentCharacter);
}
 
Example 2
Source File: Scanner.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public final boolean jumpOverUnicodeWhiteSpace() throws InvalidInputException {
	//BOOLEAN
	//handle the case of unicode. Jump over the next whiteSpace
	//making startPosition pointing on the next available char
	//On false, the currentCharacter is filled up with a potential
	//correct char

	this.wasAcr = false;
	getNextUnicodeChar();
	return CharOperation.isWhitespace(this.currentCharacter);
}
 
Example 3
Source File: JDTCompilerAdapter.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * check the compiler arguments.
 * Extract from files specified using @, lines marked with ADAPTER_PREFIX
 * These lines specify information that needs to be interpreted by us.
 * @param args compiler arguments to process
 */
private void checkCompilerArgs(String[] args) {
	for (int i = 0; i < args.length; i++) {
		if (args[i].charAt(0) == '@') {
			try {
				char[] content = Util.getFileCharContent(new File(args[i].substring(1)), null);
				int offset = 0;
				int prefixLength = ADAPTER_PREFIX.length;
				while ((offset = CharOperation.indexOf(ADAPTER_PREFIX, content, true, offset)) > -1) {
					int start = offset + prefixLength;
					int end = CharOperation.indexOf('\n', content, start);
					if (end == -1)
						end = content.length;
					while (CharOperation.isWhitespace(content[end])) {
						end--;
					}

					// end is inclusive, but in the API end is exclusive
					if (CharOperation.equals(ADAPTER_ENCODING, content, start, start + ADAPTER_ENCODING.length)) {
						CharOperation.replace(content, SEPARATOR_CHARS, File.separatorChar, start, end + 1);
						// file or folder level custom encoding
						start += ADAPTER_ENCODING.length;
						int encodeStart = CharOperation.lastIndexOf('[', content, start, end);
						if (start < encodeStart && encodeStart < end) {
							boolean isFile = CharOperation.equals(SuffixConstants.SUFFIX_java, content, encodeStart - 5, encodeStart, false);

							String str = String.valueOf(content, start, encodeStart - start);
							String enc = String.valueOf(content, encodeStart, end - encodeStart + 1);
							if (isFile) {
								if (this.fileEncodings == null)
									this.fileEncodings = new HashMap();
								//use File to translate the string into a path with the correct File.seperator
								this.fileEncodings.put(str, enc);
							} else {
								if (this.dirEncodings == null)
									this.dirEncodings = new HashMap();
								this.dirEncodings.put(str, enc);
							}
						}
					} else if (CharOperation.equals(ADAPTER_ACCESS, content, start, start + ADAPTER_ACCESS.length)) {
						// access rules for the classpath
						start += ADAPTER_ACCESS.length;
						int accessStart = CharOperation.indexOf('[', content, start, end);
						CharOperation.replace(content, SEPARATOR_CHARS, File.separatorChar, start, accessStart);
						if (start < accessStart && accessStart < end) {
							String path = String.valueOf(content, start, accessStart - start);
							String access = String.valueOf(content, accessStart, end - accessStart + 1);
							if (this.accessRules == null)
								this.accessRules = new ArrayList();
							this.accessRules.add(path);
							this.accessRules.add(access);
						}
					}
					offset = end;
				}
			} catch (IOException e) {
				//ignore
			}
		}
	}

}