本文整理汇总了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());
}
示例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());
}
示例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;
}
示例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;
}
示例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;
}