package org.simantics.db.layer0.scl;
-import gnu.trove.map.hash.THashMap;
-
import java.util.ArrayList;
import java.util.List;
import org.simantics.scl.runtime.function.Function1;
import org.simantics.utils.datastructures.Pair;
+import gnu.trove.map.hash.THashMap;
+
/**
* <p>This is a base implementation for compiling expressions stored into
* graph. It provides a skeleton and a set of methods that must be
public static String compileDocumentSCLValueExpression(ReadGraph graph, Variable context) {
try {
- ServerSCLValueRequest.compile(graph, context);
+ ServerSCLValueRequest.validate(graph, context);
return "";
} catch (Exception e) {
return resolveIssueMessage(e);
import org.simantics.scl.compiler.elaboration.expressions.Expression;
import org.simantics.scl.compiler.elaboration.modules.SCLValue;
import org.simantics.scl.compiler.environment.Environment;
-import org.simantics.scl.compiler.environment.Environments;
import org.simantics.scl.compiler.environment.specification.EnvironmentSpecification;
import org.simantics.scl.compiler.runtime.RuntimeEnvironment;
-import org.simantics.scl.compiler.top.SCLExpressionCompilationException;
import org.simantics.scl.compiler.types.TCon;
import org.simantics.scl.compiler.types.Type;
import org.simantics.scl.compiler.types.Types;
import org.simantics.structural2.scl.FindPossibleComponentTypeRequest;
import org.simantics.structural2.scl.ReadComponentTypeInterfaceRequest;
import org.simantics.utils.datastructures.Pair;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
public class ServerSCLHandlerValueRequest extends AbstractExpressionCompilationRequest<CompilationContext, Variable> {
- private static final Logger LOGGER = LoggerFactory.getLogger(ServerSCLHandlerValueRequest.class);
-
private final Variable context;
private final Pair<Resource,Resource> componentTypeAndRoot;
private final Resource literal;
@Override
protected Type getExpectedType(ReadGraph graph, CompilationContext context) throws DatabaseException {
- if(possibleExpectedValueType != null) {
- try {
- return Environments.getType(context.runtimeEnvironment.getEnvironment(), possibleExpectedValueType);
- } catch (SCLExpressionCompilationException e) {
- LOGGER.error("Could not get type for " + String.valueOf(possibleExpectedValueType), e);
- }
- }
return super.getExpectedType(graph, context);
}
-
@Override
public int hashCode() {
final int prime = 31;
public class ServerSCLValueRequest extends AbstractExpressionCompilationRequest<CompilationContext, Variable> {
- private static final Logger LOGGER = LoggerFactory.getLogger(ServerSCLValueRequest.class);
-
private final Pair<Resource,Resource> componentTypeAndRoot;
private final Resource literal;
protected String possibleExpectedValueType;
@Override
protected Type getExpectedType(ReadGraph graph, CompilationContext context) throws DatabaseException {
- if(possibleExpectedValueType != null) {
- try {
- return Environments.getType(context.runtimeEnvironment.getEnvironment(), possibleExpectedValueType);
- } catch (SCLExpressionCompilationException e) {
- LOGGER.error("Could not get type for " + String.valueOf(possibleExpectedValueType), e);
- }
- }
return super.getExpectedType(graph, context);
}
ServerSCLValueRequest other = (ServerSCLValueRequest)obj;
return literal.equals(other.literal) && componentTypeAndRoot.equals(other.componentTypeAndRoot);
}
+
+ public static Function1<Variable, Object> validate(ReadGraph graph, Variable context) throws DatabaseException {
+ return graph.syncRequest(new ServerSCLValueValidationRequest(graph, context), TransientCacheListener.<Function1<Variable,Object>>instance());
+ }
+
+ public static class ServerSCLValueValidationRequest extends ServerSCLValueRequest {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(ServerSCLHandlerValueRequest.class);
+
+ public ServerSCLValueValidationRequest(ReadGraph graph, Variable context) throws DatabaseException {
+ super(graph, context);
+ }
+
+ @Override
+ protected Type getExpectedType(ReadGraph graph, CompilationContext context) throws DatabaseException {
+ if(possibleExpectedValueType != null) {
+ try {
+ return Environments.getType(context.runtimeEnvironment.getEnvironment(), possibleExpectedValueType);
+ } catch (SCLExpressionCompilationException e) {
+ LOGGER.error("Could not get type for " + String.valueOf(possibleExpectedValueType), e);
+ }
+ }
+ return super.getExpectedType(graph, context);
+ }
+ }
}