Exemplo n.º 1
0
 protected void addJSFile(TernDoc doc, ITernFile file) throws IOException {
   TernQuery query = doc.getQuery();
   String fileName = file.getFullName(getProject());
   query.setFile(fileName);
   TernFile tf = file.toTernServerFile(getProject());
   doc.addFile(tf);
 }
Exemplo n.º 2
0
 @Override
 public void synchronizeFile(TernDoc doc, ITernFile file) throws IOException {
   writeLock.lock();
   try {
     try {
       TernQuery query = doc.getQuery();
       if (query != null) {
         if (TernResourcesManager.isJSFile(file)) {
           addJSFile(doc, file);
           sendFiles(doc);
           return;
         } else if (TernResourcesManager.isHTMLFile(file)) {
           // This is HTML file case: never keep the file on the server
           String queryType = query.getType();
           if (TernCompletionsQuery.isQueryType(queryType)
               || TernDefinitionQuery.isQueryType(queryType)
               || query instanceof TernLintQuery) {
             addHTMLFile(doc, file);
             return;
           }
         }
       }
       TernFile tf = file.toTernServerFile(getProject());
       String oldText = sentFiles.get(tf.getName());
       if (tf.getText().equals(oldText) && !uploader.cancel(tf.getName())) {
         // no need to synchronize the file, already up-to-date
         return;
       }
       doc.addFile(tf);
     } finally {
       updateSentFiles(doc);
       // as this is
       // wait a bit for the sync to finish
       uploader.join(TIMEOUT);
     }
   } finally {
     writeLock.unlock();
   }
 }
Exemplo n.º 3
0
 protected void addHTMLFile(TernDoc doc, ITernFile file) throws IOException {
   TernQuery query = doc.getQuery();
   TernFile tf = file.toTernServerFile(getProject());
   doc.addFile(tf);
   query.set("file", "#" + (doc.getFiles().size() - 1)); // $NON-NLS-1$ //$NON-NLS-2$
 }