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


Java ToolFactory.createScanner方法代码示例

本文整理汇总了Java中org.eclipse.jdt.core.ToolFactory.createScanner方法的典型用法代码示例。如果您正苦于以下问题:Java ToolFactory.createScanner方法的具体用法?Java ToolFactory.createScanner怎么用?Java ToolFactory.createScanner使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jdt.core.ToolFactory的用法示例。


在下文中一共展示了ToolFactory.createScanner方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkMethodsWithSharedAttributes

import org.eclipse.jdt.core.ToolFactory; //导入方法依赖的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

示例2: normalizeReference

import org.eclipse.jdt.core.ToolFactory; //导入方法依赖的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

示例3: isJustWhitespaceOrComment

import org.eclipse.jdt.core.ToolFactory; //导入方法依赖的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

示例4: TokenScanner

import org.eclipse.jdt.core.ToolFactory; //导入方法依赖的package包/类
/**
 * Creates a TokenScanner
 *
 * @param typeRoot The type root to scan on
 * @throws CoreException thrown if the buffer cannot be accessed
 */
public TokenScanner(ITypeRoot typeRoot) throws CoreException {
  IJavaProject project = typeRoot.getJavaProject();
  IBuffer buffer = typeRoot.getBuffer();
  if (buffer == null) {
    throw new CoreException(
        createError(DOCUMENT_ERROR, "Element has no source", null)); // $NON-NLS-1$
  }
  String sourceLevel = project.getOption(JavaCore.COMPILER_SOURCE, true);
  String complianceLevel = project.getOption(JavaCore.COMPILER_COMPLIANCE, true);
  fScanner =
      ToolFactory.createScanner(
          true, false, true, sourceLevel, complianceLevel); // line info required

  fScanner.setSource(buffer.getCharacters());
  fDocument = null; // use scanner for line information
  fEndPosition = fScanner.getSource().length - 1;
}
 
开发者ID:eclipse,项目名称:che,代码行数:24,代码来源:TokenScanner.java

示例5: normalizeReference

import org.eclipse.jdt.core.ToolFactory; //导入方法依赖的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

示例6: isJustWhitespaceOrComment

import org.eclipse.jdt.core.ToolFactory; //导入方法依赖的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

示例7: normalizeReference

import org.eclipse.jdt.core.ToolFactory; //导入方法依赖的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:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:22,代码来源:CommentAnalyzer.java

示例8: TokenScanner

import org.eclipse.jdt.core.ToolFactory; //导入方法依赖的package包/类
/**
 * Creates a TokenScanner
 * @param document The textbuffer to create the scanner on
 * @param project the current Java project
 */
public TokenScanner(IDocument document, IJavaProject project) {
	String sourceLevel= project.getOption(JavaCore.COMPILER_SOURCE, true);
	String complianceLevel= project.getOption(JavaCore.COMPILER_COMPLIANCE, true);
	fScanner= ToolFactory.createScanner(true, false, false, sourceLevel, complianceLevel); // no line info required
	fScanner.setSource(document.get().toCharArray());
	fDocument= document;
	fEndPosition= fScanner.getSource().length - 1;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:14,代码来源:TokenScanner.java

示例9: isValidComment

import org.eclipse.jdt.core.ToolFactory; //导入方法依赖的package包/类
private boolean isValidComment(String template) {
	IScanner scanner = ToolFactory.createScanner(true, false, false, false);
	scanner.setSource(template.toCharArray());
	try {
		int next = scanner.getNextToken();
		while (TokenScanner.isComment(next)) {
			next = scanner.getNextToken();
		}
		return next == ITerminalSymbols.TokenNameEOF;
	} catch (InvalidInputException e) {
	}
	return false;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:14,代码来源:CodeTemplateContextType.java

示例10: getScanner

import org.eclipse.jdt.core.ToolFactory; //导入方法依赖的package包/类
protected IScanner getScanner(ICompilationUnit unit) {
	IJavaProject project = unit.getJavaProject();
	if (project.equals(fProjectCache)) {
		return fScannerCache;
	}

	fProjectCache = project;
	String sourceLevel = project.getOption(JavaCore.COMPILER_SOURCE, true);
	String complianceLevel = project.getOption(JavaCore.COMPILER_COMPLIANCE, true);
	fScannerCache = ToolFactory.createScanner(false, false, false, sourceLevel, complianceLevel);
	return fScannerCache;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:13,代码来源:RenameProcessor.java

示例11: isValidComment

import org.eclipse.jdt.core.ToolFactory; //导入方法依赖的package包/类
private boolean isValidComment(String template) {
  IScanner scanner = ToolFactory.createScanner(true, false, false, false);
  scanner.setSource(template.toCharArray());
  try {
    int next = scanner.getNextToken();
    while (TokenScanner.isComment(next)) {
      next = scanner.getNextToken();
    }
    return next == ITerminalSymbols.TokenNameEOF;
  } catch (InvalidInputException e) {
  }
  return false;
}
 
开发者ID:eclipse,项目名称:che,代码行数:14,代码来源:CodeTemplateContextType.java

示例12: getScanner

import org.eclipse.jdt.core.ToolFactory; //导入方法依赖的package包/类
protected IScanner getScanner(ICompilationUnit unit) {
  IJavaProject project = unit.getJavaProject();
  if (project.equals(fProjectCache)) return fScannerCache;

  fProjectCache = project;
  String sourceLevel = project.getOption(JavaCore.COMPILER_SOURCE, true);
  String complianceLevel = project.getOption(JavaCore.COMPILER_COMPLIANCE, true);
  fScannerCache = ToolFactory.createScanner(false, false, false, sourceLevel, complianceLevel);
  return fScannerCache;
}
 
开发者ID:eclipse,项目名称:che,代码行数:11,代码来源:CuCollectingSearchRequestor.java

示例13: scan

import org.eclipse.jdt.core.ToolFactory; //导入方法依赖的package包/类
public void scan(ICompilationUnit cu) throws JavaModelException {
  char[] chars = cu.getBuffer().getCharacters();
  fMatches = new HashSet<TextMatch>();
  fScanner = ToolFactory.createScanner(true, true, false, true);
  fScanner.setSource(chars);

  //		IImportContainer importContainer= cu.getImportContainer();
  //		if (importContainer.exists())
  //			fNoFlyZone= importContainer.getSourceRange();
  //		else
  //			fNoFlyZone= null;

  doScan();
  fScanner = null;
}
 
开发者ID:eclipse,项目名称:che,代码行数:16,代码来源:RefactoringScanner.java

示例14: isValidComment

import org.eclipse.jdt.core.ToolFactory; //导入方法依赖的package包/类
private boolean isValidComment(String template) {
  IScanner scanner = ToolFactory.createScanner(true, false, false, false);
  scanner.setSource(template.toCharArray());
  try {
    int next = scanner.getNextToken();
    while (TokenScanner.isComment(next)) {
      next = scanner.getNextToken();
    }
    return next == ITerminalSymbols.TokenNameEOF;
  } catch (InvalidInputException e) {
    // If there are lexical errors, the comment is invalid
  }
  return false;
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:15,代码来源:TypeCreator.java

示例15: isValidComment

import org.eclipse.jdt.core.ToolFactory; //导入方法依赖的package包/类
private boolean isValidComment(String template) {
	IScanner scanner= ToolFactory.createScanner(true, false, false, false);
	scanner.setSource(template.toCharArray());
	try {
		int next= scanner.getNextToken();
		while (TokenScanner.isComment(next)) {
			next= scanner.getNextToken();
		}
		return next == ITerminalSymbols.TokenNameEOF;
	} catch (InvalidInputException e) {
	}
	return false;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:14,代码来源:ParameterObjectFactory.java


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