本文整理匯總了Java中org.eclipse.jdt.core.dom.ASTParser.setFocalPosition方法的典型用法代碼示例。如果您正苦於以下問題:Java ASTParser.setFocalPosition方法的具體用法?Java ASTParser.setFocalPosition怎麽用?Java ASTParser.setFocalPosition使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jdt.core.dom.ASTParser
的用法示例。
在下文中一共展示了ASTParser.setFocalPosition方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: parsePartialCompilationUnit
import org.eclipse.jdt.core.dom.ASTParser; //導入方法依賴的package包/類
static CompilationUnit parsePartialCompilationUnit(ICompilationUnit unit) {
if (unit == null) {
throw new IllegalArgumentException();
}
try {
ASTParser c= ASTParser.newParser(ASTProvider.SHARED_AST_LEVEL);
c.setSource(unit);
c.setFocalPosition(0);
c.setResolveBindings(false);
c.setWorkingCopyOwner(null);
ASTNode result= c.createAST(null);
return (CompilationUnit) result;
} catch (IllegalStateException e) {
// convert ASTParser's complaints into old form
throw new IllegalArgumentException();
}
}
示例2: visitCompilationUnit
import org.eclipse.jdt.core.dom.ASTParser; //導入方法依賴的package包/類
private void visitCompilationUnit(IFile file) {
ICompilationUnit cu= JavaCore.createCompilationUnitFrom(file);
if (cu != null) {
ASTParser parser= ASTParser.newParser(ASTProvider.SHARED_AST_LEVEL);
parser.setSource(cu);
parser.setFocalPosition(0);
CompilationUnit root= (CompilationUnit)parser.createAST(null);
PackageDeclaration packDecl= root.getPackage();
IPath packPath= file.getParent().getFullPath();
String cuName= file.getName();
if (packDecl == null) {
addToMap(fSourceFolders, packPath, new Path(cuName));
} else {
IPath relPath= new Path(packDecl.getName().getFullyQualifiedName().replace('.', '/'));
IPath folderPath= getFolderPath(packPath, relPath);
if (folderPath != null) {
addToMap(fSourceFolders, folderPath, relPath.append(cuName));
}
}
}
}
示例3: createASTForImports
import org.eclipse.jdt.core.dom.ASTParser; //導入方法依賴的package包/類
private CompilationUnit createASTForImports(ICompilationUnit cu) {
ASTParser parser= ASTParser.newParser(ASTProvider.SHARED_AST_LEVEL);
parser.setSource(cu);
parser.setResolveBindings(true);
parser.setFocalPosition(0);
return (CompilationUnit) parser.createAST(null);
}
示例4: createStructureComparator
import org.eclipse.jdt.core.dom.ASTParser; //導入方法依賴的package包/類
private IStructureComparator createStructureComparator(final Object input, char[] buffer, IDocument doc, ISharedDocumentAdapter adapter, IProgressMonitor monitor) {
String contents;
Map<String, String> compilerOptions= null;
if (input instanceof IResourceProvider) {
IResource resource= ((IResourceProvider) input).getResource();
if (resource != null) {
IJavaElement element= JavaCore.create(resource);
if (element != null) {
IJavaProject javaProject= element.getJavaProject();
if (javaProject != null)
compilerOptions= javaProject.getOptions(true);
}
}
}
if (compilerOptions == null)
compilerOptions= fDefaultCompilerOptions;
if (doc != null) {
boolean isEditable= false;
if (input instanceof IEditableContent)
isEditable= ((IEditableContent) input).isEditable();
// we hook into the root node to intercept all node changes
JavaNode root= new RootJavaNode(doc, isEditable, input, adapter);
if (buffer == null) {
contents= doc.get();
int n= contents.length();
buffer= new char[n];
contents.getChars(0, n, buffer, 0);
}
ASTParser parser= ASTParser.newParser(ASTProvider.SHARED_AST_LEVEL);
if (compilerOptions != null)
parser.setCompilerOptions(compilerOptions);
parser.setSource(buffer);
parser.setFocalPosition(0);
CompilationUnit cu= (CompilationUnit) parser.createAST(monitor);
cu.accept(new JavaParseTreeBuilder(root, buffer, true));
return root;
}
return null;
}