本文整理汇总了Java中org.eclipse.jdt.core.compiler.InvalidInputException类的典型用法代码示例。如果您正苦于以下问题:Java InvalidInputException类的具体用法?Java InvalidInputException怎么用?Java InvalidInputException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
InvalidInputException类属于org.eclipse.jdt.core.compiler包,在下文中一共展示了InvalidInputException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: tokenize
import org.eclipse.jdt.core.compiler.InvalidInputException; //导入依赖的package包/类
@Override
public List<String> tokenize(String source) {
try {
char[] charArray = source.toCharArray();
scanner.setSource(source.toCharArray());
List<String> tokens = new ArrayList<>();
int token;
while ((token = scanner.getNextToken()) != ITerminalSymbols.TokenNameEOF) {
int tokenStart = scanner.getCurrentTokenStartPosition();
int tokenEnd = scanner.getCurrentTokenEndPosition();
if (token != ITerminalSymbols.TokenNameWHITESPACE) {
tokens.add(new String(charArray, tokenStart, tokenEnd - tokenStart + 1));
}
}
return tokens;
} catch (InvalidInputException e) {
throw new RuntimeException(e);
}
}
示例2: checkMethodsWithSharedAttributes
import org.eclipse.jdt.core.compiler.InvalidInputException; //导入依赖的package包/类
/**
* Method to check with methods share common attributes, according to
* CK definition.
* @author Mariana Azevedo
* @since 13/07/2014
* @param methods
*/
private void checkMethodsWithSharedAttributes(IMethod[] methods){
IScanner scanner = null;
for (IMethod method : methods) {
String methodName = method.getElementName();
try {
scanner = ToolFactory.createScanner(false, false, false, false);
scanner.setSource(method.getSource().toCharArray());
while(true){
int charactere = scanner.getNextToken();
if (charactere == ITerminalSymbols.TokenNameEOF) break;
if (charactere == ITerminalSymbols.TokenNameIdentifier) {
addMethods(new String(scanner.getCurrentTokenSource()), methodName);
}
}
} catch (JavaModelException exception1) {
logger.error(exception1);
} catch (InvalidInputException exception2) {
logger.error(exception2);
}
}
}
示例3: normalizeReference
import org.eclipse.jdt.core.compiler.InvalidInputException; //导入依赖的package包/类
/**
* Removes comments and whitespace
*
* @param reference
* the type reference
* @return the reference only consisting of dots and java identifier
* characters
*/
public static String normalizeReference(String reference) {
IScanner scanner = ToolFactory.createScanner(false, false, false, false);
scanner.setSource(reference.toCharArray());
StringBuffer sb = new StringBuffer();
try {
int tokenType = scanner.getNextToken();
while (tokenType != ITerminalSymbols.TokenNameEOF) {
sb.append(scanner.getRawTokenSource());
tokenType = scanner.getNextToken();
}
} catch (InvalidInputException e) {
Assert.isTrue(false, reference);
}
reference = sb.toString();
return reference;
}
示例4: isJustWhitespaceOrComment
import org.eclipse.jdt.core.compiler.InvalidInputException; //导入依赖的package包/类
private static boolean isJustWhitespaceOrComment(int start, int end, IBuffer buffer) {
if (start == end) return true;
Assert.isTrue(start <= end);
String trimmedText = buffer.getText(start, end - start).trim();
if (0 == trimmedText.length()) {
return true;
} else {
IScanner scanner = ToolFactory.createScanner(false, false, false, null);
scanner.setSource(trimmedText.toCharArray());
try {
return scanner.getNextToken() == ITerminalSymbols.TokenNameEOF;
} catch (InvalidInputException e) {
return false;
}
}
}
示例5: doScan
import org.eclipse.jdt.core.compiler.InvalidInputException; //导入依赖的package包/类
private void doScan() {
try {
int token = fScanner.getNextToken();
while (token != ITerminalSymbols.TokenNameEOF) {
switch (token) {
case ITerminalSymbols.TokenNameStringLiteral:
case ITerminalSymbols.TokenNameCOMMENT_JAVADOC:
case ITerminalSymbols.TokenNameCOMMENT_LINE:
case ITerminalSymbols.TokenNameCOMMENT_BLOCK:
parseCurrentToken();
}
token = fScanner.getNextToken();
}
} catch (InvalidInputException e) {
// ignore
}
}
示例6: normalizeReference
import org.eclipse.jdt.core.compiler.InvalidInputException; //导入依赖的package包/类
/**
* Removes comments and whitespace
*
* @param reference the type reference
* @return the reference only consisting of dots and java identifier characters
*/
public static String normalizeReference(String reference) {
IScanner scanner = ToolFactory.createScanner(false, false, false, false);
scanner.setSource(reference.toCharArray());
StringBuffer sb = new StringBuffer();
try {
int tokenType = scanner.getNextToken();
while (tokenType != ITerminalSymbols.TokenNameEOF) {
sb.append(scanner.getRawTokenSource());
tokenType = scanner.getNextToken();
}
} catch (InvalidInputException e) {
Assert.isTrue(false, reference);
}
reference = sb.toString();
return reference;
}
示例7: getSurroundingComment
import org.eclipse.jdt.core.compiler.InvalidInputException; //导入依赖的package包/类
private int getSurroundingComment(IScanner scanner) {
try {
int start = fLocation.getOffset();
int end = start + fLocation.getLength();
int token = scanner.getNextToken();
while (token != ITerminalSymbols.TokenNameEOF) {
if (TokenScanner.isComment(token)) {
int currStart = scanner.getCurrentTokenStartPosition();
int currEnd = scanner.getCurrentTokenEndPosition() + 1;
if (currStart <= start && end <= currEnd) {
return token;
}
}
token = scanner.getNextToken();
}
} catch (InvalidInputException e) {
// ignore
}
return ITerminalSymbols.TokenNameEOF;
}
示例8: retrieveStartBlockPosition
import org.eclipse.jdt.core.compiler.InvalidInputException; //导入依赖的package包/类
/**
* This method is used to retrieve the start position of the block.
* @return int the dimension found, -1 if none
*/
protected int retrieveStartBlockPosition(int start, int end) {
this.scanner.resetTo(start, end);
try {
int token;
while ((token = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
switch(token) {
case TerminalTokens.TokenNameLBRACE://110
return this.scanner.startPosition;
}
}
} catch(InvalidInputException e) {
// ignore
}
return -1;
}
示例9: tokenListFromCode
import org.eclipse.jdt.core.compiler.InvalidInputException; //导入依赖的package包/类
@Override
public List<String> tokenListFromCode(final char[] code) {
final List<String> tokens = Lists.newArrayList();
tokens.add(SENTENCE_START);
final PublicScanner scanner = prepareScanner(code);
do {
try {
final int token = scanner.getNextToken();
if (token == ITerminalSymbols.TokenNameEOF) {
break;
}
tokens.addAll(getConvertedToken(scanner, token));
} catch (final InvalidInputException e) {
LOGGER.warning(ExceptionUtils.getFullStackTrace(e));
}
} while (!scanner.atEnd());
tokens.add(SENTENCE_END);
return tokens;
}
示例10: getTokenListFromCode
import org.eclipse.jdt.core.compiler.InvalidInputException; //导入依赖的package包/类
@Override
public List<FullToken> getTokenListFromCode(final char[] code) {
final List<FullToken> tokens = Lists.newArrayList();
tokens.add(new FullToken(SENTENCE_START, SENTENCE_START));
final PublicScanner scanner = prepareScanner(code);
do {
try {
final int token = scanner.getNextToken();
if (token == ITerminalSymbols.TokenNameEOF) {
break;
}
for (final String cToken : getConvertedToken(scanner, token)) {
tokens.add(new FullToken(cToken, ""));
}
} catch (final InvalidInputException e) {
LOGGER.warning(ExceptionUtils.getFullStackTrace(e));
}
} while (!scanner.atEnd());
tokens.add(new FullToken(SENTENCE_END, SENTENCE_END));
return tokens;
}
示例11: consumeDigits
import org.eclipse.jdt.core.compiler.InvalidInputException; //导入依赖的package包/类
private final void consumeDigits(int radix, boolean expectingDigitFirst) throws InvalidInputException {
final int USING_UNDERSCORE = 1;
final int INVALID_POSITION = 2;
switch(consumeDigits0(radix, USING_UNDERSCORE, INVALID_POSITION, expectingDigitFirst)) {
case USING_UNDERSCORE :
if (this.sourceLevel < ClassFileConstants.JDK1_7) {
throw new InvalidInputException(UNDERSCORES_IN_LITERALS_NOT_BELOW_17);
}
break;
case INVALID_POSITION :
if (this.sourceLevel < ClassFileConstants.JDK1_7) {
throw new InvalidInputException(UNDERSCORES_IN_LITERALS_NOT_BELOW_17);
}
throw new InvalidInputException(INVALID_UNDERSCORE);
}
}
示例12: retrieveEndOfRightParenthesisPosition
import org.eclipse.jdt.core.compiler.InvalidInputException; //导入依赖的package包/类
/**
* This method is used to retrieve the position after the right parenthesis.
* @return int the position found
*/
protected int retrieveEndOfRightParenthesisPosition(int start, int end) {
this.scanner.resetTo(start, end);
try {
int token;
while ((token = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
switch(token) {
case TerminalTokens.TokenNameRPAREN:
return this.scanner.currentPosition;
}
}
} catch(InvalidInputException e) {
// ignore
}
return -1;
}
示例13: doScan
import org.eclipse.jdt.core.compiler.InvalidInputException; //导入依赖的package包/类
private void doScan() {
try{
int token = fScanner.getNextToken();
while (token != ITerminalSymbols.TokenNameEOF) {
switch (token) {
case ITerminalSymbols.TokenNameStringLiteral :
case ITerminalSymbols.TokenNameCOMMENT_JAVADOC :
case ITerminalSymbols.TokenNameCOMMENT_LINE :
case ITerminalSymbols.TokenNameCOMMENT_BLOCK :
parseCurrentToken();
}
token = fScanner.getNextToken();
}
} catch (InvalidInputException e){
//ignore
}
}
示例14: isJustWhitespaceOrComment
import org.eclipse.jdt.core.compiler.InvalidInputException; //导入依赖的package包/类
private static boolean isJustWhitespaceOrComment(int start, int end, IBuffer buffer) {
if (start == end)
return true;
Assert.isTrue(start <= end);
String trimmedText= buffer.getText(start, end - start).trim();
if (0 == trimmedText.length()) {
return true;
} else {
IScanner scanner= ToolFactory.createScanner(false, false, false, null);
scanner.setSource(trimmedText.toCharArray());
try {
return scanner.getNextToken() == ITerminalSymbols.TokenNameEOF;
} catch (InvalidInputException e) {
return false;
}
}
}
示例15: createFieldReference
import org.eclipse.jdt.core.compiler.InvalidInputException; //导入依赖的package包/类
protected Object createFieldReference(Object receiver) throws InvalidInputException {
try {
MemberRef fieldRef = this.ast.newMemberRef();
SimpleName fieldName = new SimpleName(this.ast);
fieldName.internalSetIdentifier(new String(this.identifierStack[0]));
fieldRef.setName(fieldName);
int start = (int) (this.identifierPositionStack[0] >>> 32);
int end = (int) this.identifierPositionStack[0];
fieldName.setSourceRange(start, end - start + 1);
if (receiver == null) {
start = this.memberStart;
fieldRef.setSourceRange(start, end - start + 1);
} else {
Name typeRef = (Name) receiver;
fieldRef.setQualifier(typeRef);
start = typeRef.getStartPosition();
end = fieldName.getStartPosition()+fieldName.getLength()-1;
fieldRef.setSourceRange(start, end-start+1);
}
return fieldRef;
}
catch (ClassCastException ex) {
throw new InvalidInputException();
}
}