Skip to content

Commit

Permalink
Polish.
Browse files Browse the repository at this point in the history
  • Loading branch information
traceyyoshima committed Nov 17, 2023
1 parent 5515292 commit eb23bb0
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ private JavaScriptParser(Collection<NamedStyles> styles) {
public Stream<SourceFile> parse(String... sources) {
List<Input> inputs = new ArrayList<>(sources.length);
for (int i = 0; i < sources.length; i++) {
Path path = Paths.get("f" + i + ".js");
Path path = Paths.get("f" + i + ".ts");
int j = i;
inputs.add(new Input(
path, null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,7 @@ public static <T> TSCConversion<List<T>> list(TSCConversion<T> of) {
}
V8ValueArray array = (V8ValueArray) value;
List<T> result = new ArrayList<>(array.getLength());
array.forEach(element -> {
result.add(of.convertNonNull(context, element));
});
array.forEach(element -> result.add(of.convertNonNull(context, element)));
return result;
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.caoccao.javet.values.V8Value;
import com.caoccao.javet.values.reference.V8ValueFunction;
import com.caoccao.javet.values.reference.V8ValueObject;
import lombok.Getter;
import lombok.Value;

import javax.annotation.Nullable;
Expand All @@ -39,9 +40,13 @@ public class TSCProgramContext extends TSCV8ValueHolder {
*/
private final Path compilerLibPath;

private TSCGlobals typescriptGlobals;
private TSCTypeChecker typeChecker;
private TSCInstanceOfChecks instanceOfChecks;
private final TSCGlobals typescriptGlobals;

@Getter
private final TSCTypeChecker typeChecker;

@Getter
private final TSCInstanceOfChecks instanceOfChecks;

final TSCObjectCache<TSCNode> nodeCache = lifecycleLinked(TSCObjectCache.usingInternalKey(TSCNode::wrap));
final TSCObjectCache<TSCNodeList> nodeListCache = lifecycleLinked(TSCObjectCache.usingInternalKey(TSCNodeList::wrap));
Expand Down Expand Up @@ -100,18 +105,10 @@ public long getInternalObjectId(V8ValueObject objectV8) {
}


public TSCTypeChecker getTypeChecker() {
return this.typeChecker;
}

public TSCGlobals getTypeScriptGlobals() {
return this.typescriptGlobals;
}

public TSCInstanceOfChecks getInstanceOfChecks() {
return this.instanceOfChecks;
}

public @Nullable TSCInstanceOfChecks.InterfaceKind identifyInterfaceKind(V8Value valueV8) {
return this.getInstanceOfChecks().identifyInterfaceKind(valueV8);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,17 @@

import com.caoccao.javet.exceptions.JavetException;
import com.caoccao.javet.values.reference.V8ValueObject;
import lombok.Getter;
import org.openrewrite.javascript.internal.tsc.generated.TSCSyntaxKind;

import java.nio.file.Path;

public class TSCSourceFileContext extends TSCV8ValueHolder {
@Getter
private final TSCProgramContext programContext;
private final V8ValueObject scanner;

@Getter
private final Path relativeSourcePath;

TSCSourceFileContext(TSCProgramContext programContext, String sourceText, Path relativeSourcePath) {
Expand All @@ -39,10 +42,6 @@ public class TSCSourceFileContext extends TSCV8ValueHolder {
resetScanner(0);
}

public TSCProgramContext getProgramContext() {
return programContext;
}

public Integer scannerTokenStart() {
try {
return this.scanner.invokeInteger("getTokenPos");
Expand Down Expand Up @@ -84,7 +83,4 @@ public TSCSyntaxKind nextScannerSyntaxType() {
}
}

public Path getRelativeSourcePath() {
return relativeSourcePath;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
public class TSCSymbol implements TSCV8Backed {

@Value
static class DebugInfo {
public static class DebugInfo {
List<TSCSymbolFlag> symbolFlags;
Map<String, Object> properties;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@

import com.caoccao.javet.values.reference.V8ValueObject;
import org.openrewrite.internal.lang.NonNull;
import org.openrewrite.internal.lang.Nullable;

import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.*;

public class TSCSyntaxListNode extends TSCNode implements List<TSCNode> {
@Nullable
private List<TSCNode> children;

public TSCSyntaxListNode(TSCProgramContext programContext, V8ValueObject nodeV8) {
Expand Down Expand Up @@ -82,7 +81,7 @@ public boolean remove(Object o) {

@Override
public boolean containsAll(@NonNull Collection<?> c) {
return getChildren().containsAll(c);
return new HashSet<>(getChildren()).containsAll(c);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

public class TSCType implements TSCV8Backed, TSCTypeAccessors {
@Value
static class DebugInfo {
public static class DebugInfo {
List<TSCTypeFlag> typeFlags;
List<TSCObjectFlag> objectFlags;
Map<String, Object> properties;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static String preview(String text, int maxLength) {
return text;
}

maxLength--; // to accomodate the ellipsis
maxLength--; // to accommodate the ellipsis
int startLength = maxLength / 2;
int endLength = maxLength - startLength;
return text.substring(0, startLength) + "…" + text.substring(text.length() - endLength);
Expand Down

0 comments on commit eb23bb0

Please sign in to comment.