• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java IScanner类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.eclipse.jdt.core.compiler.IScanner的典型用法代码示例。如果您正苦于以下问题:Java IScanner类的具体用法?Java IScanner怎么用?Java IScanner使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IScanner类属于org.eclipse.jdt.core.compiler包,在下文中一共展示了IScanner类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: checkMethodsWithSharedAttributes

import org.eclipse.jdt.core.compiler.IScanner; //导入依赖的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.compiler.IScanner; //导入依赖的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.compiler.IScanner; //导入依赖的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: normalizeReference

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


示例5: getSurroundingComment

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


示例6: parseTags

import org.eclipse.jdt.core.compiler.IScanner; //导入依赖的package包/类
private static void parseTags(NLSLine line, IScanner scanner) {
	String s= new String(scanner.getCurrentTokenSource());
	int pos= s.indexOf(NLSElement.TAG_PREFIX);
	while (pos != -1) {
		int start= pos + NLSElement.TAG_PREFIX_LENGTH;
		int end= s.indexOf(NLSElement.TAG_POSTFIX, start);
		if (end < 0)
			return; //no error recovery

		String index= s.substring(start, end);
		int i= 0;
		try {
			i= Integer.parseInt(index) - 1; 	// Tags are one based not zero based.
		} catch (NumberFormatException e) {
			return; //ignore the exception - no error recovery
		}
		if (line.exists(i)) {
			NLSElement element= line.get(i);
			element.setTagPosition(scanner.getCurrentTokenStartPosition() + pos, end - pos + 1);
		} else {
			return; //no error recovery
		}
		pos= s.indexOf(NLSElement.TAG_PREFIX, start);
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:26,代码来源:NLSScanner.java


示例7: normalizeReference

import org.eclipse.jdt.core.compiler.IScanner; //导入依赖的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,代码行数:22,代码来源:CommentAnalyzer.java


示例8: isJustWhitespaceOrComment

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


示例9: createContext

import org.eclipse.jdt.core.compiler.IScanner; //导入依赖的package包/类
private FoldingStructureComputationContext createContext(boolean allowCollapse) {
	if (!isInstalled())
		return null;
	ProjectionAnnotationModel model= getModel();
	if (model == null)
		return null;
	IDocument doc= getDocument();
	if (doc == null)
		return null;

	IScanner scanner= null;
	if (fUpdatingCount == 1)
		scanner= fSharedScanner; // reuse scanner

	return new FoldingStructureComputationContext(doc, model, allowCollapse, scanner);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:17,代码来源:DefaultJavaFoldingStructureProvider.java


示例10: getSurroundingComment

import org.eclipse.jdt.core.compiler.IScanner; //导入依赖的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:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:23,代码来源:TaskMarkerProposal.java


示例11: initScanner

import org.eclipse.jdt.core.compiler.IScanner; //导入依赖的package包/类
/**
 * @param source
 *            must be not null
 * @param range
 *            can be null
 * @return may return null, otherwise an initialized scanner which may
 *         answer which source offset index belongs to which source line
 * @throws JavaModelException
 */
private static IScanner initScanner(IType source, ISourceRange range) throws JavaModelException {
    if (range == null) {
        return null;
    }
    char[] charContent = getContent(source);
    if (charContent == null) {
        return null;
    }
    IScanner scanner = ToolFactory.createScanner(false, false, false, true);
    scanner.setSource(charContent);
    int offset = range.getOffset();
    try {
        while (scanner.getNextToken() != ITerminalSymbols.TokenNameEOF) {
            // do nothing, just wait for the end of stream
            if (offset <= scanner.getCurrentTokenEndPosition()) {
                break;
            }
        }
    } catch (InvalidInputException e) {
        FindbugsPlugin.getDefault().logException(e, "Could not init scanner for type: " + source);
    }
    return scanner;
}
 
开发者ID:OpenNTF,项目名称:FindBug-for-Domino-Designer,代码行数:33,代码来源:MarkerUtil.java


示例12: isValidComment

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


示例13: getScanner

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


示例14: perform

import org.eclipse.jdt.core.compiler.IScanner; //导入依赖的package包/类
public static RefactoringStatus perform(Selection selection, IScanner scanner, int start, int length) {
	RefactoringStatus result = new RefactoringStatus();
	if (length <= 0) {
		return result;
	}
	new CommentAnalyzer().check(result, selection, scanner, start, start + length - 1);
	return result;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:9,代码来源:CommentAnalyzer.java


示例15: check

import org.eclipse.jdt.core.compiler.IScanner; //导入依赖的package包/类
private void check(RefactoringStatus result, Selection selection, IScanner scanner, int start, int end) {
	char[] characters = scanner.getSource();
	selection = adjustSelection(characters, selection, end);
	scanner.resetTo(start, end);

	int token = 0;
	try {
		loop: while (token != ITerminalSymbols.TokenNameEOF) {
			token = scanner.getNextToken();
			switch (token) {
				case ITerminalSymbols.TokenNameCOMMENT_LINE:
				case ITerminalSymbols.TokenNameCOMMENT_BLOCK:
				case ITerminalSymbols.TokenNameCOMMENT_JAVADOC:
					if (checkStart(scanner, selection.getOffset())) {
						result.addFatalError(RefactoringCoreMessages.CommentAnalyzer_starts_inside_comment);
						break loop;
					}
					if (checkEnd(scanner, selection.getInclusiveEnd())) {
						result.addFatalError(RefactoringCoreMessages.CommentAnalyzer_ends_inside_comment);
						break loop;
					}
					break;
			}
		}
	} catch (InvalidInputException e) {
		result.addFatalError(RefactoringCoreMessages.CommentAnalyzer_internal_error);
	}
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:29,代码来源:CommentAnalyzer.java


示例16: isValidComment

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


示例17: getScanner

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


示例18: perform

import org.eclipse.jdt.core.compiler.IScanner; //导入依赖的package包/类
public static RefactoringStatus perform(
    Selection selection, IScanner scanner, int start, int length) {
  RefactoringStatus result = new RefactoringStatus();
  if (length <= 0) return result;
  new CommentAnalyzer().check(result, selection, scanner, start, start + length - 1);
  return result;
}
 
开发者ID:eclipse,项目名称:che,代码行数:8,代码来源:CommentAnalyzer.java


示例19: check

import org.eclipse.jdt.core.compiler.IScanner; //导入依赖的package包/类
private void check(
    RefactoringStatus result, Selection selection, IScanner scanner, int start, int end) {
  char[] characters = scanner.getSource();
  selection = adjustSelection(characters, selection, end);
  scanner.resetTo(start, end);

  int token = 0;
  try {
    loop:
    while (token != ITerminalSymbols.TokenNameEOF) {
      token = scanner.getNextToken();
      switch (token) {
        case ITerminalSymbols.TokenNameCOMMENT_LINE:
        case ITerminalSymbols.TokenNameCOMMENT_BLOCK:
        case ITerminalSymbols.TokenNameCOMMENT_JAVADOC:
          if (checkStart(scanner, selection.getOffset())) {
            result.addFatalError(RefactoringCoreMessages.CommentAnalyzer_starts_inside_comment);
            break loop;
          }
          if (checkEnd(scanner, selection.getInclusiveEnd())) {
            result.addFatalError(RefactoringCoreMessages.CommentAnalyzer_ends_inside_comment);
            break loop;
          }
          break;
      }
    }
  } catch (InvalidInputException e) {
    result.addFatalError(RefactoringCoreMessages.CommentAnalyzer_internal_error);
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:31,代码来源:CommentAnalyzer.java


示例20: isValidComment

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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ContainerPort类代码示例发布时间:2022-05-22
下一篇:
Java SetOwnerOp类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap