Major Feature #13226

CodeAssist

Added by Martin Eisengardt over 4 years ago.

Status:New Start date:2011-02-21
Priority:Should have Due date:
Assigned To:- % Done:

0%

Category:-
Target version:-

Description

Some hacks to support some Code Assist.

1. Support objectManager->create and objectManager->get
2. Support the following phpdoc syntax (those are non-standard meaning that they are not mentioned as valid datatypes in the phpdoc manual):
@param/@var/@return array(FooObject)
@param/@var/@return ArrayObject(FooObject)
@param/@var/@return SplObjectStorage(FooObject)
@param/@var/@return array[FooObject]
@param/@var/@return ArrayObject(FooObject)
@param/@var/@return SplObjectStorage(FooObject)
@param/@var/@return FooObject[]
Maybe those syntax should become some kind of flow3 convetion to help others. Currently it seems that only some IDEs support array in PHPDoc.
3. Support foreach (array syntax seen above)
4. Support repository methods (findByUuid, fineAll, findOneBy..., findBy...)
This is realized in class Flow3RepositoryEvaluator. The method evaluateTypeFromRepos trys to read the field $objectType of the associated Repository class. Within my project I have a convention that every repository sets this field and that the interfaces of a repository is located in a DatabaseApi package and the realization in a DatabaseImpl package. The logic may be changed to fit the flow3 specificated (maybe reading the Objects.yaml or guess the entity class name if the field $objectType is not set).

An example where code assist will work:

foreach ($repository->findAll() as $object)
{
    $object->| // here the code assist will work without any additional @var
}

$result = $repository->findByMySpecialSecretAttribute($value);
$array = $result->| // maps to query result methods
foreach ($result as $object)
{
    $object->| // iterating over this query result works too
}
while ($result->valid()
{
    $result->current()->| // even accessing the current object will work
    $result->next();
}

plugin.xml (relevant snippet):

   <extension
         point="org.eclipse.php.core.goalEvaluatorFactories">
      <factory class="com.netplayworld.xworlds.uml.goals.Flow3FactoryEvaluator" priority="100" />
      <factory
            class="com.netplayworld.xworlds.uml.goals.Flow3RepositoryEvaluator" 
            priority="100">
      </factory>
      <factory
            class="com.netplayworld.xworlds.uml.goals.ArrayEvaluator" 
            priority="100">
      </factory>
   </extension>

see the attached classes. Feel free to use/copy them. Please keep the original author (net-playworld and mepeisen). thx.

ArrayEvaluator.java Magnifier (9.4 kB) Martin Eisengardt, 2011-02-21 14:20

Flow3FactoryEvaluator.java Magnifier (4 kB) Martin Eisengardt, 2011-02-21 14:20

Flow3RepositoryEvaluator.java Magnifier (13.4 kB) Martin Eisengardt, 2011-02-21 14:20

Also available in: Atom PDF