当前位置: 首页>>代码示例>>Java>>正文


Java InvalidInputException类代码示例

本文整理汇总了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);
       }
}
 
开发者ID:aserg-ufmg,项目名称:RefDiff,代码行数:20,代码来源:JavaSourceTokenizer.java

示例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);
		}
		
	}
}
 
开发者ID:mariazevedo88,项目名称:o3smeasures-tool,代码行数:32,代码来源:LackCohesionMethodsJavaModel.java

示例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;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:25,代码来源:CommentAnalyzer.java

示例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;
    }
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:17,代码来源:Util.java

示例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
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:18,代码来源:RefactoringScanner.java

示例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;
}
 
开发者ID:eclipse,项目名称:che,代码行数:23,代码来源:CommentAnalyzer.java

示例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;
}
 
开发者ID:eclipse,项目名称:che,代码行数:23,代码来源:TaskMarkerProposal.java

示例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;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:20,代码来源:ASTConverter.java

示例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;
}
 
开发者ID:mast-group,项目名称:codemining-core,代码行数:20,代码来源:JavaWhitespaceTokenizer.java

示例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;
}
 
开发者ID:mast-group,项目名称:tassal,代码行数:22,代码来源:JavaWhitespaceTokenizer.java

示例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);
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:17,代码来源:Scanner.java

示例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;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:20,代码来源:ASTConverter.java

示例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
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:18,代码来源:RefactoringScanner.java

示例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;
		}
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:18,代码来源:Util.java

示例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();
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:26,代码来源:DocCommentParser.java


注:本文中的org.eclipse.jdt.core.compiler.InvalidInputException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。