Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[pdt-dev] Type inference using reference value

Hi!
I've read and implemented a plugin for extending PDT to achieve the type reference hinting (works just out of the box), as described on the wiki page: http://wiki.eclipse.org/Extending_PDT_2.2
$myObject = ClassRegistry::init('MyClass');

Now, I have another use case when I want to to do the same creation but using a constant or variable. E.g.:

class SomeClass {
    const MY_CONSTANT = 'MyClass';
...
$myObject = ClassRegistry::init(SomeClass::MY_CONSTANT);

or:

const MY_CONSTANT = 'MyClass';
...
$myObject = ClassRegistry::init(self::MY_CONSTANT);

or:

$className = ''MyClass;
$myObject = ClassRegistry::init($className);


I figured I need to evaluate that input somehow in my implementing GoalEvaluator, something like:

...
public Object produceResult() {
    var String className = "DummyClassForNow";
    /* todo: evaluate and fetch value of constant or variable. */
    
    return new PHPClassType(className);
}

But I am not sure how to actually do that. Can someone point me in the right direction?

Thanks!

---

Nicklas Gummesson

Back to the top