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); }
@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(); } }
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$ }