Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 78520 Details for
Bug 87852
ASTParser fails when called from another program
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Patch allows use of ASTParser to generate bindings outside of Eclipse environment
bindings_patch.txt (text/plain), 7.98 KB, created by
Alexei Svitkine
on 2007-09-16 19:33:55 EDT
(
hide
)
Description:
Patch allows use of ASTParser to generate bindings outside of Eclipse environment
Filename:
MIME Type:
Creator:
Alexei Svitkine
Created:
2007-09-16 19:33:55 EDT
Size:
7.98 KB
patch
obsolete
>Index: dom/org/eclipse/jdt/core/dom/ASTParser.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTParser.java,v >retrieving revision 1.76 >diff -w -u -b -r1.76 ASTParser.java >--- dom/org/eclipse/jdt/core/dom/ASTParser.java 14 Sep 2007 19:37:26 -0000 1.76 >+++ dom/org/eclipse/jdt/core/dom/ASTParser.java 16 Sep 2007 23:31:23 -0000 >@@ -27,6 +27,7 @@ > import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration; > import org.eclipse.jdt.internal.compiler.ast.ConstructorDeclaration; > import org.eclipse.jdt.internal.compiler.env.IBinaryType; >+import org.eclipse.jdt.internal.compiler.env.INameEnvironment; > import org.eclipse.jdt.internal.compiler.parser.RecoveryScanner; > import org.eclipse.jdt.internal.compiler.parser.RecoveryScannerData; > import org.eclipse.jdt.internal.compiler.parser.Scanner; >@@ -197,6 +198,16 @@ > */ > private String unitName = null; > >+ private INameEnvironment environment = null; >+ >+ public INameEnvironment getEnvironment() { >+ return environment; >+ } >+ >+ public void setEnvironment(INameEnvironment environment) { >+ this.environment = environment; >+ } >+ > /** > * Creates a new AST parser for the given API level. > * <p> >@@ -852,6 +863,9 @@ > } > } else if (this.rawSource != null) { > needToResolveBindings = this.resolveBindings && this.unitName != null && this.project != null && this.compilerOptions != null; >+ if (!needToResolveBindings && this.resolveBindings && this.environment != null) { >+ needToResolveBindings = true; >+ } > sourceUnit = new BasicCompilationUnit(this.rawSource, null, this.unitName == null ? "" : this.unitName, this.project); //$NON-NLS-1$ > } else { > throw new IllegalStateException(); >@@ -865,6 +879,16 @@ > if (this.bindingsRecovery) flags |= ICompilationUnit.ENABLE_BINDINGS_RECOVERY; > try { > // parse and resolve >+ if (environment != null) { >+ compilationUnitDeclaration = >+ CompilationUnitResolver.resolve( >+ sourceUnit, >+ this.environment, >+ searcher, >+ this.compilerOptions, >+ flags, >+ monitor); >+ } else { > compilationUnitDeclaration = > CompilationUnitResolver.resolve( > sourceUnit, >@@ -874,6 +898,7 @@ > this.workingCopyOwner, > flags, > monitor); >+ } > } catch (JavaModelException e) { > flags &= ~ICompilationUnit.ENABLE_BINDINGS_RECOVERY; > compilationUnitDeclaration = CompilationUnitResolver.parse( >Index: dom/org/eclipse/jdt/core/dom/CompilationUnitResolver.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/CompilationUnitResolver.java,v >retrieving revision 1.124 >diff -w -u -b -r1.124 CompilationUnitResolver.java >--- dom/org/eclipse/jdt/core/dom/CompilationUnitResolver.java 16 Mar 2007 18:28:58 -0000 1.124 >+++ dom/org/eclipse/jdt/core/dom/CompilationUnitResolver.java 16 Sep 2007 23:31:23 -0000 >@@ -488,6 +488,57 @@ > } > } > } >+ >+ public static CompilationUnitDeclaration resolve( >+ org.eclipse.jdt.internal.compiler.env.ICompilationUnit sourceUnit, >+ INameEnvironment environment, >+ NodeSearcher nodeSearcher, >+ Map options, >+ int flags, >+ IProgressMonitor monitor) throws JavaModelException { >+ >+ CompilationUnitDeclaration unit = null; >+ CancelableProblemFactory problemFactory = null; >+ CompilationUnitResolver resolver = null; >+ try { >+ problemFactory = new CancelableProblemFactory(monitor); >+ resolver = >+ new CompilationUnitResolver( >+ environment, >+ getHandlingPolicy(), >+ getCompilerOptions(options, (flags & ICompilationUnit.ENABLE_STATEMENTS_RECOVERY) != 0), >+ getRequestor(), >+ problemFactory, >+ monitor); >+ >+ unit = >+ resolver.resolve( >+ null, // no existing compilation unit declaration >+ sourceUnit, >+ nodeSearcher, >+ true, // method verification >+ true, // analyze code >+ true); // generate code >+ if (resolver.hasCompilationAborted) { >+ // the bindings could not be resolved due to missing types in name environment >+ // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=86541 >+ CompilationUnitDeclaration unitDeclaration = parse(sourceUnit, nodeSearcher, options, flags); >+ final int problemCount = unit.compilationResult.problemCount; >+ if (problemCount != 0) { >+ unitDeclaration.compilationResult.problems = new CategorizedProblem[problemCount]; >+ System.arraycopy(unit.compilationResult.problems, 0, unitDeclaration.compilationResult.problems, 0, problemCount); >+ unitDeclaration.compilationResult.problemCount = problemCount; >+ } >+ return unitDeclaration; >+ } >+ return unit; >+ } finally { >+ if (problemFactory != null) { >+ problemFactory.monitor = null; // don't hold a reference to this external object >+ } >+ } >+ } >+ > public static CompilationUnitDeclaration resolve( > org.eclipse.jdt.internal.compiler.env.ICompilationUnit sourceUnit, > IJavaProject javaProject,
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 87852
: 78520