Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "API Document for Extension Points PDT"

(Extension Example)
(Extension Example)
Line 22: Line 22:
 
</extension>
 
</extension>
 
</pre>
 
</pre>
 
  
 
* Write the factory class:
 
* Write the factory class:

Revision as of 08:29, 9 July 2008

PHP Core

PHP Evaluator Factory

Extension Description

This extension point allows providing additional goal evaluator factories (IGoalEvaluatorFactory) thus overriding default PHP goal evaluator factory. Goal evaluator factory is a part of DLTK type inference engine, and it is used for creating evaluators that correspond to goals (see DDP algorithm for more information).

Extension Registry Algorithm

PHP Goal evaluators registry goes over all contributed extensions sorted by priority, and tries to resolve goal evaluator using current factory. The first that returns non-null goal evaluator is working - the rest are discarded.

Extension Example

Lets add a new goal and goal evaluator for resolving special Aspect PHP variable "$thisJoinPoint":

  • Create a new goal factory extension:
<extension point="org.eclipse.php.core.goalEvaluatorFactories">
  <factory
       class="org.eclipse.apdt.core.AspectPHPEvaluatorFactory"
       priority="100">
  </factory>
</extension>
  • Write the factory class:
public class AspectPHPEvaluatorFactory implements IGoalEvaluatorFactory {
	public GoalEvaluator createEvaluator(IGoal goal) {
		if (goal instanceof ExpressionTypeGoal) {
			ExpressionTypeGoal typedGoal = (ExpressionTypeGoal) goal;
			Expression expression = typedGoal.getExpression();
			if (expression instanceof VariableReference) {
				VariableReference varReference = (VariableReference) expression;
				if (varReference.getName().equals("$thisJoinPoint")) {
					return new ThisJoinPointEvaluator(typedGoal);
				}
			}
		}
		return null; // let other factories proceeed
	}
}
  • Implement the evaluator class:
public class ThisJoinPointEvaluator extends GoalEvaluator {
	private IEvaluatedType result;

	public IGoal[] init() {
		// Set result to the special builtin 'JoinPoint' type
		result = new JoinPointType();
		return IGoal.NO_GOALS;
	}
	public Object produceResult() {
		return result;
	}
	public IGoal[] subGoalDone(IGoal subgoal, Object result, GoalState state) {
		return IGoal.NO_GOALS;
	}
}

PHP Mixin Build Visitor

PHP Source Element Requestor

Back to the top