Search in sources :

Example 16 with ITaglibRecord

use of org.eclipse.jst.jsp.core.taglib.ITaglibRecord in project webtools.sourceediting by eclipse.

the class TLDCMDocumentManager method getModificationStamp.

private long getModificationStamp(String reference) {
    IPath currentParserPath = getCurrentParserPath();
    if (currentParserPath == null) {
        return IResource.NULL_STAMP;
    }
    ITaglibRecord record = TaglibIndex.resolve(currentParserPath.toString(), reference, false);
    long modificationStamp = IResource.NULL_STAMP;
    if (record != null) {
        switch(record.getRecordType()) {
            case (ITaglibRecord.TLD):
                {
                    IFile tldfile = ResourcesPlugin.getWorkspace().getRoot().getFile(((ITLDRecord) record).getPath());
                    if (tldfile.isAccessible()) {
                        modificationStamp = tldfile.getModificationStamp();
                    }
                }
                break;
            case (ITaglibRecord.JAR):
                {
                    File jarfile = new File(((IJarRecord) record).getLocation().toOSString());
                    if (jarfile.exists()) {
                        try {
                            modificationStamp = jarfile.lastModified();
                        } catch (SecurityException e) {
                            modificationStamp = IResource.NULL_STAMP;
                        }
                    }
                }
                break;
            case (ITaglibRecord.TAGDIR):
                {
                    IFolder tagFolder = ResourcesPlugin.getWorkspace().getRoot().getFolder(((ITagDirRecord) record).getPath());
                    if (tagFolder.isAccessible()) {
                        IResource[] members;
                        try {
                            members = tagFolder.members();
                            for (int i = 0; i < members.length; i++) {
                                modificationStamp = Math.max(modificationStamp, members[i].getModificationStamp());
                            }
                        } catch (CoreException e) {
                            modificationStamp = IResource.NULL_STAMP;
                        }
                    }
                }
                break;
            case (ITaglibRecord.URL):
                {
                    String loc = ((IURLRecord) record).getBaseLocation();
                    if (loc != null && loc.endsWith(".jar")) {
                        // $NON-NLS-1$
                        File jarfile = new File(loc);
                        if (jarfile.exists()) {
                            try {
                                modificationStamp = jarfile.lastModified();
                            } catch (SecurityException e) {
                                modificationStamp = IResource.NULL_STAMP;
                            }
                        }
                    }
                }
                break;
            default:
                break;
        }
    }
    return modificationStamp;
}
Also used : IFile(org.eclipse.core.resources.IFile) IPath(org.eclipse.core.runtime.IPath) CoreException(org.eclipse.core.runtime.CoreException) ITaglibRecord(org.eclipse.jst.jsp.core.taglib.ITaglibRecord) ITLDRecord(org.eclipse.jst.jsp.core.taglib.ITLDRecord) ITagDirRecord(org.eclipse.jst.jsp.core.taglib.ITagDirRecord) IFile(org.eclipse.core.resources.IFile) File(java.io.File) IFolder(org.eclipse.core.resources.IFolder)

Aggregations

ITaglibRecord (org.eclipse.jst.jsp.core.taglib.ITaglibRecord)16 IProject (org.eclipse.core.resources.IProject)10 Path (org.eclipse.core.runtime.Path)10 IPath (org.eclipse.core.runtime.IPath)5 IFile (org.eclipse.core.resources.IFile)4 URL (java.net.URL)3 CMElementDeclarationImpl (org.eclipse.jst.jsp.core.internal.contentmodel.tld.CMElementDeclarationImpl)3 ITLDRecord (org.eclipse.jst.jsp.core.taglib.ITLDRecord)3 IURLRecord (org.eclipse.jst.jsp.core.taglib.IURLRecord)3 CMDocument (org.eclipse.wst.xml.core.internal.contentmodel.CMDocument)3 CoreException (org.eclipse.core.runtime.CoreException)2 CMDocumentFactoryTLD (org.eclipse.jst.jsp.core.internal.contentmodel.tld.CMDocumentFactoryTLD)2 IJarRecord (org.eclipse.jst.jsp.core.taglib.IJarRecord)2 ITagDirRecord (org.eclipse.jst.jsp.core.taglib.ITagDirRecord)2 ITextRegion (org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion)2 ITextRegionList (org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList)2 CMElementDeclaration (org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration)2 CMNamedNodeMap (org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap)2 CMNode (org.eclipse.wst.xml.core.internal.contentmodel.CMNode)2 IDOMNode (org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode)2