Examples of IEvaluationContext


Examples of org.eclipse.jdt.core.eval.IEvaluationContext

                }
            }
        };
        collector.acceptContext( new CompletionContext() );
        try {
            IEvaluationContext evalContext = javaProject.newEvaluationContext();
            evalContext.codeComplete( classNameStart,
                                      classNameStart.length(),
                                      collector );
            IJavaCompletionProposal[] proposals = collector.getJavaCompletionProposals();
            for ( int i = 0; i < proposals.length; i++ ) {
                if ( proposals[i] instanceof AbstractJavaCompletionProposal ) {
View Full Code Here

Examples of org.eclipse.jdt.core.eval.IEvaluationContext

        CompletionProposalCollector collector = new CompletionProposalCollector( javaProject );
        collector.acceptContext( new CompletionContext() );

        try {
            IEvaluationContext evalContext = javaProject.newEvaluationContext();
            List imports = getImports();
            if ( imports != null && imports.size() > 0 ) {
                evalContext.setImports( (String[]) imports.toArray( new String[imports.size()] ) );
            }
            StringBuffer javaTextWithParams = new StringBuffer();
            Iterator iterator = params.entrySet().iterator();
            while ( iterator.hasNext() ) {
                Map.Entry entry = (Map.Entry) iterator.next();
                // this does not seem to work, so adding variables manually
                // evalContext.newVariable((String) entry.getValue(), (String) entry.getKey(), null);
                javaTextWithParams.append( entry.getValue() + " " + entry.getKey() + ";\n" );
            }
            if (useDrools) {
                javaTextWithParams.append( "org.kie.api.runtime.rule.RuleContext kcontext;" );
            }
            if (useContext) {
                javaTextWithParams.append( "org.kie.api.runtime.process.ProcessContext kcontext;" );
            }
            javaTextWithParams.append( javaText );
            String jtext = javaTextWithParams.toString();
            String fixedText = new KnowledgeHelperFixer().fix( jtext );

            evalContext.codeComplete( fixedText,
                                      fixedText.length(),
                                      collector );
            IJavaCompletionProposal[] proposals = collector.getJavaCompletionProposals();
            for ( int i = 0; i < proposals.length; i++ ) {
                if ( proposals[i] instanceof AbstractJavaCompletionProposal ) {
View Full Code Here

Examples of org.eclipse.jdt.core.eval.IEvaluationContext

                }
            }
        };
        collector.acceptContext( new CompletionContext() );
        try {
            IEvaluationContext evalContext = javaProject.newEvaluationContext();
            evalContext.codeComplete( classNameStart,
                                      classNameStart.length(),
                                      collector );
            IJavaCompletionProposal[] proposals = collector.getJavaCompletionProposals();
            for ( int i = 0; i < proposals.length; i++ ) {
                if ( proposals[i] instanceof AbstractJavaCompletionProposal ) {
View Full Code Here

Examples of org.eclipse.jdt.core.eval.IEvaluationContext

        CompletionProposalCollector collector = new CompletionProposalCollector( javaProject );
        collector.acceptContext( new CompletionContext() );

        try {
            IEvaluationContext evalContext = javaProject.newEvaluationContext();
            List<String> imports = getImports();
            if ( imports != null && imports.size() > 0 ) {
                evalContext.setImports(imports.toArray(new String[imports.size()]));
            }
            StringBuffer javaTextWithParams = new StringBuffer();
            for (Entry<String, String> entry : params.entrySet()) {
                // this does not seem to work, so adding variables manually
                // evalContext.newVariable((String) entry.getValue(), (String) entry.getKey(), null);
                javaTextWithParams.append( entry.getValue() + " " + entry.getKey() + ";\n" );
            }
            if (useDrools) {
                javaTextWithParams.append( "org.kie.api.runtime.rule.RuleContext kcontext;" );
            }
            if (useContext) {
                javaTextWithParams.append( "org.kie.api.runtime.process.ProcessContext kcontext;" );
            }
            javaTextWithParams.append( javaText );
            String jtext = javaTextWithParams.toString();
            String fixedText = KnowledgeHelperFixer.fix(jtext);

            evalContext.codeComplete( fixedText,
                                      fixedText.length(),
                                      collector );
            IJavaCompletionProposal[] proposals = collector.getJavaCompletionProposals();
            for ( int i = 0; i < proposals.length; i++ ) {
                if ( proposals[i] instanceof AbstractJavaCompletionProposal ) {
View Full Code Here

Examples of org.eclipse.xtext.xbase.interpreter.IEvaluationContext

        final EObject executable = IterableExtensions.<EObject>head(_sourceElements);
        Object _xifexpression = null;
        if ((executable instanceof Executable)) {
          Object _xblockexpression_1 = null;
          {
            final IEvaluationContext context = this.createContext();
            QualifiedName _create = QualifiedName.create("this");
            context.newValue(_create, this.tortoise);
            int index = 0;
            EList<JvmFormalParameter> _parameters = operation.getParameters();
            for (final JvmFormalParameter param : _parameters) {
              {
                String _name = param.getName();
                QualifiedName _create_1 = QualifiedName.create(_name);
                Object _get = argumentValues.get(index);
                context.newValue(_create_1, _get);
                index = (index + 1);
              }
            }
            XBlockExpression _body = ((Executable)executable).getBody();
            final IEvaluationResult result = this.evaluate(_body, context, CancelIndicator.NullImpl);
View Full Code Here

Examples of org.eclipse.xtext.xbase.interpreter.IEvaluationContext

  @Override
  protected Object invokeOperation(JvmOperation operation, Object receiver, List<Object> argumentValues, IEvaluationContext c, CancelIndicator indicator) {
    XMethodDeclaration m = getMethodDeclaration(operation);
    if (m != null) {
      IEvaluationContext context = c.fork();
      int index = 0;
      for (JvmFormalParameter p : m.getParameters()) {
        context.newValue(QualifiedName.create(p.getName()), argumentValues.get(index));
        index++;
      }
      IEvaluationResult result = evaluate(m.getBody(), context, indicator);
      if (result.getException() != null) {
        result.getException().printStackTrace();
View Full Code Here

Examples of org.eclipse.xtext.xbase.interpreter.IEvaluationContext

    return null;
  }

  private String interpret(final Model m, final IProgressMonitor monitor) {
    final List<String> data = new ArrayList<String>();
    IEvaluationContext context = new DefaultEvaluationContext();
    context.newValue(qualifiedNameConverter.toQualifiedName(IModelQueryConstants.INFERRED_CLASS_NAME + "." + IModelQueryConstants.INDEX), resourceDescriptions);
    context.newValue(qualifiedNameConverter.toQualifiedName(IModelQueryConstants.INFERRED_CLASS_NAME + "." + IModelQueryConstants.RESOURCESET), resourceSetProvider.get());
    context.newValue(qualifiedNameConverter.toQualifiedName(IModelQueryConstants.INFERRED_CLASS_NAME + "." + IModelQueryConstants.INJECTOR), injector);
    for (XImportDeclaration i : m.getImports().getImportDeclarations()) {
      data.add(serializer.serialize(i).trim());
    }
    for (XMethodDeclaration d : m.getMethods()) {
      data.add(serializer.serialize(d).trim());
View Full Code Here

Examples of org.eclipse.xtext.xbase.interpreter.IEvaluationContext

        return ((RuleContextAdapter) adapter).getContext();
      }
    }
   
    // no evaluation context found, so create a new one
      IEvaluationContext evaluationContext = contextProvider.get();
      for(XExpression expr : ruleModel.getVariables()) {
        if (expr instanceof XVariableDeclaration) {
        XVariableDeclaration var = (XVariableDeclaration) expr;
        try {
            Object initialValue = var.getRight()==null ? null : scriptEngine.newScriptFromXExpression(var.getRight()).execute();
          evaluationContext.newValue(QualifiedName.create(var.getName()), initialValue);
        } catch (ScriptExecutionException e) {
          logger.warn("Variable '{}' on rule file '{}' cannot be initialized with value '{}': {}",
              new String[] { var.getName(), ruleModel.eResource().getURI().path(), var.getRight().toString(), e.getMessage() });
        }
      }
View Full Code Here

Examples of org.eclipse.xtext.xbase.interpreter.IEvaluationContext

  XExpression getXExpression() {
    return xExpression;
  }
 
  public Object execute() throws ScriptExecutionException {
      IEvaluationContext evaluationContext = contextProvider.get();
      return execute(evaluationContext);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.