本文整理匯總了Java中org.eclipse.jdt.core.dom.ASTParser.setWorkingCopyOwner方法的典型用法代碼示例。如果您正苦於以下問題:Java ASTParser.setWorkingCopyOwner方法的具體用法?Java ASTParser.setWorkingCopyOwner怎麽用?Java ASTParser.setWorkingCopyOwner使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jdt.core.dom.ASTParser
的用法示例。
在下文中一共展示了ASTParser.setWorkingCopyOwner方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: getCuNode
import org.eclipse.jdt.core.dom.ASTParser; //導入方法依賴的package包/類
private static CompilationUnit getCuNode(WorkingCopyOwner workingCopyOwner, ICompilationUnit cu) {
ASTParser p = ASTParser.newParser(ASTProvider.SHARED_AST_LEVEL);
p.setSource(cu);
p.setResolveBindings(true);
p.setWorkingCopyOwner(workingCopyOwner);
p.setCompilerOptions(RefactoringASTParser.getCompilerOptions(cu));
return (CompilationUnit) p.createAST(null);
}
示例3: getCuNode
import org.eclipse.jdt.core.dom.ASTParser; //導入方法依賴的package包/類
private static CompilationUnit getCuNode(WorkingCopyOwner workingCopyOwner, ICompilationUnit cu) {
ASTParser p = ASTParser.newParser(ASTProvider.SHARED_AST_LEVEL);
p.setSource(cu);
p.setResolveBindings(true);
p.setWorkingCopyOwner(workingCopyOwner);
p.setCompilerOptions(RefactoringASTParser.getCompilerOptions(cu));
return (CompilationUnit) p.createAST(null);
}
示例4: createChangeManager
import org.eclipse.jdt.core.dom.ASTParser; //導入方法依賴的package包/類
/**
* Creates the text change manager for this processor.
*
* @param monitor
* the progress monitor to display progress
* @param status
* the refactoring status
* @return the created text change manager
* @throws JavaModelException
* if the method declaration could not be found
* @throws CoreException
* if the changes could not be generated
*/
protected final TextEditBasedChangeManager createChangeManager(final IProgressMonitor monitor, final RefactoringStatus status) throws JavaModelException, CoreException {
Assert.isNotNull(status);
Assert.isNotNull(monitor);
try {
monitor.beginTask("", 300); //$NON-NLS-1$
monitor.setTaskName(RefactoringCoreMessages.UseSuperTypeProcessor_creating);
final TextEditBasedChangeManager manager= new TextEditBasedChangeManager();
final IJavaProject project= fSubType.getJavaProject();
final ASTParser parser= ASTParser.newParser(ASTProvider.SHARED_AST_LEVEL);
parser.setWorkingCopyOwner(fOwner);
parser.setResolveBindings(true);
parser.setProject(project);
parser.setCompilerOptions(RefactoringASTParser.getCompilerOptions(project));
if (fSubType.isBinary() || fSubType.isReadOnly()) {
final IBinding[] bindings= parser.createBindings(new IJavaElement[] { fSubType, fSuperType }, new SubProgressMonitor(monitor, 50));
if (bindings != null && bindings.length == 2 && bindings[0] instanceof ITypeBinding && bindings[1] instanceof ITypeBinding) {
solveSuperTypeConstraints(null, null, fSubType, (ITypeBinding) bindings[0], (ITypeBinding) bindings[1], new SubProgressMonitor(monitor, 100), status);
if (!status.hasFatalError())
rewriteTypeOccurrences(manager, null, null, null, null, new HashSet<String>(), status, new SubProgressMonitor(monitor, 150));
}
} else {
parser.createASTs(new ICompilationUnit[] { fSubType.getCompilationUnit() }, new String[0], new ASTRequestor() {
@Override
public final void acceptAST(final ICompilationUnit unit, final CompilationUnit node) {
try {
final CompilationUnitRewrite subRewrite= new CompilationUnitRewrite(fOwner, unit, node);
final AbstractTypeDeclaration subDeclaration= ASTNodeSearchUtil.getAbstractTypeDeclarationNode(fSubType, subRewrite.getRoot());
if (subDeclaration != null) {
final ITypeBinding subBinding= subDeclaration.resolveBinding();
if (subBinding != null) {
final ITypeBinding superBinding= findTypeInHierarchy(subBinding, fSuperType.getFullyQualifiedName('.'));
if (superBinding != null) {
solveSuperTypeConstraints(subRewrite.getCu(), subRewrite.getRoot(), fSubType, subBinding, superBinding, new SubProgressMonitor(monitor, 100), status);
if (!status.hasFatalError()) {
rewriteTypeOccurrences(manager, this, subRewrite, subRewrite.getCu(), subRewrite.getRoot(), new HashSet<String>(), status, new SubProgressMonitor(monitor, 200));
final TextChange change= subRewrite.createChange(true);
if (change != null)
manager.manage(subRewrite.getCu(), change);
}
}
}
}
} catch (CoreException exception) {
JavaPlugin.log(exception);
status.merge(RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.UseSuperTypeProcessor_internal_error));
}
}
@Override
public final void acceptBinding(final String key, final IBinding binding) {
// Do nothing
}
}, new NullProgressMonitor());
}
return manager;
} finally {
monitor.done();
}
}
示例5: rewriteTypeOccurrences
import org.eclipse.jdt.core.dom.ASTParser; //導入方法依賴的package包/類
protected void rewriteTypeOccurrences(final TextEditBasedChangeManager manager, final CompilationUnitRewrite sourceRewrite, final ICompilationUnit copy, final Set<String> replacements, final RefactoringStatus status, final IProgressMonitor monitor) {
try {
monitor.beginTask("", 100); //$NON-NLS-1$
monitor.setTaskName(RefactoringCoreMessages.PullUpRefactoring_checking);
final IType declaring= getDeclaringType();
final IJavaProject project= declaring.getJavaProject();
final ASTParser parser= ASTParser.newParser(ASTProvider.SHARED_AST_LEVEL);
parser.setWorkingCopyOwner(fOwner);
parser.setResolveBindings(true);
parser.setProject(project);
parser.setCompilerOptions(RefactoringASTParser.getCompilerOptions(project));
parser.createASTs(new ICompilationUnit[] { copy}, new String[0], new ASTRequestor() {
@Override
public final void acceptAST(final ICompilationUnit unit, final CompilationUnit node) {
try {
final IType subType= (IType) JavaModelUtil.findInCompilationUnit(unit, declaring);
final AbstractTypeDeclaration subDeclaration= ASTNodeSearchUtil.getAbstractTypeDeclarationNode(subType, node);
if (subDeclaration != null) {
final ITypeBinding subBinding= subDeclaration.resolveBinding();
if (subBinding != null) {
String name= null;
ITypeBinding superBinding= null;
final ITypeBinding[] superBindings= Bindings.getAllSuperTypes(subBinding);
for (int index= 0; index < superBindings.length; index++) {
name= superBindings[index].getName();
if (name.startsWith(fDestinationType.getElementName()))
superBinding= superBindings[index];
}
if (superBinding != null) {
solveSuperTypeConstraints(unit, node, subType, subBinding, superBinding, new SubProgressMonitor(monitor, 80), status);
if (!status.hasFatalError())
rewriteTypeOccurrences(manager, this, sourceRewrite, unit, node, replacements, status, new SubProgressMonitor(monitor, 120));
}
}
}
} catch (JavaModelException exception) {
JavaPlugin.log(exception);
status.merge(RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ExtractInterfaceProcessor_internal_error));
}
}
@Override
public final void acceptBinding(final String key, final IBinding binding) {
// Do nothing
}
}, new NullProgressMonitor());
} finally {
monitor.done();
}
}