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


Java TokenScanner.getNextStartOffset方法代码示例

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


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

示例1: getMemberStartOffset

import org.eclipse.jdt.internal.corext.dom.TokenScanner; //导入方法依赖的package包/类
private int getMemberStartOffset(IMember curr, IDocument document) throws JavaModelException {
	int offset= curr.getSourceRange().getOffset();
	TokenScanner scanner= new TokenScanner(document, curr.getJavaProject());
	try {
		return scanner.getNextStartOffset(offset, true); // read to the first real non comment token
	} catch (CoreException e) {
		// ignore
	}
	return offset;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:11,代码来源:AddJavaDocStubOperation.java

示例2: getNextElseOffset

import org.eclipse.jdt.internal.corext.dom.TokenScanner; //导入方法依赖的package包/类
private int getNextElseOffset(Statement then, ITypeRoot editorInput) {
	int thenEnd= ASTNodes.getExclusiveEnd(then);
	try {
		TokenScanner scanner= new TokenScanner(editorInput);
		return scanner.getNextStartOffset(thenEnd, true);
	} catch (CoreException e) {
		// ignore
	}
	return -1;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:11,代码来源:JavaSourceHover.java

示例3: initializeRanges

import org.eclipse.jdt.internal.corext.dom.TokenScanner; //导入方法依赖的package包/类
private void initializeRanges() throws CoreException {
  fRanges = new HashMap<ASTNode, SourceRange>();
  if (fSelectedNodes.length == 0) return;

  fRanges.put(fSelectedNodes[0], super.computeSourceRange(fSelectedNodes[0]));
  int last = fSelectedNodes.length - 1;
  fRanges.put(fSelectedNodes[last], super.computeSourceRange(fSelectedNodes[last]));

  IScanner scanner = ToolFactory.createScanner(true, false, false, false);
  char[] source = fDocumentPortionToScan.toCharArray();
  scanner.setSource(source);
  fDocumentPortionToScan = null; // initializeRanges() is only called once

  TokenScanner tokenizer = new TokenScanner(scanner);
  int pos = tokenizer.getNextStartOffset(0, false);

  ASTNode currentNode = fSelectedNodes[0];
  int newStart = Math.min(fSelectionStart + pos, currentNode.getStartPosition());
  SourceRange range = fRanges.get(currentNode);
  fRanges.put(
      currentNode,
      new SourceRange(newStart, range.getLength() + range.getStartPosition() - newStart));

  currentNode = fSelectedNodes[last];
  int scannerStart = currentNode.getStartPosition() + currentNode.getLength() - fSelectionStart;
  tokenizer.setOffset(scannerStart);
  pos = scannerStart;
  int token = -1;
  try {
    while (true) {
      token = tokenizer.readNext(false);
      pos = tokenizer.getCurrentEndOffset();
    }
  } catch (CoreException e) {
  }
  if (token == ITerminalSymbols.TokenNameCOMMENT_LINE) {
    int index = pos - 1;
    while (index >= 0 && IndentManipulation.isLineDelimiterChar(source[index])) {
      pos--;
      index--;
    }
  }

  int newEnd =
      Math.max(fSelectionStart + pos, currentNode.getStartPosition() + currentNode.getLength());
  range = fRanges.get(currentNode);
  fRanges.put(
      currentNode, new SourceRange(range.getStartPosition(), newEnd - range.getStartPosition()));
}
 
开发者ID:eclipse,项目名称:che,代码行数:50,代码来源:SelectionAwareSourceRangeComputer.java

示例4: initializeRanges

import org.eclipse.jdt.internal.corext.dom.TokenScanner; //导入方法依赖的package包/类
private void initializeRanges() throws CoreException {
	fRanges= new HashMap<ASTNode, SourceRange>();
	if (fSelectedNodes.length == 0)
		return;

	fRanges.put(fSelectedNodes[0], super.computeSourceRange(fSelectedNodes[0]));
	int last= fSelectedNodes.length - 1;
	fRanges.put(fSelectedNodes[last], super.computeSourceRange(fSelectedNodes[last]));

	IScanner scanner= ToolFactory.createScanner(true, false, false, false);
	char[] source= fDocumentPortionToScan.toCharArray();
	scanner.setSource(source);
	fDocumentPortionToScan= null; // initializeRanges() is only called once

	TokenScanner tokenizer= new TokenScanner(scanner);
	int pos= tokenizer.getNextStartOffset(0, false);

	ASTNode currentNode= fSelectedNodes[0];
	int newStart= Math.min(fSelectionStart + pos, currentNode.getStartPosition());
	SourceRange range= fRanges.get(currentNode);
	fRanges.put(currentNode, new SourceRange(newStart, range.getLength() + range.getStartPosition() - newStart));

	currentNode= fSelectedNodes[last];
	int scannerStart= currentNode.getStartPosition() + currentNode.getLength() - fSelectionStart;
	tokenizer.setOffset(scannerStart);
	pos= scannerStart;
	int token= -1;
	try {
		while (true) {
			token= tokenizer.readNext(false);
			pos= tokenizer.getCurrentEndOffset();
		}
	} catch (CoreException e) {
	}
	if (token == ITerminalSymbols.TokenNameCOMMENT_LINE) {
		int index= pos - 1;
		while (index >= 0 && IndentManipulation.isLineDelimiterChar(source[index])) {
			pos--;
			index--;
		}
	}

	int newEnd= Math.max(fSelectionStart + pos, currentNode.getStartPosition() + currentNode.getLength());
	range= fRanges.get(currentNode);
	fRanges.put(currentNode, new SourceRange(range.getStartPosition(), newEnd - range.getStartPosition()));
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:47,代码来源:SelectionAwareSourceRangeComputer.java


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