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


Java PackageDeclaration.getStartPosition方法代码示例

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


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

示例1: createStubTypeContext

import org.eclipse.jdt.core.dom.PackageDeclaration; //导入方法依赖的package包/类
public static StubTypeContext createStubTypeContext(
    ICompilationUnit cu, CompilationUnit root, int focalPosition) throws CoreException {
  StringBuffer bufBefore = new StringBuffer();
  StringBuffer bufAfter = new StringBuffer();

  int introEnd = 0;
  PackageDeclaration pack = root.getPackage();
  if (pack != null) introEnd = pack.getStartPosition() + pack.getLength();
  List<ImportDeclaration> imports = root.imports();
  if (imports.size() > 0) {
    ImportDeclaration lastImport = imports.get(imports.size() - 1);
    introEnd = lastImport.getStartPosition() + lastImport.getLength();
  }
  bufBefore.append(cu.getBuffer().getText(0, introEnd));

  fillWithTypeStubs(bufBefore, bufAfter, focalPosition, root.types());
  bufBefore.append(' ');
  bufAfter.insert(0, ' ');
  return new StubTypeContext(cu, bufBefore.toString(), bufAfter.toString());
}
 
开发者ID:eclipse,项目名称:che,代码行数:21,代码来源:TypeContextChecker.java

示例2: createStubTypeContext

import org.eclipse.jdt.core.dom.PackageDeclaration; //导入方法依赖的package包/类
public static StubTypeContext createStubTypeContext(ICompilationUnit cu, CompilationUnit root, int focalPosition) throws CoreException {
	StringBuffer bufBefore= new StringBuffer();
	StringBuffer bufAfter= new StringBuffer();

	int introEnd= 0;
	PackageDeclaration pack= root.getPackage();
	if (pack != null)
		introEnd= pack.getStartPosition() + pack.getLength();
	List<ImportDeclaration> imports= root.imports();
	if (imports.size() > 0) {
		ImportDeclaration lastImport= imports.get(imports.size() - 1);
		introEnd= lastImport.getStartPosition() + lastImport.getLength();
	}
	bufBefore.append(cu.getBuffer().getText(0, introEnd));

	fillWithTypeStubs(bufBefore, bufAfter, focalPosition, root.types());
	bufBefore.append(' ');
	bufAfter.insert(0, ' ');
	return new StubTypeContext(cu, bufBefore.toString(), bufAfter.toString());
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:21,代码来源:TypeContextChecker.java

示例3: hasCopyrightsComment

import org.eclipse.jdt.core.dom.PackageDeclaration; //导入方法依赖的package包/类
/**
 * Checks whether {@link CompilationUnit} has copyright header
 *
 * @param compilationUnit
 *            checked compilation unit
 * @return true if {@link CompilationUnit} has copyright header
 */
public boolean hasCopyrightsComment(final CompilationUnit compilationUnit) {
	final List<Comment> comments = getCommentList(compilationUnit);
	boolean hasCopyrights = false;
	if (!comments.isEmpty()) {
		final PackageDeclaration packageNode = compilationUnit.getPackage();
		final boolean commentBeforePackage = comments.get(0).getStartPosition() <= packageNode.getStartPosition();
		final boolean hasJavaDoc = packageNode.getJavadoc() != null;
		hasCopyrights = commentBeforePackage || hasJavaDoc;
	}
	return hasCopyrights;
}
 
开发者ID:SAP,项目名称:hybris-commerce-eclipse-plugin,代码行数:19,代码来源:CopyrightManager.java

示例4: getPackageStatementEndPos

import org.eclipse.jdt.core.dom.PackageDeclaration; //导入方法依赖的package包/类
private int getPackageStatementEndPos(CompilationUnit root) {
	PackageDeclaration packDecl= root.getPackage();
	if (packDecl != null) {
		int afterPackageStatementPos= -1;
		int lineNumber= root.getLineNumber(packDecl.getStartPosition() + packDecl.getLength());
		if (lineNumber >= 0) {
			int lineAfterPackage= lineNumber + 1;
			afterPackageStatementPos= root.getPosition(lineAfterPackage, 0);
		}
		if (afterPackageStatementPos < 0) {
			this.flags|= F_NEEDS_LEADING_DELIM;
			return packDecl.getStartPosition() + packDecl.getLength();
		}
		int firstTypePos= getFirstTypeBeginPos(root);
		if (firstTypePos != -1 && firstTypePos <= afterPackageStatementPos) {
			this.flags|= F_NEEDS_TRAILING_DELIM;
			if (firstTypePos == afterPackageStatementPos) {
				this.flags|= F_NEEDS_LEADING_DELIM;
			}
			return firstTypePos;
		}
		this.flags|= F_NEEDS_LEADING_DELIM;
		return afterPackageStatementPos; // insert a line after after package statement
	}
	this.flags |= F_NEEDS_TRAILING_DELIM;
	return 0;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:28,代码来源:ImportRewriteAnalyzer.java

示例5: visit

import org.eclipse.jdt.core.dom.PackageDeclaration; //导入方法依赖的package包/类
@Override
public boolean visit(PackageDeclaration node) {
       new JavaNode(getCurrentContainer(), JavaNode.PACKAGE, null, node.getStartPosition(), node.getLength());
       return false;
   }
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:6,代码来源:JavaParseTreeBuilder.java


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