Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webservice repair #85

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<junit.jupiter.version>5.7.0</junit.jupiter.version>
<junit.platform.version>1.7.0</junit.platform.version>
<antlr.repo.sha>8803cbe8aca1b3b6ebf73e13f5c41665f393b381</antlr.repo.sha>
<j2v8.artifactId>j2v8_macosx_x86_64</j2v8.artifactId>
<j2v8.artifactId>j2v8_linux_x86_64</j2v8.artifactId>
</properties>
<repositories>
<repository>
Expand Down Expand Up @@ -88,7 +88,7 @@
<dependency>
<groupId>com.eclipsesource.j2v8</groupId>
<artifactId>${j2v8.artifactId}</artifactId>
<version>4.6.0</version>
<version>4.8.0</version>
</dependency>
</dependencies>
<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ private abstract class TypeScriptMethodVisitor extends TypeScriptVisitor {

@Override
public void visit(String source) {
init();
sourceFile = getSource(source);
visit(sourceFile);
sourceFile = null;
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/com/felixgrund/codeshovel/util/TypeScript.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@ public class TypeScript {
private static TypeScript instance;
private final NodeJS nodeJS;
private static V8Object ts;
private static Thread thread;

private static Logger log = LoggerFactory.getLogger(TypeScript.class);

public static TypeScript getInstance() {
if (instance == null) {
Thread currentThread = Thread.currentThread();
if (instance == null || thread != currentThread) {
try {
thread = currentThread;
instance = new TypeScript();
} catch (IOException e) {
e.printStackTrace();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ public class TypeScriptVisitor {

public TypeScriptVisitor() {
ts = TypeScript.getInstance().getTS();
init();
}

public void visit(String source) {
init();
visit(getSource(source));
clear();
}
Expand All @@ -44,14 +44,13 @@ protected V8Object getSource(String source) {
return ts.executeObjectFunction("createSourceFile", parameters);
}

private void init() {
protected void init() {
scope = new MemoryManager(TypeScript.getInstance().getRuntime());
syntaxKind = ts.getObject("SyntaxKind");
}

protected void clear() {
scope.release();
init();
}

protected void visit(V8Object node) {
Expand Down