Пример #1
0
  public LoadedDeclarations parse(XModelObject o, IPath source, IKbProject sp) {
    if (o == null) return null;

    if (o.getParent() instanceof FolderImpl) {
      IFile f = ResourcesPlugin.getWorkspace().getRoot().getFile(source);
      if (f != null && f.exists()) {
        try {
          ((FolderImpl) o.getParent()).updateChildFile(o, f.getLocation().toFile());
        } catch (XModelException e) {
          ModelPlugin.getPluginLog().logError(e);
        }
        if (o.getParent() == null) {
          boolean b = isLikelyComponentSource(f);
          if (!b) return null;
          o = EclipseResourceUtil.getObjectByResource(o.getModel(), f);
          if (o == null) return null;
        }
      }
    }

    LoadedDeclarations ds = new LoadedDeclarations();
    if (LibraryScanner.isTLDFile(o)) {
      parseTLD(o, source, ds);
    } else if (LibraryScanner.isFaceletTaglibFile(o)) {
      parseFaceletTaglib(o, source, ds);
    } else if (LibraryScanner.isFacesConfigFile(o)) {
      parseFacesConfig(o, source, ds);
    }
    return ds;
  }
 public static XModel getXModel(IFile file) {
   if (file == null) return null;
   XModelObject fs = EclipseResourceUtil.getObjectByResource(file);
   if (fs != null) return fs.getModel();
   IProject project = file.getProject();
   IModelNature nature = EclipseResourceUtil.getModelNature(project);
   return (nature == null) ? null : nature.getModel();
 }
Пример #3
0
 /**
  * This method should be called only if isRelevant returns true; Makes simple check if this java
  * file contains annotation Name.
  *
  * @param resource
  * @return
  */
 public boolean isLikelyComponentSource(IFile f) {
   if (!f.isSynchronized(IFile.DEPTH_ZERO) || !f.exists()) return false;
   XModel model = InnerModelHelper.createXModel(f.getProject());
   if (model == null) return false;
   XModelObject o = EclipseResourceUtil.getObjectByResource(model, f);
   return (o != null)
       && (LibraryScanner.isTLDFile(o)
           || LibraryScanner.isFaceletTaglibFile(o)
           || LibraryScanner.isFacesConfigFile(o));
 }
 private static IEditorInput convertFileInput(IFileEditorInput input) {
   IFileEditorInput fi = (IFileEditorInput) input;
   IFile f = fi.getFile();
   if (f != null && !f.isSynchronized(IResource.DEPTH_INFINITE)) {
     try {
       f.refreshLocal(IResource.DEPTH_INFINITE, null);
     } catch (CoreException e) {
       // ignore
     }
   }
   XModelObject o = EclipseResourceUtil.getObjectByResource(f);
   if (o == null) {
     o = EclipseResourceUtil.createObjectForResource(f);
   }
   return (o == null || o.getFileType() != XModelObject.FILE)
       ? input
       : new XModelObjectEditorInput(getMainObject(o));
 }
Пример #5
0
 /**
  * Returns list of components
  *
  * @param f
  * @return
  * @throws ScannerException
  */
 public LoadedDeclarations parse(IFile f, IKbProject sp) throws ScannerException {
   XModel model = InnerModelHelper.createXModel(f.getProject());
   if (model == null) return null;
   XModelObject o = EclipseResourceUtil.getObjectByResource(model, f);
   return parse(o, f.getFullPath(), sp);
 }