-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8133c39
commit 69c1ae3
Showing
33 changed files
with
507 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,14 +8,15 @@ | |
* Contributors: | ||
* Angelo Zerr <[email protected]> - initial API and implementation | ||
*/ | ||
package tern; | ||
package tern.repository; | ||
|
||
import java.io.File; | ||
|
||
import tern.TernException; | ||
import tern.server.ITernModule; | ||
|
||
/** | ||
* Tern repository is a base dir which contains the tern.js JS files : | ||
* Tern repository is a local base dir which contains the tern.js JS files : | ||
* | ||
* <ul> | ||
* <li>bin folder</li> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,12 +8,13 @@ | |
* Contributors: | ||
* Angelo Zerr <[email protected]> - initial API and implementation | ||
*/ | ||
package tern; | ||
package tern.repository; | ||
|
||
import java.io.File; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import tern.TernException; | ||
import tern.server.ITernModule; | ||
import tern.utils.ExtensionUtils; | ||
import tern.utils.TernModuleHelper; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/** | ||
* Copyright (c) 2013-2014 Angelo ZERR. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Angelo Zerr <[email protected]> - initial API and implementation | ||
*/ | ||
package tern.utils; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.io.InputStreamReader; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import org.apache.http.HttpEntity; | ||
import org.apache.http.HttpResponse; | ||
import org.apache.http.HttpStatus; | ||
import org.apache.http.StatusLine; | ||
import org.apache.http.client.ClientProtocolException; | ||
import org.apache.http.client.HttpClient; | ||
import org.apache.http.client.methods.HttpGet; | ||
import org.apache.http.impl.client.DefaultHttpClient; | ||
|
||
import tern.TernException; | ||
import tern.server.BasicTernPlugin; | ||
import tern.server.ITernModule; | ||
|
||
import com.eclipsesource.json.JsonObject; | ||
import com.eclipsesource.json.JsonObject.Member; | ||
|
||
/** | ||
* Helper for tern repository. | ||
* | ||
*/ | ||
public class TernRepositoryHelper { | ||
|
||
/** | ||
* Default tern repository.json URL | ||
*/ | ||
public static final String DEFAULT_TERN_REPOSITORY_URL = "https://raw.githubusercontent.com/angelozerr/tern.java/master/eclipse/tern.eclipse.ide.tools.ui/TO_DELETE/repository.json"; | ||
|
||
/** | ||
* Load tern modules coming from the given repository.json URL. | ||
* | ||
* @param repositoryURL | ||
* repository URL. | ||
* @return | ||
* @throws IOException | ||
* @throws ClientProtocolException | ||
* @throws TernException | ||
*/ | ||
public static List<ITernModule> loadModules(String repositoryURL) | ||
throws IOException, TernException { | ||
// load repository.json with HTTP client. | ||
HttpClient httpClient = new DefaultHttpClient(); | ||
HttpGet httpGet = new HttpGet(repositoryURL); | ||
HttpResponse httpResponse = httpClient.execute(httpGet); | ||
HttpEntity entity = httpResponse.getEntity(); | ||
InputStream in = entity.getContent(); | ||
// Check the status | ||
StatusLine statusLine = httpResponse.getStatusLine(); | ||
int statusCode = statusLine.getStatusCode(); | ||
if (statusCode != HttpStatus.SC_OK) { | ||
String message = IOUtils.toString(in); | ||
if (StringUtils.isEmpty(message)) { | ||
throw new TernException(statusLine.toString()); | ||
} | ||
throw new TernException(message); | ||
} | ||
|
||
// read JSON and create tern modules list | ||
JsonObject repository = JsonObject.readFrom(new InputStreamReader(in)); | ||
ITernModule module = null; | ||
List<ITernModule> modules = new ArrayList<ITernModule>(); | ||
for (Member member : repository) { | ||
module = new BasicTernPlugin(member.getName()); | ||
modules.add(module); | ||
} | ||
return modules; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.