Changeset 85b4650e22de85722d0e932da31e0104e8a88327

Show
Ignore:
Timestamp:
06/28/09 23:36:49 (8 months ago)
Author:
mb0 <mb0@…>
git-author:
mb0 <mb0@mb0.org> / 2009-06-05T02:52:06Z+0200
Parents:
369d8ecb6239f8f96d0abe435a0b50d8fbaabb9a
Children:
c598ac61d680bc607baa6ff4a8fbb9447b6cf4ed
git-committer:
mb0 <mb0@mb0.org> / 2009-06-28T23:36:49Z+0200
Message:

axentry has now a transient reference property to the axnode
axnode can be created from any concrete axindexnode
index0r initializes preferences on singleton creation
axdoc has now a preference with table editor

Files:
3 added
22 modified

Legend:

Unmodified
Added
Removed
  • org.axdt.axdoc.model/model/AXDoc.ecore

    r87f02d1 r85b4650  
    4343      <eParameters name="part" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/> 
    4444    </eOperations> 
    45     <eOperations name="getOrCreatePackage" eType="#//AXPackage"/> 
     45    <eOperations name="getOrCreateReference" eType="#//AXPackage"/> 
    4646    <eStructuralFeatures xsi:type="ecore:EReference" name="reference" eType="#//AXPackage"/> 
    4747    <eStructuralFeatures xsi:type="ecore:EAttribute" name="level" eType="#//AXLevel" 
     
    7474    <eStructuralFeatures xsi:type="ecore:EReference" name="parent" eType="#//AXIndexNode" 
    7575        transient="true" eOpposite="#//AXIndexNode/entries"/> 
     76    <eStructuralFeatures xsi:type="ecore:EReference" name="reference" eType="#//AXNode" 
     77        transient="true"/> 
    7678  </eClassifiers> 
    7779  <eClassifiers xsi:type="ecore:EClass" name="AXIndexNode" abstract="true"> 
     
    8991      <eParameters name="type" eType="#//AXEntryType"/> 
    9092    </eOperations> 
     93    <eOperations name="getOrCreateReference" eType="#//AXNode"/> 
    9194    <eStructuralFeatures xsi:type="ecore:EAttribute" name="name" lowerBound="1" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/> 
    9295    <eStructuralFeatures xsi:type="ecore:EReference" name="entries" upperBound="-1" 
  • org.axdt.axdoc.model/src/org/axdt/axdoc/model/AXDocPackage.java

    r79dd699 r85b4650  
    665665 
    666666        /** 
     667         * The feature id for the '<em><b>Reference</b></em>' reference. 
     668         * <!-- begin-user-doc --> 
     669         * <!-- end-user-doc --> 
     670         * @generated 
     671         * @ordered 
     672         */ 
     673        int AX_ENTRY__REFERENCE = AX_INDEX_NODE_FEATURE_COUNT + 2; 
     674 
     675        /** 
    667676         * The number of structural features of the '<em>AX Entry</em>' class. 
    668677         * <!-- begin-user-doc --> 
     
    671680         * @ordered 
    672681         */ 
    673         int AX_ENTRY_FEATURE_COUNT = AX_INDEX_NODE_FEATURE_COUNT + 2; 
     682        int AX_ENTRY_FEATURE_COUNT = AX_INDEX_NODE_FEATURE_COUNT + 3; 
    674683 
    675684        /** 
     
    970979         */ 
    971980        EReference getAXEntry_Parent(); 
     981 
     982        /** 
     983         * Returns the meta object for the reference '{@link org.axdt.axdoc.model.AXEntry#getReference <em>Reference</em>}'. 
     984         * <!-- begin-user-doc --> 
     985         * <!-- end-user-doc --> 
     986         * @return the meta object for the reference '<em>Reference</em>'. 
     987         * @see org.axdt.axdoc.model.AXEntry#getReference() 
     988         * @see #getAXEntry() 
     989         * @generated 
     990         */ 
     991        EReference getAXEntry_Reference(); 
    972992 
    973993        /** 
     
    13131333 
    13141334                /** 
     1335                 * The meta object literal for the '<em><b>Reference</b></em>' reference feature. 
     1336                 * <!-- begin-user-doc --> 
     1337                 * <!-- end-user-doc --> 
     1338                 * @generated 
     1339                 */ 
     1340                EReference AX_ENTRY__REFERENCE = eINSTANCE.getAXEntry_Reference(); 
     1341 
     1342                /** 
    13151343                 * The meta object literal for the '{@link org.axdt.axdoc.model.impl.AXIndexNodeImpl <em>AX Index Node</em>}' class. 
    13161344                 * <!-- begin-user-doc --> 
  • org.axdt.axdoc.model/src/org/axdt/axdoc/model/AXEntry.java

    r79dd699 r85b4650  
    1717 *   <li>{@link org.axdt.axdoc.model.AXEntry#getType <em>Type</em>}</li> 
    1818 *   <li>{@link org.axdt.axdoc.model.AXEntry#getParent <em>Parent</em>}</li> 
     19 *   <li>{@link org.axdt.axdoc.model.AXEntry#getReference <em>Reference</em>}</li> 
    1920 * </ul> 
    2021 * </p> 
     
    8283        void setParent(AXIndexNode value); 
    8384 
     85        /** 
     86         * Returns the value of the '<em><b>Reference</b></em>' reference. 
     87         * <!-- begin-user-doc --> 
     88         * <p> 
     89         * If the meaning of the '<em>Reference</em>' reference isn't clear, 
     90         * there really should be more of a description here... 
     91         * </p> 
     92         * <!-- end-user-doc --> 
     93         * @return the value of the '<em>Reference</em>' reference. 
     94         * @see #setReference(AXNode) 
     95         * @see org.axdt.axdoc.model.AXDocPackage#getAXEntry_Reference() 
     96         * @model transient="true" 
     97         * @generated 
     98         */ 
     99        AXNode getReference(); 
     100 
     101        /** 
     102         * Sets the value of the '{@link org.axdt.axdoc.model.AXEntry#getReference <em>Reference</em>}' reference. 
     103         * <!-- begin-user-doc --> 
     104         * <!-- end-user-doc --> 
     105         * @param value the new value of the '<em>Reference</em>' reference. 
     106         * @see #getReference() 
     107         * @generated 
     108         */ 
     109        void setReference(AXNode value); 
     110 
    84111} // AXEntry 
  • org.axdt.axdoc.model/src/org/axdt/axdoc/model/AXIndex.java

    r87f02d1 r85b4650  
    153153         * @generated 
    154154         */ 
    155         AXPackage getOrCreatePackage(); 
     155        AXPackage getOrCreateReference(); 
    156156 
    157157} // AXIndex 
  • org.axdt.axdoc.model/src/org/axdt/axdoc/model/AXIndexNode.java

    r79dd699 r85b4650  
    144144        AXEntry createEntry(String part, AXEntryType type); 
    145145 
     146        /** 
     147         * <!-- begin-user-doc --> 
     148         * <!-- end-user-doc --> 
     149         * @model kind="operation" 
     150         * @generated 
     151         */ 
     152        AXNode getOrCreateReference(); 
     153 
    146154} // AXIndexNode 
  • org.axdt.axdoc.model/src/org/axdt/axdoc/model/impl/AXDocPackageImpl.java

    r87f02d1 r85b4650  
    423423         * @generated 
    424424         */ 
     425        public EReference getAXEntry_Reference() { 
     426                return (EReference) axEntryEClass.getEStructuralFeatures().get(2); 
     427        } 
     428 
     429        /** 
     430         * <!-- begin-user-doc --> 
     431         * <!-- end-user-doc --> 
     432         * @generated 
     433         */ 
    425434        public EClass getAXIndexNode() { 
    426435                return axIndexNodeEClass; 
     
    572581                createEAttribute(axEntryEClass, AX_ENTRY__TYPE); 
    573582                createEReference(axEntryEClass, AX_ENTRY__PARENT); 
     583                createEReference(axEntryEClass, AX_ENTRY__REFERENCE); 
    574584 
    575585                axIndexNodeEClass = createEClass(AX_INDEX_NODE); 
     
    713723                                IS_ORDERED); 
    714724 
    715                 addEOperation(axIndexEClass, this.getAXPackage(), "getOrCreatePackage", 
    716                                 0, 1, IS_UNIQUE, IS_ORDERED); 
     725                addEOperation(axIndexEClass, this.getAXPackage(), 
     726                                "getOrCreateReference", 0, 1, IS_UNIQUE, IS_ORDERED); 
    717727 
    718728                initEClass(axRootEClass, AXRoot.class, "AXRoot", !IS_ABSTRACT, 
     
    751761                                !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, 
    752762                                IS_ORDERED); 
     763                initEReference(getAXEntry_Reference(), this.getAXNode(), null, 
     764                                "reference", null, 0, 1, AXEntry.class, IS_TRANSIENT, 
     765                                !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, 
     766                                !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); 
    753767 
    754768                initEClass(axIndexNodeEClass, AXIndexNode.class, "AXIndexNode", 
     
    799813                                IS_ORDERED); 
    800814 
     815                addEOperation(axIndexNodeEClass, this.getAXNode(), 
     816                                "getOrCreateReference", 0, 1, IS_UNIQUE, IS_ORDERED); 
     817 
    801818                // Initialize enums and add enum literals 
    802819                initEEnum(axLevelEEnum, AXLevel.class, "AXLevel"); 
  • org.axdt.axdoc.model/src/org/axdt/axdoc/model/impl/AXEntryImpl.java

    r79dd699 r85b4650  
    99import java.util.Collection; 
    1010 
     11import org.axdt.axdoc.model.AXDocFactory; 
    1112import org.axdt.axdoc.model.AXDocPackage; 
    1213import org.axdt.axdoc.model.AXEntry; 
     
    1415import org.axdt.axdoc.model.AXIndex; 
    1516import org.axdt.axdoc.model.AXIndexNode; 
     17import org.axdt.axdoc.model.AXMember; 
     18import org.axdt.axdoc.model.AXMemberHolder; 
     19import org.axdt.axdoc.model.AXNode; 
     20import org.axdt.axdoc.model.AXPackage; 
    1621import org.axdt.axdoc.model.AXRoot; 
     22import org.axdt.axdoc.model.AXType; 
    1723import org.eclipse.emf.common.notify.Notification; 
    1824import org.eclipse.emf.common.notify.NotificationChain; 
     
    3238 *   <li>{@link org.axdt.axdoc.model.impl.AXEntryImpl#getType <em>Type</em>}</li> 
    3339 *   <li>{@link org.axdt.axdoc.model.impl.AXEntryImpl#getParent <em>Parent</em>}</li> 
     40 *   <li>{@link org.axdt.axdoc.model.impl.AXEntryImpl#getReference <em>Reference</em>}</li> 
    3441 * </ul> 
    3542 * </p> 
     
    5764         */ 
    5865        protected AXEntryType type = TYPE_EDEFAULT; 
     66 
     67        /** 
     68         * The cached value of the '{@link #getReference() <em>Reference</em>}' reference. 
     69         * <!-- begin-user-doc --> 
     70         * <!-- end-user-doc --> 
     71         * @see #getReference() 
     72         * @generated 
     73         * @ordered 
     74         */ 
     75        protected AXNode reference; 
    5976 
    6077        /** 
     
    153170         * @generated 
    154171         */ 
     172        public AXNode getReference() { 
     173                if (reference != null && reference.eIsProxy()) { 
     174                        InternalEObject oldReference = (InternalEObject) reference; 
     175                        reference = (AXNode) eResolveProxy(oldReference); 
     176                        if (reference != oldReference) { 
     177                                if (eNotificationRequired()) 
     178                                        eNotify(new ENotificationImpl(this, Notification.RESOLVE, 
     179                                                        AXDocPackage.AX_ENTRY__REFERENCE, oldReference, 
     180                                                        reference)); 
     181                        } 
     182                } 
     183                return reference; 
     184        } 
     185 
     186        /** 
     187         * <!-- begin-user-doc --> 
     188         * <!-- end-user-doc --> 
     189         * @generated 
     190         */ 
     191        public AXNode basicGetReference() { 
     192                return reference; 
     193        } 
     194 
     195        /** 
     196         * <!-- begin-user-doc --> 
     197         * <!-- end-user-doc --> 
     198         * @generated 
     199         */ 
     200        public void setReference(AXNode newReference) { 
     201                AXNode oldReference = reference; 
     202                reference = newReference; 
     203                if (eNotificationRequired()) 
     204                        eNotify(new ENotificationImpl(this, Notification.SET, 
     205                                        AXDocPackage.AX_ENTRY__REFERENCE, oldReference, reference)); 
     206        } 
     207 
     208        /** 
     209         * <!-- begin-user-doc --> 
     210         * <!-- end-user-doc --> 
     211         * @generated 
     212         */ 
    155213        @SuppressWarnings("unchecked") 
    156214        @Override 
     
    226284                case AXDocPackage.AX_ENTRY__PARENT: 
    227285                        return getParent(); 
     286                case AXDocPackage.AX_ENTRY__REFERENCE: 
     287                        if (resolve) 
     288                                return getReference(); 
     289                        return basicGetReference(); 
    228290                } 
    229291                return eDynamicGet(featureID, resolve, coreType); 
     
    252314                        setParent((AXIndexNode) newValue); 
    253315                        return; 
     316                case AXDocPackage.AX_ENTRY__REFERENCE: 
     317                        setReference((AXNode) newValue); 
     318                        return; 
    254319                } 
    255320                eDynamicSet(featureID, newValue); 
     
    275340                case AXDocPackage.AX_ENTRY__PARENT: 
    276341                        setParent((AXIndexNode) null); 
     342                        return; 
     343                case AXDocPackage.AX_ENTRY__REFERENCE: 
     344                        setReference((AXNode) null); 
    277345                        return; 
    278346                } 
     
    301369                case AXDocPackage.AX_ENTRY__PARENT: 
    302370                        return getParent() != null; 
     371                case AXDocPackage.AX_ENTRY__REFERENCE: 
     372                        return reference != null; 
    303373                } 
    304374                return eDynamicIsSet(featureID); 
     
    366436                return id; 
    367437        } 
     438 
     439        /** 
     440         * <!-- begin-user-doc --> 
     441         * <!-- end-user-doc --> 
     442         */ 
     443        public AXNode getOrCreateReference() { 
     444                AXNode node = getReference(); 
     445                // if transient reference is not yet set .. 
     446                if (node == null && getName() != null && getType() != null) { 
     447                        // lets try to find it first 
     448                        AXIndexNode parent = getParent(); 
     449                        // we need a parent ! 
     450                        if (parent == null) return null; 
     451                        // lets work down the index tree and create all needed references 
     452                        AXNode parentRef = parent.getOrCreateReference(); 
     453                        // parent ref does not exist and cannot be created 
     454                        if (parentRef == null) return null; 
     455                        if (getType().isMember()) { 
     456                                // should never happen 
     457                                if (!(parentRef instanceof AXMemberHolder)) return null; 
     458                                AXMemberHolder holder = (AXMemberHolder) parentRef; 
     459                                AXMember result = null; 
     460                                for (AXMember member:holder.getMembers()) { 
     461                                        if (getName().equals(member.getName())) { 
     462                                                result = member; 
     463                                                break; 
     464                                        } 
     465                                } 
     466                                // none found type. lets create one 
     467                                if (result == null) { 
     468                                        // none found type. lets create one 
     469                                        result = AXDocFactory.eINSTANCE.createAXMember(); 
     470                                        result.setName(getName()); 
     471                                        if (getType().equals(AXEntryType.METHOD)) 
     472                                                result.setFunction(true); 
     473                                        else if (getType().equals(AXEntryType.CONSTRUCTOR)) 
     474                                                result.setConst(true); 
     475                                        else if (getType().equals(AXEntryType.PROPERTY)) 
     476                                                result.setVar(true); 
     477                                        holder.getMembers().add(result); 
     478                                } 
     479                                node = result; 
     480                        } else if (getType().isType()) { 
     481                                // we need a package to add types 
     482                                // XXX: think about private classes in source indexes 
     483                                if (!(parentRef instanceof AXPackage)) return null; 
     484                                AXPackage pack = (AXPackage) parentRef; 
     485                                AXType result = null; 
     486                                for (AXType type:pack.getTypes()) { 
     487                                        if (getName().equals(type.getName())) { 
     488                                                result = type; 
     489                                                break; 
     490                                        } 
     491                                } 
     492                                if (result == null) { 
     493                                        // none found type. lets create one 
     494                                        result = AXDocFactory.eINSTANCE.createAXType(); 
     495                                        result.setName(getName()); 
     496                                        if (getType().equals(AXEntryType.INTERFACE)) { 
     497                                                result.setInterface(true); 
     498                                        } 
     499                                        pack.getTypes().add(result); 
     500                                } 
     501                                node = result; 
     502                        } 
     503                        setReference(node); 
     504                } 
     505                return node; 
     506        } 
    368507} //AXEntryImpl 
  • org.axdt.axdoc.model/src/org/axdt/axdoc/model/impl/AXIndexImpl.java

    r87f02d1 r85b4650  
    513513         * <!-- end-user-doc --> 
    514514         */ 
    515         public AXPackage getOrCreatePackage() { 
     515        public AXPackage getOrCreateReference() { 
    516516                AXPackage pack = getReference(); 
    517                 if (pack == null) { 
     517                if (pack == null && eResource() != null) { 
    518518                        pack = AXDocFactory.eINSTANCE.createAXPackage(); 
    519519                        pack.setName(getName()); 
  • org.axdt.axdoc.model/src/org/axdt/axdoc/model/impl/AXIndexNodeImpl.java

    r79dd699 r85b4650  
    1414import org.axdt.axdoc.model.AXEntryType; 
    1515import org.axdt.axdoc.model.AXIndexNode; 
     16import org.axdt.axdoc.model.AXNode; 
    1617import org.axdt.axdoc.model.AXRoot; 
    1718import org.eclipse.emf.common.notify.Notification; 
     
    251252         * <!-- begin-user-doc --> 
    252253         * <!-- end-user-doc --> 
     254         */ 
     255        public abstract AXNode getOrCreateReference(); 
     256 
     257        /** 
     258         * <!-- begin-user-doc --> 
     259         * <!-- end-user-doc --> 
    253260         * @generated 
    254261         */ 
  • org.axdt.axdoc.test/src/org/axdt/axdoc/model/AXEntryTest.java

    r79dd699 r85b4650  
    88 
    99import junit.textui.TestRunner; 
     10 
     11import org.axdt.axdoc.model.util.AXUtil; 
    1012 
    1113/** 
     
    8890                assertSame(root, getFixture().getRoot()); 
    8991        } 
     92 
     93        @Override 
     94        public void testGetOrCreateReference() { 
     95                // if null not enough info provided 
     96                assertNull(getFixture().getOrCreateReference()); 
     97                getFixture().setName("Array"); 
     98                // still needs entry type 
     99                assertNull(getFixture().getOrCreateReference()); 
     100                getFixture().setType(AXEntryType.CLASS); 
     101                // still need package 
     102                assertNull(getFixture().getOrCreateReference()); 
     103                AXRoot root = AXUtil.createRoot("test", "file:/tmp/axdoc.entryTest/asdoc", "file:/tmp/axdoc.entryTest/resources"); 
     104                root.getEntries().add(getFixture()); 
     105                AXNode ref = getFixture().getOrCreateReference(); 
     106                assertNotNull(ref); 
     107                assertTrue(ref instanceof AXType); 
     108                AXType type = (AXType) ref; 
     109                assertFalse(type.isInterface()); 
     110                assertEquals("Array", type.getName()); 
     111                assertSame(type, getFixture().getOrCreateReference()); 
     112                 
     113                AXEntry entry = getFixture().createEntry("toString", AXEntryType.METHOD); 
     114                ref = entry.getOrCreateReference(); 
     115                assertNotNull(ref); 
     116                assertTrue(ref instanceof AXMember); 
     117                AXMember member = (AXMember) ref; 
     118                assertTrue(member.isFunction()); 
     119                assertEquals("toString", member.getName()); 
     120                assertSame(member, entry.getOrCreateReference()); 
     121        } 
    90122} //AXEntryTest 
  • org.axdt.axdoc.test/src/org/axdt/axdoc/model/AXIndexNodeTest.java

    r79dd699 r85b4650  
    3030 *   <li>{@link org.axdt.axdoc.model.AXIndexNode#localEntry(java.lang.String, boolean) <em>Local Entry</em>}</li> 
    3131 *   <li>{@link org.axdt.axdoc.model.AXIndexNode#createEntry(java.lang.String, org.axdt.axdoc.model.AXEntryType) <em>Create Entry</em>}</li> 
     32 *   <li>{@link org.axdt.axdoc.model.AXIndexNode#getOrCreateReference() <em>Get Or Create Reference</em>}</li> 
    3233 * </ul> 
    3334 * </p> 
     
    185186        } 
    186187 
     188        /** 
     189         * Tests the '{@link org.axdt.axdoc.model.AXIndexNode#getOrCreateReference() <em>Get Or Create Reference</em>}' operation. 
     190         * <!-- begin-user-doc --> 
     191         * <!-- end-user-doc --> 
     192         * @see org.axdt.axdoc.model.AXIndexNode#getOrCreateReference() 
     193         */ 
     194        public void testGetOrCreateReference() { 
     195                // should be tested in  concrete implementations 
     196        } 
     197 
    187198} //AXIndexNodeTest 
  • org.axdt.axdoc.test/src/org/axdt/axdoc/model/AXIndexTest.java

    r87f02d1 r85b4650  
    88 
    99import junit.textui.TestRunner; 
     10 
     11import org.axdt.axdoc.model.util.AXUtil; 
     12import org.eclipse.emf.ecore.resource.Resource; 
    1013 
    1114/** 
     
    1821 *   <li>{@link org.axdt.axdoc.model.AXIndex#localIndex(java.lang.String) <em>Local Index</em>}</li> 
    1922 *   <li>{@link org.axdt.axdoc.model.AXIndex#createIndex(java.lang.String) <em>Create Index</em>}</li> 
    20  *   <li>{@link org.axdt.axdoc.model.AXIndex#getOrCreatePackage() <em>Get Or Create Package</em>}</li> 
     23 *   <li>{@link org.axdt.axdoc.model.AXIndex#getOrCreateReference() <em>Get Or Create Reference</em>}</li> 
    2124 * </ul> 
    2225 * </p> 
     
    184187 
    185188        /** 
    186          * Tests the '{@link org.axdt.axdoc.model.AXIndex#getOrCreatePackage() <em>Get Or Create Package</em>}' operation. 
    187          * <!-- begin-user-doc --> 
    188          * <!-- end-user-doc --> 
    189          * @see org.axdt.axdoc.model.AXIndex#getOrCreatePackage() 
    190          */ 
    191         public void testGetOrCreatePackage() { 
    192         } 
     189         * Tests the '{@link org.axdt.axdoc.model.AXIndex#getOrCreateReference() <em>Get Or Create Reference</em>}' operation. 
     190         * <!-- begin-user-doc --> 
     191         * <!-- end-user-doc --> 
     192         * @see org.axdt.axdoc.model.AXIndex#getOrCreateReference() 
     193         */ 
     194        public void testGetOrCreateReference() { 
     195                getFixture().setName("org"); 
     196                AXPackage reference = getFixture().getOrCreateReference(); 
     197                // needs resource set 
     198                assertNull(reference); 
     199                Resource resource = AXUtil.getResource("test"); 
     200                resource.getContents().add(getFixture()); 
     201                reference = getFixture().getOrCreateReference(); 
     202                assertNotNull(reference); 
     203                assertEquals("org", reference.getName()); 
     204                assertEquals(0, reference.getTypes().size()); 
     205                assertEquals(0, reference.getMembers().size()); 
     206                // watch out asdoc is a list ! 
     207                assertEquals(0, reference.getAsdoc().size()); 
     208        } 
     209 
    193210} //AXIndexTest 
  • org.axdt.axdoc.test/src/org/axdt/axdoc/model/util/AXDocUtilTest.java

    r79dd699 r85b4650  
    99import org.axdt.axdoc.model.AXPackage; 
    1010import org.axdt.axdoc.model.AXRoot; 
    11 import org.axdt.axdoc.model.util.AXUtil; 
    1211import org.eclipse.emf.ecore.resource.Resource; 
    1312 
  • org.axdt.axdoc.test/src/org/axdt/axdoc/util/Index0rTest.java

    r87f02d1 r85b4650  
    11package org.axdt.axdoc.util; 
     2 
     3import junit.framework.TestCase; 
    24 
    35import org.axdt.axdoc.TestConstants; 
     
    79import org.axdt.axdoc.model.AXRoot; 
    810import org.axdt.axdoc.model.AXRootType; 
    9 import org.axdt.axdoc.util.Index0r; 
    10  
    11 import junit.framework.TestCase; 
     11import org.eclipse.emf.common.util.URI; 
    1212 
    1313public class Index0rTest extends TestCase implements TestConstants { 
     
    2222                assertEquals(2,"::test".split("::").length); 
    2323                assertEquals("test::".length()-2,"test::".indexOf("::")); 
    24                 Index0r index = new Index0r(){}; 
     24 
     25                // platform urls are only supported with active workspace 
     26                final URI customBaseUrl = URI.createURI("file:/tmp/axdttest/"+Long.toHexString(System.currentTimeMillis())); 
     27                Index0r index = new Index0r(){ 
     28                        @Override 
     29                        protected URI createBaseUri() { 
     30                                return customBaseUrl; 
     31                        } 
     32                }; 
    2533                String pathUrl = dataFolder.concat("/asdoc/"); 
    2634                AXRoot root = index.addRoot("langref", pathUrl, AXRootType.ASDOC); 
    27                 assertEquals("platform:/meta/org.axdt.axdoc/"+Integer.toHexString(pathUrl.hashCode())+"/root-index.axdoc", root.eResource().getURI().toString()); 
     35                assertEquals(customBaseUrl+"/"+Integer.toHexString(pathUrl.hashCode())+"/root-index.axdoc", root.eResource().getURI().toString()); 
    2836                index.initialize(root, AXLevel.PACKAGE); 
    2937                assertNotNull(root); 
  • org.axdt.axdoc/META-INF/MANIFEST.MF

    r87f02d1 r85b4650  
    1010 org.axdt.common, 
    1111 org.eclipse.core.resources, 
    12  org.axdt.axdoc.model 
     12 org.axdt.axdoc.model, 
     13 org.eclipse.debug.core 
    1314Eclipse-LazyStart: true 
    1415Bundle-Activator: org.axdt.axdoc.AXDocPlugin 
  • org.axdt.axdoc/plugin.xml

    r87f02d1 r85b4650  
    77            class="org.axdt.axdoc.preferences.AXDocPreferencePage" 
    88            category="org.axdt.as3.preferences" 
    9             id="org.axdt.axdoc.prefernces" 
     9            id="org.axdt.axdoc.preferences" 
    1010            name="AXDoc"> 
    1111      </page> 
    1212   </extension> 
     13  <extension 
     14         point="org.eclipse.core.runtime.preferences"> 
     15      <initializer 
     16            class="org.axdt.axdoc.preferences.AXDocPreferences"> 
     17      </initializer> 
     18  </extension> 
    1319</plugin> 
  • org.axdt.axdoc/src/org/axdt/axdoc/AXDocPlugin.java

    r87f02d1 r85b4650  
    44import java.net.URL; 
    55 
    6 import org.axdt.axdoc.model.AXLevel; 
    7 import org.axdt.axdoc.model.AXRoot; 
    8 import org.axdt.axdoc.model.AXRootType; 
    9 import org.axdt.axdoc.preferences.AXDocPreferences; 
    10 import org.axdt.axdoc.util.Index0r; 
    116import org.eclipse.core.runtime.FileLocator; 
    127import org.eclipse.core.runtime.Path; 
     
    5449                super.start(context); 
    5550                plugin = this; 
    56                 try { 
    57                         initializeIndex0r(); 
    58                 } catch (Exception e) { 
    59                         log("could not initialize indexer", e); 
    60                 } 
    61         } 
    62  
    63         protected void initializeIndex0r() { 
    64                 Index0r result = Index0r.getInstance(); 
    65                 // load configured indexes 
    66                 String pathString = AXDocPreferences.getLangRefPathString(); 
    67                 AXRoot root = result.addRoot("langref", pathString, AXRootType.ASDOC); 
    68                 result.initialize(root, AXLevel.PACKAGE); 
    6951        } 
    7052 
  • org.axdt.axdoc/src/org/axdt/axdoc/preferences/AXDocPreferencePage.java

    r87f02d1 r85b4650  
    11package org.axdt.axdoc.preferences; 
    22 
     3import org.axdt.axdoc.util.Index0r; 
    34import org.axdt.preferences.AbstractPreferencePage; 
    45 
     
    78                super(AXDocPreferences.getInstance()); 
    89        } 
     10         
     11        @Override 
     12        protected void performApply() { 
     13                super.performApply(); 
     14                // if changed reparse 
     15                AXDocPreferences.checkAXDocPaths(Index0r.getInstance()); 
     16        } 
    917} 
  • org.axdt.axdoc/src/org/axdt/axdoc/preferences/AXDocPreferences.java

    r87f02d1 r85b4650  
    22 
    33import org.axdt.axdoc.AXDocPlugin; 
     4import org.axdt.axdoc.model.AXLevel; 
     5import org.axdt.axdoc.model.AXRoot; 
     6import org.axdt.axdoc.model.AXRootType; 
     7import org.axdt.axdoc.preferences.DocTableFieldEditor.DocItem; 
     8import org.axdt.axdoc.util.Index0r; 
    49import org.axdt.preferences.AbstractPreferences; 
    510import org.eclipse.jface.preference.IPreferenceStore; 
     
    1621 
    1722        public AXDocPreferences() { 
    18                 super("Preferences for ActionScript 3 language support"); 
     23                super("Preferences for asdoc support"); 
    1924                instance = this; 
    2025        } 
     
    2732        @Override 
    2833        public void initializeFieldSpecs() { 
    29                 add(LANGREF_PATH, "&Langref path", "file:/home/mb0/workspace/axdt/org.axdt.axdoc.test/data/asdoc"); 
     34                add(new DocTableField(LANGREF_PATH, "Asdoc uris", "file:/home/mb0/workspace/axdt/org.axdt.axdoc.test/data/asdoc")); 
    3035        } 
    3136 
     
    3439                return store.getString(LANGREF_PATH); 
    3540        } 
     41        public static void checkAXDocPaths(Index0r index0r) { 
     42                String string = getLangRefPathString(); 
     43                Object[] values = DocTableFieldEditor.deserializeValue(string); 
     44                for (Object value:values) { 
     45                        if (value instanceof DocItem) { 
     46                                DocItem item = (DocItem) value; 
     47                                AXRoot root = index0r.addRoot(item.name, item.url, AXRootType.ASDOC); 
     48                                index0r.initialize(root, AXLevel.TYPE); 
     49                        } 
     50                } 
     51        } 
     52        @Override 
     53        public void initializeDefaultPreferences() { 
     54                super.initializeDefaultPreferences(); 
     55        } 
    3656} 
  • org.axdt.axdoc/src/org/axdt/axdoc/util/AXDocParser.java

    r87f02d1 r85b4650  
    1212import org.axdt.axdoc.model.AXEntryType; 
    1313import org.axdt.axdoc.model.AXIndex; 
     14import org.axdt.axdoc.model.AXIndexNode; 
    1415import org.axdt.axdoc.model.AXLevel; 
    15 import org.axdt.axdoc.model.AXPackage; 
    1616import org.axdt.axdoc.model.AXRoot; 
    17 import org.axdt.axdoc.model.AXType; 
    1817import org.axdt.axdoc.model.util.AXUtil; 
    1918import org.w3c.dom.DOMException; 
     
    118117                root.setLevel(AXLevel.PACKAGE); 
    119118        } 
    120         public void setDoc(AXIndex packageIndex, Node docNode) { 
     119        public void setDoc(AXIndexNode node, Node docNode) { 
    121120                if (docNode == null || docNode.getTextContent() == null) return; 
    122121                String docContent = docNode.getTextContent().replaceAll("\\W+"," ").trim(); 
    123122                if (docContent.trim().equals("")) return; 
    124                 packageIndex.getOrCreatePackage().getAsdoc().add(docContent);  
     123                node.getOrCreateReference().getAsdoc().add(docContent);  
    125124        } 
    126125        public void parseTypeLevel(AXIndex index) { 
     
    205204                                        } 
    206205                                        AXEntry typeIndex = index.createEntry(typeName, entryType); 
    207                                         AXType typeNode = AXUtil.createType(typeName); 
    208                                         // we need to access the package reference and add it there 
    209                                         // TODO a shortcut to create axnodes from existing indexnode info would be appropriate  
    210206                                        // load type doc summary 
    211207                                        if (loadSummary) { 
    212208                                                // remember package detail is ia/a/i 
    213                                                 Node parent = typeNode.isInterface() ? item.getParentNode() : item; 
    214                                                 //setDoc(typeNode, parent.getParentNode().getNextSibling()); 
     209                                                Node parent = AXEntryType.INTERFACE.equals(typeIndex.getType()) ? item.getParentNode() : item; 
     210                                                setDoc(typeIndex, parent.getParentNode().getNextSibling()); 
    215211                                        } 
    216                                         ((AXPackage)index.getReference()).getTypes().add(typeNode); 
    217212                                        index.getEntries().add(typeIndex); 
    218                                         log(3,"[DDD] found type ", typeNode); 
     213                                        log(3,"[DDD] found type ", typeIndex); 
    219214                                } 
    220215                        } 
     
    265260                } 
    266261        } 
    267         private void parseTypeMemberInfo(AXEntry result, Node detail) throws DOMException, XPathExpressionException { 
     262        private void parseTypeMemberInfo(AXEntry typeIndex, Node detail) throws DOMException, XPathExpressionException { 
    268263                String headerType = parseTypeMemberHeader(detail); 
    269264                if ("Example".equals(headerType)) return; 
     265                // TODO handle events 
    270266                if ("Event".equals(headerType)) return; 
    271267                Node child = detail.getFirstChild(); 
     
    273269                String childCode = child.getTextContent().trim(); 
    274270                log(3,"[DDD] found detail: "+ childCode); 
    275                 AXEntry memberIndex = result.createEntry(childCode, AXEntryType.METHOD); 
    276                 //AXUtil.createMember(childCode); 
    277                 //((AXType)result.getReference()).getMembers().add(memberNode); 
    278                 result.getEntries().add(memberIndex); 
     271                AXEntry memberIndex = typeIndex.createEntry(childCode, AXEntryType.METHOD); 
     272                typeIndex.getEntries().add(memberIndex); 
    279273                child = child.getNextSibling(); 
    280274                boolean isGetterSetter = child.getNodeType() == Node.TEXT_NODE; 
  • org.axdt.axdoc/src/org/axdt/axdoc/util/Index0r.java

    r87f02d1 r85b4650  
    1414import org.axdt.axdoc.model.AXRootType; 
    1515import org.axdt.axdoc.model.util.AXUtil; 
     16import org.axdt.axdoc.preferences.AXDocPreferences; 
    1617import org.eclipse.core.runtime.Path; 
    1718import org.eclipse.emf.common.CommonPlugin; 
     
    2728         
    2829        public static Index0r getInstance() { 
    29                 if (instance == null) 
     30                if (instance == null) { 
    3031                        instance = new Index0r(); 
     32                        AXDocPreferences.checkAXDocPaths(instance); 
     33                } 
    3134                return instance; 
    3235        } 
     
    3942                roots = new HashMap<String, AXRoot>(); 
    4043                docParser = new AXDocParser(); 
    41                 baseURI = CommonPlugin.resolve(URI.createURI("platform:/meta/"+AXDocPlugin.PLUGIN_ID)); 
     44                baseURI = createBaseUri(); 
     45        } 
     46        protected URI createBaseUri() { 
     47                return CommonPlugin.resolve(URI.createURI("platform:/meta/"+AXDocPlugin.PLUGIN_ID)); 
    4248        } 
    4349        public AXIndexNode[] find(String qname) { 
     
    112118                return root; 
    113119        } 
     120        public AXRoot[] getRoots() { 
     121                return roots.values().toArray(new AXRoot[roots.size()]); 
     122        } 
    114123        public void initialize(AXRoot root, AXLevel level) { 
    115124                if (root.getRootType() == AXRootType.ASDOC) { 
  • org.axdt.common/src/org/axdt/common/AxdtPlugin.java

    r87f02d1 r85b4650  
    33import java.net.URL; 
    44 
    5 import org.axdt.common.preferences.AxdtPreferences; 
    65import org.eclipse.core.runtime.FileLocator; 
    76import org.eclipse.core.runtime.Path;