Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

API Document for Extension Points PDT

Revision as of 08:50, 9 July 2008 by Spektom.gmail.com (Talk | contribs) (PHP Source Element Requestor)

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

Extension Description

This extension point allows providing additional visitors for Mixin Parser Build Visitor. Mixin model represents global workspace-scope database for model elements that are stored in a special index, and can be easily accessed using special key (for more details refer to DLTK Core Architecture).

Extension Registry Algorithm

PHP Mixin Parser first calls to the PHP Mixin Build Visitor, which builds Mixin model for most of PHP elements. Then it calls to all other extensions, thus allowing them to complete Mixin index with other potential model elements.

Extension Example

PHP Source Element Requestor

Extension Description

This extension point allows intervention into structured model build process for contribution additional model elements. Structured model (IModuleElement hierarchy) is used to present elements structure in script explorer, outline, search, code completion, code selection, etc... This model consists only from top level elements, like: IType, IMethod, IField. If additional element type is considered to be added - it must derive from one of those basic types.

Back to the top