/** * @see IJavaProject#newEvaluationContext() */ @Override public IEvaluationContext newEvaluationContext() { EvaluationContext context = new EvaluationContext(); context.setLineSeparator(Util.getLineSeparator(null/*no existing source*/, this)); return new EvaluationContextWrapper(context, this); }
/** * @see org.eclipse.jdt.core.eval.IEvaluationContext#allVariables() */ public IGlobalVariable[] allVariables() { GlobalVariable[] vars = this.context.allVariables(); int length = vars.length; GlobalVariableWrapper[] result = new GlobalVariableWrapper[length]; for (int i = 0; i < length; i++) { result[i] = new GlobalVariableWrapper(vars[i]); } return result; } /**
/** * @see org.eclipse.jdt.core.eval.IEvaluationContext#deleteVariable(IGlobalVariable) */ public void deleteVariable(IGlobalVariable variable) { if (variable instanceof GlobalVariableWrapper) { GlobalVariableWrapper wrapper = (GlobalVariableWrapper)variable; this.context.deleteVariable(wrapper.variable); } else { throw new Error("Unknown implementation of IGlobalVariable"); //$NON-NLS-1$ } } /**
this.context.setPackageName(declaringType.getPackageFragment().getElementName().toCharArray()); ICompilationUnit compilationUnit = declaringType.getCompilationUnit(); if (compilationUnit != null) { importsNames[i] = imports[i].getElementName().toCharArray(); this.context.setImports(importsNames); char[][] imports = sourceMapper.getImports((BinaryType) declaringType); if (imports != null) { this.context.setImports(imports); this.context.evaluate( codeSnippet.toCharArray(), varTypeNames,
this.isConstructorCall = contextIsConstructorCall; deployCodeSnippetClassIfNeeded(requestor); evaluateVariables(environment, options, forwardingRequestor, problemFactory); char[] pkgName = getPackageName(); char[] qualifiedClassName = pkgName.length == 0 ?
evaluateVariables(environment, options, variableRequestor, new DefaultProblemFactory(Locale.getDefault())); } catch (InstallException e) { IBinaryType binaryType = getRootCodeSnippetBinary(); if (binaryType != null) {
/** * @see org.eclipse.jdt.core.eval.IEvaluationContext * @exception org.eclipse.jdt.internal.eval.InstallException if the code snippet class files could not be deployed. */ public void evaluate(char[] codeSnippet, INameEnvironment environment, Map<String, String> options, final IRequestor requestor, IProblemFactory problemFactory) throws InstallException { this.evaluate( codeSnippet, null, null, null, null, true, false, environment, options, requestor, problemFactory); } /**
@Override public byte[] getBytes() { return getCodeSnippetBytes(); } @Override
/** * @see IEvaluationContext#validateImports(ICodeSnippetRequestor) */ public void validateImports(ICodeSnippetRequestor requestor) { checkBuilderState(); INameEnvironment environment = null; try { this.context.evaluateImports( environment = getBuildNameEnvironment(), getInfrastructureEvaluationRequestor(requestor), getProblemFactory()); } finally { if (environment != null) environment.cleanup(); } } /**
/** * @see IEvaluationContext#evaluateVariable(IGlobalVariable, ICodeSnippetRequestor, IProgressMonitor) */ public void evaluateVariable(IGlobalVariable variable, ICodeSnippetRequestor requestor, IProgressMonitor progressMonitor) throws JavaModelException { checkBuilderState(); INameEnvironment environment = null; try { this.context.evaluateVariable( ((GlobalVariableWrapper)variable).variable, environment = getBuildNameEnvironment(), this.project.getOptions(true), getInfrastructureEvaluationRequestor(requestor), getProblemFactory()); } catch (InstallException e) { handleInstallException(e); } finally { if (environment != null) environment.cleanup(); } } /**
/** * @see org.eclipse.jdt.core.eval.IEvaluationContext#codeComplete(String, int, CompletionRequestor, WorkingCopyOwner, IProgressMonitor) */ @Override public void codeComplete( String codeSnippet, int position, CompletionRequestor requestor, WorkingCopyOwner owner, IProgressMonitor monitor) throws JavaModelException { SearchableEnvironment environment = this.project.newSearchableNameEnvironment(owner); this.context.complete( codeSnippet.toCharArray(), position, environment, requestor, this.project.getOptions(true), this.project, owner, monitor ); } /**
deployCodeSnippetClassIfNeeded(requestor); VariablesEvaluator evaluator = new VariablesEvaluator(this, environment, options, requestor, problemFactory); ClassFile[] classes = evaluator.getClasses();
this.context.setPackageName(declaringType.getPackageFragment().getElementName().toCharArray()); ICompilationUnit compilationUnit = declaringType.getCompilationUnit(); if (compilationUnit != null) { importsNames[i] = imports[i].getElementName().toCharArray(); this.context.setImports(importsNames); char[][] imports = sourceMapper.getImports((BinaryType) declaringType); if (imports != null) { this.context.setImports(imports); this.context.evaluate( codeSnippet.toCharArray(), varTypeNames,
this.isConstructorCall = contextIsConstructorCall; deployCodeSnippetClassIfNeeded(requestor); evaluateVariables(environment, options, forwardingRequestor, problemFactory); char[] pkgName = getPackageName(); char[] qualifiedClassName = pkgName.length == 0 ?
evaluateVariables(environment, options, variableRequestor, new DefaultProblemFactory(Locale.getDefault())); } catch (InstallException e) { IBinaryType binaryType = getRootCodeSnippetBinary(); if (binaryType != null) {
/** * @see org.eclipse.jdt.core.eval.IEvaluationContext * @exception org.eclipse.jdt.internal.eval.InstallException if the code snippet class files could not be deployed. */ public void evaluate(char[] codeSnippet, INameEnvironment environment, Map<String, String> options, final IRequestor requestor, IProblemFactory problemFactory) throws InstallException { this.evaluate( codeSnippet, null, null, null, null, true, false, environment, options, requestor, problemFactory); } /**
public byte[] getBytes() { return getCodeSnippetBytes(); } public char[][] getCompoundName() {
/** * @see IEvaluationContext#validateImports(ICodeSnippetRequestor) */ @Override public void validateImports(ICodeSnippetRequestor requestor) { checkBuilderState(); INameEnvironment environment = null; try { this.context.evaluateImports( environment = getBuildNameEnvironment(), getInfrastructureEvaluationRequestor(requestor), getProblemFactory()); } finally { if (environment != null) environment.cleanup(); } } /**
/** * @see IEvaluationContext#evaluateVariable(IGlobalVariable, ICodeSnippetRequestor, IProgressMonitor) */ public void evaluateVariable(IGlobalVariable variable, ICodeSnippetRequestor requestor, IProgressMonitor progressMonitor) throws JavaModelException { checkBuilderState(); INameEnvironment environment = null; try { this.context.evaluateVariable( ((GlobalVariableWrapper)variable).variable, environment = getBuildNameEnvironment(), this.project.getOptions(true), getInfrastructureEvaluationRequestor(requestor), getProblemFactory()); } catch (InstallException e) { handleInstallException(e); } finally { if (environment != null) environment.cleanup(); } } /**
/** * @see org.eclipse.jdt.core.eval.IEvaluationContext#codeComplete(String, int, CompletionRequestor, WorkingCopyOwner, IProgressMonitor) */ public void codeComplete( String codeSnippet, int position, CompletionRequestor requestor, WorkingCopyOwner owner, IProgressMonitor monitor) throws JavaModelException { SearchableEnvironment environment = this.project.newSearchableNameEnvironment(owner); this.context.complete( codeSnippet.toCharArray(), position, environment, requestor, this.project.getOptions(true), this.project, owner, monitor ); } /**