import org.osgi.service.component.annotations.Component;
import org.simantics.scl.compiler.commands.CommandSession;
import org.simantics.scl.compiler.common.names.Name;
+import org.simantics.scl.compiler.compilation.CompilationContext;
import org.simantics.scl.compiler.constants.JavaMethod;
import org.simantics.scl.compiler.elaboration.contexts.SimplificationContext;
import org.simantics.scl.compiler.elaboration.expressions.EApply;
value.setMacroRule(new MacroRule() {
@Override
public Expression apply(SimplificationContext context, Type[] typeParameters, EApply apply) {
- ConcreteModule module = context.getCompilationContext().module;
- String identifier;
- if (module != null)
- identifier = module.getName().replaceAll("/", ".");
- else
- identifier = CommandSession.class.getName();
+ String identifier = resolveModuleIdentifier(context.getCompilationContext());
apply.set(new ELiteral(javaMethod), new Expression[] {
new EExternalConstant(LoggerFactory.getLogger(identifier), Logger)
});
value.setMacroRule(new MacroRule() {
@Override
public Expression apply(SimplificationContext context, Type[] typeParameters, EApply apply) {
- ConcreteModule module = context.getCompilationContext().module;
- String identifier;
- if (module != null)
- identifier = module.getName().replaceAll("/", ".");
- else
- identifier = CommandSession.class.getName();
+ String identifier = resolveModuleIdentifier(context.getCompilationContext());
apply.set(new ELiteral(javaMethod), new Expression[] {
new EExternalConstant(LoggerFactory.getLogger(identifier), Logger),
apply.parameters[0]
value.setMacroRule(new MacroRule() {
@Override
public Expression apply(SimplificationContext context, Type[] typeParameters, EApply apply) {
- ConcreteModule module = context.getCompilationContext().module;
- String identifier;
- if (module != null)
- identifier = module.getName().replaceAll("/", ".");
- else
- identifier = CommandSession.class.getName();
+ String identifier = resolveModuleIdentifier(context.getCompilationContext());
apply.set(new ELiteral(javaMethod), new Expression[] {
new EExternalConstant(LoggerFactory.getLogger(identifier), Logger),
apply.parameters[0],
value.setMacroRule(new MacroRule() {
@Override
public Expression apply(SimplificationContext context, Type[] typeParameters, EApply apply) {
- ConcreteModule module = context.getCompilationContext().module;
- String identifier;
- if (module != null)
- identifier = module.getName().replaceAll("/", ".");
- else
- identifier = CommandSession.class.getName();
+ String identifier = resolveModuleIdentifier(context.getCompilationContext());
apply.set(new ELiteral(javaMethod), new Expression[] {
new EExternalConstant(LoggerFactory.getLogger(identifier), Logger),
apply.parameters[0],
value.setMacroRule(new MacroRule() {
@Override
public Expression apply(SimplificationContext context, Type[] typeParameters, EApply apply) {
- ConcreteModule module = context.getCompilationContext().module;
- String identifier;
- if (module != null)
- identifier = module.getName().replaceAll("/", ".");
- else
- identifier = CommandSession.class.getName();
+ String identifier = resolveModuleIdentifier(context.getCompilationContext());
apply.set(new ELiteral(javaMethod), new Expression[] {
new EExternalConstant(LoggerFactory.getLogger(identifier), Logger),
apply.parameters[0],
private static String capitalizeFirstCharacter(String input) {
return input.substring(0, 1).toUpperCase() + input.substring(1);
}
+
+ private static String resolveModuleIdentifier(CompilationContext context) {
+ ConcreteModule module = context.module;
+ String identifier;
+ if (module != null) {
+ String moduleName = module.getName();
+ if (moduleName.startsWith("http://")) {
+ moduleName = moduleName.substring("http://".length());
+ }
+ identifier = moduleName.replaceAll("/", ".");
+ } else {
+ identifier = CommandSession.class.getName();
+ }
+ return identifier;
+ }
}