Changeset 2d81bf0e2ed8217c6cb2a26fcb22d09b8441f7a3

Show
Ignore:
Timestamp:
06/28/09 23:36:50 (9 months ago)
Author:
mb0 <mb0@…>
git-author:
mb0 <mb0@mb0.org> / 2009-06-09T21:53:24Z+0200
Parents:
82cecb85d4b9fff471d3eadd986735ad736c6c3f
Children:
69d1ca8cf4ab8b63f93d4467f3d504c0ffdfabb7
git-committer:
mb0 <mb0@mb0.org> / 2009-06-28T23:36:50Z+0200
Message:

renamed axdoc preference option, root package serialization file name and axutil functions
rootLevel is not transient. a dirty flag was added to axroot.
pulled getReference up to axindexnode.
index0r got a package cache and some simple lookup methods.

Files:
19 modified

Legend:

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

    r85b4650 r2d81bf0  
    6262    <eStructuralFeatures xsi:type="ecore:EAttribute" name="url" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/> 
    6363    <eStructuralFeatures xsi:type="ecore:EAttribute" name="rootType" eType="#//AXRootType"/> 
    64     <eStructuralFeatures xsi:type="ecore:EAttribute" name="rootLevel" eType="#//AXLevel" 
    65         transient="true"/> 
     64    <eStructuralFeatures xsi:type="ecore:EAttribute" name="rootLevel" eType="#//AXLevel"/> 
     65    <eStructuralFeatures xsi:type="ecore:EAttribute" name="dirty" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBoolean" 
     66        transient="true" defaultValueLiteral="false"/> 
    6667  </eClassifiers> 
    6768  <eClassifiers xsi:type="ecore:EEnum" name="AXRootType"> 
     
    9293    </eOperations> 
    9394    <eOperations name="getOrCreateReference" eType="#//AXNode"/> 
     95    <eOperations name="getReference" eType="#//AXNode"/> 
    9496    <eStructuralFeatures xsi:type="ecore:EAttribute" name="name" lowerBound="1" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/> 
    9597    <eStructuralFeatures xsi:type="ecore:EReference" name="entries" upperBound="-1" 
  • org.axdt.axdoc.model/model/AXDocXML.xsd

    r87f02d1 r2d81bf0  
    8888        <xsd:attribute name="url" type="xsd:string"/> 
    8989        <xsd:attribute name="rootType" type="axdoc:AXRootType"/> 
     90        <xsd:attribute name="rootLevel" type="axdoc:AXLevel"/> 
    9091      </xsd:extension> 
    9192    </xsd:complexContent> 
  • org.axdt.axdoc.model/src/org/axdt/axdoc/model/AXDocPackage.java

    r85b4650 r2d81bf0  
    592592 
    593593        /** 
     594         * The feature id for the '<em><b>Dirty</b></em>' attribute. 
     595         * <!-- begin-user-doc --> 
     596         * <!-- end-user-doc --> 
     597         * @generated 
     598         * @ordered 
     599         */ 
     600        int AX_ROOT__DIRTY = AX_INDEX_FEATURE_COUNT + 3; 
     601 
     602        /** 
    594603         * The number of structural features of the '<em>AX Root</em>' class. 
    595604         * <!-- begin-user-doc --> 
     
    598607         * @ordered 
    599608         */ 
    600         int AX_ROOT_FEATURE_COUNT = AX_INDEX_FEATURE_COUNT + 3; 
     609        int AX_ROOT_FEATURE_COUNT = AX_INDEX_FEATURE_COUNT + 4; 
    601610 
    602611        /** 
     
    947956         */ 
    948957        EAttribute getAXRoot_RootLevel(); 
     958 
     959        /** 
     960         * Returns the meta object for the attribute '{@link org.axdt.axdoc.model.AXRoot#isDirty <em>Dirty</em>}'. 
     961         * <!-- begin-user-doc --> 
     962         * <!-- end-user-doc --> 
     963         * @return the meta object for the attribute '<em>Dirty</em>'. 
     964         * @see org.axdt.axdoc.model.AXRoot#isDirty() 
     965         * @see #getAXRoot() 
     966         * @generated 
     967         */ 
     968        EAttribute getAXRoot_Dirty(); 
    949969 
    950970        /** 
     
    13071327 
    13081328                /** 
     1329                 * The meta object literal for the '<em><b>Dirty</b></em>' attribute feature. 
     1330                 * <!-- begin-user-doc --> 
     1331                 * <!-- end-user-doc --> 
     1332                 * @generated 
     1333                 */ 
     1334                EAttribute AX_ROOT__DIRTY = eINSTANCE.getAXRoot_Dirty(); 
     1335 
     1336                /** 
    13091337                 * The meta object literal for the '{@link org.axdt.axdoc.model.impl.AXEntryImpl <em>AX Entry</em>}' class. 
    13101338                 * <!-- begin-user-doc --> 
  • org.axdt.axdoc.model/src/org/axdt/axdoc/model/AXIndexNode.java

    r85b4650 r2d81bf0  
    152152        AXNode getOrCreateReference(); 
    153153 
     154        /** 
     155         * <!-- begin-user-doc --> 
     156         * <!-- end-user-doc --> 
     157         * @model kind="operation" 
     158         * @generated 
     159         */ 
     160        AXNode getReference(); 
     161 
    154162} // AXIndexNode 
  • org.axdt.axdoc.model/src/org/axdt/axdoc/model/AXRoot.java

    r79dd699 r2d81bf0  
    1818 *   <li>{@link org.axdt.axdoc.model.AXRoot#getRootType <em>Root Type</em>}</li> 
    1919 *   <li>{@link org.axdt.axdoc.model.AXRoot#getRootLevel <em>Root Level</em>}</li> 
     20 *   <li>{@link org.axdt.axdoc.model.AXRoot#isDirty <em>Dirty</em>}</li> 
    2021 * </ul> 
    2122 * </p> 
     
    9495         * @see #setRootLevel(AXLevel) 
    9596         * @see org.axdt.axdoc.model.AXDocPackage#getAXRoot_RootLevel() 
    96          * @model transient="true" 
     97         * @model 
    9798         * @generated 
    9899         */ 
     
    109110         */ 
    110111        void setRootLevel(AXLevel value); 
     112 
     113        /** 
     114         * Returns the value of the '<em><b>Dirty</b></em>' attribute. 
     115         * The default value is <code>"false"</code>. 
     116         * <!-- begin-user-doc --> 
     117         * <p> 
     118         * If the meaning of the '<em>Dirty</em>' attribute isn't clear, 
     119         * there really should be more of a description here... 
     120         * </p> 
     121         * <!-- end-user-doc --> 
     122         * @return the value of the '<em>Dirty</em>' attribute. 
     123         * @see #setDirty(boolean) 
     124         * @see org.axdt.axdoc.model.AXDocPackage#getAXRoot_Dirty() 
     125         * @model default="false" transient="true" 
     126         * @generated 
     127         */ 
     128        boolean isDirty(); 
     129 
     130        /** 
     131         * Sets the value of the '{@link org.axdt.axdoc.model.AXRoot#isDirty <em>Dirty</em>}' attribute. 
     132         * <!-- begin-user-doc --> 
     133         * <!-- end-user-doc --> 
     134         * @param value the new value of the '<em>Dirty</em>' attribute. 
     135         * @see #isDirty() 
     136         * @generated 
     137         */ 
     138        void setDirty(boolean value); 
    111139 
    112140        /** 
  • org.axdt.axdoc.model/src/org/axdt/axdoc/model/impl/AXDocPackageImpl.java

    r85b4650 r2d81bf0  
    396396         * @generated 
    397397         */ 
     398        public EAttribute getAXRoot_Dirty() { 
     399                return (EAttribute) axRootEClass.getEStructuralFeatures().get(3); 
     400        } 
     401 
     402        /** 
     403         * <!-- begin-user-doc --> 
     404         * <!-- end-user-doc --> 
     405         * @generated 
     406         */ 
    398407        public EClass getAXEntry() { 
    399408                return axEntryEClass; 
     
    577586                createEAttribute(axRootEClass, AX_ROOT__ROOT_TYPE); 
    578587                createEAttribute(axRootEClass, AX_ROOT__ROOT_LEVEL); 
     588                createEAttribute(axRootEClass, AX_ROOT__DIRTY); 
    579589 
    580590                axEntryEClass = createEClass(AX_ENTRY); 
     
    736746                                IS_ORDERED); 
    737747                initEAttribute(getAXRoot_RootLevel(), this.getAXLevel(), "rootLevel", 
    738                                 null, 0, 1, AXRoot.class, IS_TRANSIENT, !IS_VOLATILE, 
     748                                null, 0, 1, AXRoot.class, !IS_TRANSIENT, !IS_VOLATILE, 
     749                                IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, 
     750                                IS_ORDERED); 
     751                initEAttribute(getAXRoot_Dirty(), ecorePackage.getEBoolean(), "dirty", 
     752                                "false", 0, 1, AXRoot.class, IS_TRANSIENT, !IS_VOLATILE, 
    739753                                IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, 
    740754                                IS_ORDERED); 
     
    816830                                "getOrCreateReference", 0, 1, IS_UNIQUE, IS_ORDERED); 
    817831 
     832                addEOperation(axIndexNodeEClass, this.getAXNode(), "getReference", 0, 
     833                                1, IS_UNIQUE, IS_ORDERED); 
     834 
    818835                // Initialize enums and add enum literals 
    819836                initEEnum(axLevelEEnum, AXLevel.class, "AXLevel"); 
  • org.axdt.axdoc.model/src/org/axdt/axdoc/model/impl/AXEntryImpl.java

    r85b4650 r2d81bf0  
    448448                        AXIndexNode parent = getParent(); 
    449449                        // we need a parent ! 
    450                         if (parent == null) return null; 
     450                        if (parent == null) 
     451                                return null; 
    451452                        // lets work down the index tree and create all needed references 
    452453                        AXNode parentRef = parent.getOrCreateReference(); 
    453454                        // parent ref does not exist and cannot be created 
    454                         if (parentRef == null) return null; 
     455                        if (parentRef == null) 
     456                                return null; 
    455457                        if (getType().isMember()) { 
    456458                                // should never happen 
    457                                 if (!(parentRef instanceof AXMemberHolder)) return null; 
     459                                if (!(parentRef instanceof AXMemberHolder)) 
     460                                        return null; 
    458461                                AXMemberHolder holder = (AXMemberHolder) parentRef; 
    459462                                AXMember result = null; 
    460                                 for (AXMember member:holder.getMembers()) { 
     463                                for (AXMember member : holder.getMembers()) { 
    461464                                        if (getName().equals(member.getName())) { 
    462465                                                result = member; 
     
    481484                                // we need a package to add types 
    482485                                // XXX: think about private classes in source indexes 
    483                                 if (!(parentRef instanceof AXPackage)) return null; 
     486                                if (!(parentRef instanceof AXPackage)) 
     487                                        return null; 
    484488                                AXPackage pack = (AXPackage) parentRef; 
    485489                                AXType result = null; 
    486                                 for (AXType type:pack.getTypes()) { 
     490                                for (AXType type : pack.getTypes()) { 
    487491                                        if (getName().equals(type.getName())) { 
    488492                                                result = type; 
  • org.axdt.axdoc.model/src/org/axdt/axdoc/model/impl/AXIndexImpl.java

    r85b4650 r2d81bf0  
    518518                        pack = AXDocFactory.eINSTANCE.createAXPackage(); 
    519519                        pack.setName(getName()); 
     520                        String fileName = this instanceof AXRoot ? "root-package.axdoc" 
     521                                        : getId() + ".axdoc"; 
    520522                        URI uri = eResource().getURI().trimSegments(1).appendSegment( 
    521                                         getId() + ".axdoc"); 
    522                         AXUtil.getResource(eResource().getResourceSet(), pack, uri 
     523                                        fileName); 
     524                        AXUtil.getOrCreateResource(eResource().getResourceSet(), pack, uri 
    523525                                        .toString()); 
    524526                        setReference(pack); 
  • org.axdt.axdoc.model/src/org/axdt/axdoc/model/impl/AXIndexNodeImpl.java

    r85b4650 r2d81bf0  
    258258         * <!-- begin-user-doc --> 
    259259         * <!-- end-user-doc --> 
     260         */ 
     261        public abstract AXNode getReference(); 
     262 
     263        /** 
     264         * <!-- begin-user-doc --> 
     265         * <!-- end-user-doc --> 
    260266         * @generated 
    261267         */ 
  • org.axdt.axdoc.model/src/org/axdt/axdoc/model/impl/AXRootImpl.java

    r79dd699 r2d81bf0  
    3030 *   <li>{@link org.axdt.axdoc.model.impl.AXRootImpl#getRootType <em>Root Type</em>}</li> 
    3131 *   <li>{@link org.axdt.axdoc.model.impl.AXRootImpl#getRootLevel <em>Root Level</em>}</li> 
     32 *   <li>{@link org.axdt.axdoc.model.impl.AXRootImpl#isDirty <em>Dirty</em>}</li> 
    3233 * </ul> 
    3334 * </p> 
     
    9798 
    9899        /** 
     100         * The default value of the '{@link #isDirty() <em>Dirty</em>}' attribute. 
     101         * <!-- begin-user-doc --> 
     102         * <!-- end-user-doc --> 
     103         * @see #isDirty() 
     104         * @generated 
     105         * @ordered 
     106         */ 
     107        protected static final boolean DIRTY_EDEFAULT = false; 
     108 
     109        /** 
     110         * The flag representing the value of the '{@link #isDirty() <em>Dirty</em>}' attribute. 
     111         * <!-- begin-user-doc --> 
     112         * <!-- end-user-doc --> 
     113         * @see #isDirty() 
     114         * @generated 
     115         * @ordered 
     116         */ 
     117        protected static final int DIRTY_EFLAG = 1 << 0; 
     118 
     119        /** 
    99120         * <!-- begin-user-doc --> 
    100121         * <!-- end-user-doc --> 
     
    179200                        eNotify(new ENotificationImpl(this, Notification.SET, 
    180201                                        AXDocPackage.AX_ROOT__ROOT_LEVEL, oldRootLevel, rootLevel)); 
     202        } 
     203 
     204        /** 
     205         * <!-- begin-user-doc --> 
     206         * <!-- end-user-doc --> 
     207         * @generated 
     208         */ 
     209        public boolean isDirty() { 
     210                return (flags & DIRTY_EFLAG) != 0; 
     211        } 
     212 
     213        /** 
     214         * <!-- begin-user-doc --> 
     215         * <!-- end-user-doc --> 
     216         * @generated 
     217         */ 
     218        public void setDirty(boolean newDirty) { 
     219                boolean oldDirty = (flags & DIRTY_EFLAG) != 0; 
     220                if (newDirty) 
     221                        flags |= DIRTY_EFLAG; 
     222                else 
     223                        flags &= ~DIRTY_EFLAG; 
     224                if (eNotificationRequired()) 
     225                        eNotify(new ENotificationImpl(this, Notification.SET, 
     226                                        AXDocPackage.AX_ROOT__DIRTY, oldDirty, newDirty)); 
    181227        } 
    182228 
     
    245291                case AXDocPackage.AX_ROOT__ROOT_LEVEL: 
    246292                        return getRootLevel(); 
     293                case AXDocPackage.AX_ROOT__DIRTY: 
     294                        return isDirty() ? Boolean.TRUE : Boolean.FALSE; 
    247295                } 
    248296                return eDynamicGet(featureID, resolve, coreType); 
     
    287335                        setRootLevel((AXLevel) newValue); 
    288336                        return; 
     337                case AXDocPackage.AX_ROOT__DIRTY: 
     338                        setDirty(((Boolean) newValue).booleanValue()); 
     339                        return; 
    289340                } 
    290341                eDynamicSet(featureID, newValue); 
     
    325376                case AXDocPackage.AX_ROOT__ROOT_LEVEL: 
    326377                        setRootLevel(ROOT_LEVEL_EDEFAULT); 
     378                        return; 
     379                case AXDocPackage.AX_ROOT__DIRTY: 
     380                        setDirty(DIRTY_EDEFAULT); 
    327381                        return; 
    328382                } 
     
    362416                case AXDocPackage.AX_ROOT__ROOT_LEVEL: 
    363417                        return rootLevel != ROOT_LEVEL_EDEFAULT; 
     418                case AXDocPackage.AX_ROOT__DIRTY: 
     419                        return ((flags & DIRTY_EFLAG) != 0) != DIRTY_EDEFAULT; 
    364420                } 
    365421                return eDynamicIsSet(featureID); 
     
    383439                result.append(", rootLevel: "); 
    384440                result.append(rootLevel); 
     441                result.append(", dirty: "); 
     442                result.append((flags & DIRTY_EFLAG) != 0); 
    385443                result.append(')'); 
    386444                return result.toString(); 
  • org.axdt.axdoc.model/src/org/axdt/axdoc/model/util/AXUtil.java

    r87f02d1 r2d81bf0  
    2020        private static AXDocXMLProcessor xmlProcessor = new AXDocXMLProcessor(); 
    2121        private static AXDocFactory factory = AXDocFactory.eINSTANCE; 
    22         public static Resource getResource(String path) { 
     22        public static Resource createResource(String path) { 
    2323                return xmlProcessor.createResourceSet().createResource(URI.createURI(path)); 
    2424        } 
    25         public static Resource getRelatedResource(Resource resource, EObject node, 
    26                         String path) { 
    27                 ResourceSet set = (resource != null) ? resource.getResourceSet() : null;  
    28                 return getResource(set, node, path); 
    29         } 
    30         public static Resource getResource(ResourceSet set, EObject rootNode, String path) { 
    31                 Resource resource = rootNode.eResource(); 
     25        public static Resource getOrCreateResource(ResourceSet set, EObject node, String path) { 
     26                Resource resource = node.eResource(); 
    3227                if (resource == null) { 
    3328                        if (set == null) 
    3429                                set = xmlProcessor.createResourceSet(); 
    3530                        resource = set.createResource(URI.createURI(path)); 
    36                         resource.getContents().add(rootNode); 
     31                        resource.getContents().add(node); 
    3732                } else if (path != null) { 
    3833                        resource.setURI(URI.createURI(path)); 
     
    4136        } 
    4237        public static String writeToString(EObject node) throws IOException { 
    43                 return writeToString(getRelatedResource(node.eResource(),node, null)); 
     38                ResourceSet set = (node.eResource() != null) ? node.eResource().getResourceSet() : null;  
     39                return writeToString(getOrCreateResource(set, node, null)); 
    4440        } 
    4541        public static String writeToString(Resource resource) throws IOException { 
     
    4945        } 
    5046        public static Resource readFromString(String text, String path) throws IOException { 
    51                 Resource resource = getResource(path); 
     47                Resource resource = createResource(path); 
    5248                ByteArrayInputStream inputStream = new ByteArrayInputStream(text.getBytes()); 
    5349                resource.load(inputStream, null); 
    5450                return resource; 
    55         } 
    56         public static Resource writeToFile(EObject rootNode, String path) throws IOException { 
    57                 Resource resource = getRelatedResource(null,rootNode,path); 
    58                 resource.save(null); 
    59                 return resource; 
    60         } 
    61         public static void writeToDir(AXRoot rootNode, String path) throws IOException { 
    62                 ResourceSet set = rootNode.eResource().getResourceSet(); 
    63                 for (Resource res : set.getResources()) { 
    64                         res.save(null); 
    65                 } 
    6651        } 
    6752        public static AXRoot createRoot(String url, String basePath) { 
     
    7358                root.setUrl(url); 
    7459                ResourceSet set = xmlProcessor.createResourceSet(); 
    75                 getResource(set, root, resourceUrl); 
     60                getOrCreateResource(set, root, resourceUrl); 
    7661                return root; 
    7762        } 
  • org.axdt.axdoc.test/src/org/axdt/axdoc/model/AXEntryTest.java

    r85b4650 r2d81bf0  
    101101                // still need package 
    102102                assertNull(getFixture().getOrCreateReference()); 
    103                 AXRoot root = AXUtil.createRoot("test", "file:/tmp/axdoc.entryTest/asdoc", "file:/tmp/axdoc.entryTest/resources"); 
     103                AXRoot root = AXUtil.createRoot("test", 
     104                                "file:/tmp/axdoc.entryTest/asdoc", 
     105                                "file:/tmp/axdoc.entryTest/resources"); 
    104106                root.getEntries().add(getFixture()); 
    105107                AXNode ref = getFixture().getOrCreateReference(); 
     
    110112                assertEquals("Array", type.getName()); 
    111113                assertSame(type, getFixture().getOrCreateReference()); 
    112                  
    113                 AXEntry entry = getFixture().createEntry("toString", AXEntryType.METHOD); 
     114 
     115                AXEntry entry = getFixture() 
     116                                .createEntry("toString", AXEntryType.METHOD); 
    114117                ref = entry.getOrCreateReference(); 
    115118                assertNotNull(ref); 
  • org.axdt.axdoc.test/src/org/axdt/axdoc/model/AXIndexNodeTest.java

    r85b4650 r2d81bf0  
    3131 *   <li>{@link org.axdt.axdoc.model.AXIndexNode#createEntry(java.lang.String, org.axdt.axdoc.model.AXEntryType) <em>Create Entry</em>}</li> 
    3232 *   <li>{@link org.axdt.axdoc.model.AXIndexNode#getOrCreateReference() <em>Get Or Create Reference</em>}</li> 
     33 *   <li>{@link org.axdt.axdoc.model.AXIndexNode#getReference() <em>Get Reference</em>}</li> 
    3334 * </ul> 
    3435 * </p> 
     
    193194         */ 
    194195        public void testGetOrCreateReference() { 
    195                 // should be tested in  concrete implementations 
     196                // should be tested in concrete implementations 
     197        } 
     198 
     199        /** 
     200         * Tests the '{@link org.axdt.axdoc.model.AXIndexNode#getReference() <em>Get Reference</em>}' operation. 
     201         * <!-- begin-user-doc --> 
     202         * <!-- end-user-doc --> 
     203         * @see org.axdt.axdoc.model.AXIndexNode#getReference() 
     204         */ 
     205        public void testGetReference() { 
     206                // no tests needed. uses generated getter in implementations. 
    196207        } 
    197208 
  • org.axdt.axdoc.test/src/org/axdt/axdoc/model/AXIndexTest.java

    r85b4650 r2d81bf0  
    197197                // needs resource set 
    198198                assertNull(reference); 
    199                 Resource resource = AXUtil.getResource("test"); 
     199                Resource resource = AXUtil.createResource("test"); 
    200200                resource.getContents().add(getFixture()); 
    201201                reference = getFixture().getOrCreateReference(); 
  • org.axdt.axdoc.test/src/org/axdt/axdoc/model/AXRootTest.java

    r79dd699 r2d81bf0  
    66 */ 
    77package org.axdt.axdoc.model; 
     8 
     9import org.axdt.axdoc.model.util.AXUtil; 
    810 
    911import junit.textui.TestRunner; 
     
    121123        @Override 
    122124        public void testGetId() { 
     125                // not used for package serialization file name 
    123126                assertEquals("", getFixture().getId()); 
    124127                getFixture().setName("my lib"); 
    125128                assertEquals("", getFixture().getId()); 
     129                assertNull(getFixture().eResource()); 
     130                AXUtil.getOrCreateResource(null, getFixture(), "test"); 
     131                assertNotNull(getFixture().eResource()); 
     132                AXPackage reference = getFixture().getOrCreateReference(); 
     133                assertNotNull(reference.eResource()); 
     134                assertEquals("root-package.axdoc", reference.eResource().getURI().lastSegment()); 
    126135 
    127136                AXIndex index = AXDocFactory.eINSTANCE.createAXIndex(); 
  • org.axdt.axdoc.test/src/org/axdt/axdoc/model/util/AXDocUtilTest.java

    r85b4650 r2d81bf0  
    2727                String xmlNs = "xmlns:axdoc=\"http://axdt.org/axdoc\" "; 
    2828                String linebreak = "\n  "; 
    29                 assertNull(AXUtil.writeToString(AXUtil.getResource("test"))); 
     29                assertNull(AXUtil.writeToString(AXUtil.createResource("test"))); 
    3030                String simpleStart = header +"<axdoc:AXRoot "+ xmlNs; 
    3131                // create a some packages 
     
    4545                assertNull(pack.getReference()); 
    4646                AXPackage axp = AXDocFactory.eINSTANCE.createAXPackage(); 
    47                 AXUtil.getResource(pack.eResource().getResourceSet(), axp, "org.axdt.test.axdoc"); 
     47                AXUtil.getOrCreateResource(pack.eResource().getResourceSet(), axp, "org.axdt.test.axdoc"); 
    4848                axp.setName(pack.getName()); 
    4949                axp.getAsdoc().add("test"); 
  • org.axdt.axdoc/src/org/axdt/axdoc/preferences/AXDocPreferences.java

    r85b4650 r2d81bf0  
    1212public class AXDocPreferences extends AbstractPreferences { 
    1313 
    14         public final static String LANGREF_PATH = "LANGREF_PATH"; 
     14        public final static String AXDOC_URLS = "AXDOC_URLS"; 
    1515        private static AXDocPreferences instance; 
    1616 
     
    3232        @Override 
    3333        public void initializeFieldSpecs() { 
    34                 add(new DocTableField(LANGREF_PATH, "Asdoc uris", "file:/home/mb0/workspace/axdt/org.axdt.axdoc.test/data/asdoc")); 
     34                add(new DocTableField(AXDOC_URLS, "Asdoc URLs", "file:/home/mb0/workspace/axdt/org.axdt.axdoc.test/data/asdoc")); 
    3535        } 
    3636 
    3737        public static String getLangRefPathString() { 
    3838                IPreferenceStore store = getInstance().getStore(); 
    39                 return store.getString(LANGREF_PATH); 
     39                return store.getString(AXDOC_URLS); 
    4040        } 
    4141        public static void checkAXDocPaths(Index0r index0r) { 
  • org.axdt.axdoc/src/org/axdt/axdoc/util/AXDocParser.java

    r85b4650 r2d81bf0  
    2424                "b","code","div","ol","p","pre","span","table","ul" 
    2525        }; 
    26         protected static String URL_PACKAGE_LIST = "package-list.html"; 
    27         protected static String URL_PACKAGE_SUMMARY = "package-summary.html"; 
    28         protected static String URL_PACKAGE = "package.html"; 
    29         protected static String URL_PACKAGE_DETAIL = "package-detail.html"; 
    30         protected static String URL_CLASS_LIST = "class-list.html"; 
     26        public static String URL_PACKAGE_LIST = "package-list.html"; 
     27        public static String URL_PACKAGE_SUMMARY = "package-summary.html"; 
     28        public static String URL_PACKAGE = "package.html"; 
     29        public static String URL_PACKAGE_DETAIL = "package-detail.html"; 
     30        public static String URL_CLASS_LIST = "class-list.html"; 
    3131        /** 
    3232         * set whether to load detailed description 
     
    7979                int rLevel = root.getRootLevel().getValue(); 
    8080                if (AXLevel.PACKAGE_VALUE <= level.getValue()  
    81                                 && rLevel < AXLevel.PACKAGE_VALUE) 
     81                                && rLevel < AXLevel.PACKAGE_VALUE) { 
    8282                        parsePackageLevel(root); 
    8383                        root.setRootLevel(AXLevel.PACKAGE); 
     84                        root.setDirty(true); 
     85                } 
    8486                if (AXLevel.TYPE_VALUE <= level.getValue()  
    8587                                && rLevel < AXLevel.TYPE_VALUE) { 
     
    8789                        parseTypeLevel(root); 
    8890                        root.setRootLevel(AXLevel.TYPE); 
     91                        root.setDirty(true); 
    8992                } 
    9093                if (AXLevel.MEMBER_VALUE <= level.getValue()  
     
    9396                        parseMemberLevel(root); 
    9497                        root.setRootLevel(AXLevel.MEMBER); 
     98                        root.setDirty(true); 
    9599                } 
    96100                return root; 
  • org.axdt.axdoc/src/org/axdt/axdoc/util/Index0r.java

    r85b4650 r2d81bf0  
    33import java.io.IOException; 
    44import java.util.ArrayList; 
     5import java.util.Collection; 
    56import java.util.HashMap; 
     7import java.util.List; 
    68import java.util.Map; 
    79 
     
    1719import org.eclipse.core.runtime.Path; 
    1820import org.eclipse.emf.common.CommonPlugin; 
     21import org.eclipse.emf.common.util.EList; 
    1922import org.eclipse.emf.common.util.URI; 
    2023import org.eclipse.emf.ecore.EObject; 
     
    3639         
    3740        protected Map<String, AXRoot> roots; 
     41        protected Map<String, List<AXIndex>> packages; 
    3842        protected AXDocParser docParser; 
    3943        protected URI baseURI; 
     
    4145        public Index0r() { 
    4246                roots = new HashMap<String, AXRoot>(); 
     47                packages = new HashMap<String, List<AXIndex>>(); 
    4348                docParser = new AXDocParser(); 
    4449                baseURI = createBaseUri(); 
     
    9499                AXRoot root = roots.get(url); 
    95100                if (root == null) { 
    96                         URI resourcePath = baseURI.appendSegment(Integer.toHexString(url.hashCode())).appendSegment("root-index.axdoc"); 
    97                         if (new Path(resourcePath.toString()).toFile().exists()) { 
     101                        URI resourcePath = baseURI; 
     102                        if (resourcePath.hasTrailingPathSeparator()) resourcePath = resourcePath.trimSegments(1); 
     103                        resourcePath = resourcePath.appendSegment(Integer.toHexString(url.hashCode())).appendSegment("root-index.axdoc"); 
     104                        if (new Path(resourcePath.toFileString()).toFile().exists()) { 
    98105                                ResourceSet resset = new ResourceSetImpl(); 
    99106                                Resource resource = resset.createResource(resourcePath); 
     
    102109                                        if (resource.getContents().size()>0) { 
    103110                                                EObject object = resource.getContents().get(0); 
    104                                                 if (object instanceof AXRoot) 
    105                                                         return (AXRoot) object; 
     111                                                if (object instanceof AXRoot) { 
     112                                                        root = (AXRoot) object; 
     113                                                } 
    106114                                        } 
    107115                                } catch (IOException e) { 
    108                                         AXDocPlugin.getDefault().log("error loading axdoc file",e); 
     116                                        log("error loading axdoc file",e); 
    109117                                } 
    110118                        } else { 
     
    125133                        try { 
    126134                                docParser.parseDoc(root, level); 
    127                                 root.eResource().save(null); 
     135                                if (root.isDirty()) 
     136                                        saveRoot(root); 
    128137                        } catch (Exception e) { 
    129                                 if (AXDocPlugin.getDefault() != null) 
    130                                         AXDocPlugin.getDefault().log("error parsing asdoc at "+root.getUrl(), e); 
    131                                 else e.printStackTrace(); 
     138                                log("error parsing asdoc at "+root.getUrl(), e); 
    132139                        } 
    133140                } else { 
    134                         if (AXDocPlugin.getDefault() != null) 
    135                                 AXDocPlugin.getDefault().log("only asoc index is available"); 
     141                        log("only asoc index is available", null); 
     142                } 
     143                cachePackages(root); 
     144        } 
     145        protected void saveRoot(AXRoot root) throws IOException { 
     146                Resource index = root.eResource(); 
     147                index.save(null); 
     148                EList<Resource> resources = index.getResourceSet().getResources(); 
     149                for (Resource res:resources) { 
     150                        if (index.getURI().equals(res.getURI())) continue; 
     151                        try { 
     152                                res.save(null); 
     153                        } catch (IOException e) { 
     154                                log("error parsing asdoc at "+root.getUrl(), e); 
     155                        } 
    136156                } 
    137157        } 
     158        protected void log(String text, Exception e) { 
     159                if (AXDocPlugin.getDefault() != null) { 
     160                        AXDocPlugin.getDefault().log(text, e); 
     161                } else { 
     162                        System.err.println(text); 
     163                        if (e!= null) 
     164                                e.printStackTrace(); 
     165                } 
     166        } 
     167        public Collection<String> getPackageNames() { 
     168                return packages.keySet(); 
     169        } 
     170        private void cachePackages(AXIndex index) { 
     171                String id = index.getId(); 
     172                if (id != null && id.length()>0) { 
     173                        List<AXIndex> list = packages.get(id); 
     174                        if (list == null) { 
     175                                list = new ArrayList<AXIndex>(); 
     176                                packages.put(id, list); 
     177                        } 
     178                        if (!list.contains(index)) { 
     179                                list.add(index); 
     180                        } 
     181                } 
     182                for (AXIndex child:index.getIndexes()) { 
     183                        cachePackages(child); 
     184                } 
     185        } 
     186        protected void cachePackages() { 
     187                for (AXRoot root:roots.values()) { 
     188                        cachePackages(root); 
     189                } 
     190        } 
     191        public List<AXIndex> getPackages(String packname) { 
     192                return packages.get(packname); 
     193        } 
    138194}