KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > eval > CodeSnippetCompiler


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.internal.eval;
12
13 import org.eclipse.jdt.internal.compiler.Compiler;
14 import org.eclipse.jdt.internal.compiler.ICompilerRequestor;
15 import org.eclipse.jdt.internal.compiler.IErrorHandlingPolicy;
16 import org.eclipse.jdt.internal.compiler.IProblemFactory;
17 import org.eclipse.jdt.internal.compiler.env.INameEnvironment;
18 import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
19
20 /**
21  * A compiler that compiles code snippets.
22  */

23 public class CodeSnippetCompiler extends Compiler JavaDoc {
24     
25     EvaluationContext evaluationContext;
26     int codeSnippetStart;
27     int codeSnippetEnd;
28     
29     /**
30      * Creates a new code snippet compiler initialized with a code snippet parser.
31      */

32     public CodeSnippetCompiler(
33             INameEnvironment environment,
34             IErrorHandlingPolicy policy,
35             CompilerOptions compilerOptions,
36             ICompilerRequestor requestor,
37             IProblemFactory problemFactory,
38             EvaluationContext evaluationContext,
39             int codeSnippetStart,
40             int codeSnippetEnd) {
41         super(environment, policy, compilerOptions, requestor, problemFactory);
42         this.codeSnippetStart = codeSnippetStart;
43         this.codeSnippetEnd = codeSnippetEnd;
44         this.evaluationContext = evaluationContext;
45         this.parser =
46             new CodeSnippetParser(
47                 this.problemReporter,
48                 evaluationContext,
49                 this.options.parseLiteralExpressionsAsConstants,
50                 codeSnippetStart,
51                 codeSnippetEnd);
52         this.parseThreshold = 1;
53         // fully parse only the code snippet compilation unit
54
}
55     
56     /* (non-Javadoc)
57      * @see org.eclipse.jdt.internal.compiler.Compiler#initializeParser()
58      */

59     public void initializeParser() {
60         this.parser =
61             new CodeSnippetParser(
62                 this.problemReporter,
63                 this.evaluationContext,
64                 this.options.parseLiteralExpressionsAsConstants,
65                 this.codeSnippetStart,
66                 this.codeSnippetEnd);
67         }
68 }
69
Popular Tags