Пример #1
0
  public static org.lgna.project.ast.NamedUserType getNamedUserTypeFromSuperType(
      org.lgna.project.ast.JavaType superType) {
    // <lg> Added to support generality in reuse
    if (superType.isAssignableTo(org.lgna.story.SScene.class)) {
      return getSceneUserType();
    }
    // </lg>

    org.lgna.project.ast.AbstractType<?, ?, ?> parameter0Type =
        ConstructorArgumentUtilities.getContructor0Parameter0Type(superType);
    ExtendsTypeCriterion criterion;
    if (parameter0Type != null) {
      criterion =
          new ExtendsTypeWithConstructorParameterTypeCriterion(
              superType, ConstructorArgumentUtilities.getContructor0Parameter0Type(superType));
    } else {
      criterion = new DefaultConstructorExtendsTypeCriterion(superType);
    }
    org.alice.ide.IDE ide = org.alice.ide.IDE.getActiveInstance();
    if (ide != null) {
      org.lgna.project.Project project = ide.getProject();
      if (project != null) {
        java.util.Set<org.lgna.project.ast.NamedUserType> existingTypes =
            project.getNamedUserTypes();
        for (org.lgna.project.ast.NamedUserType existingType : existingTypes) {
          if (criterion.accept(existingType)) {
            return existingType;
          }
        }
      }
    }
    return createTypeFor(superType, createClassNameFromSuperType(superType), null, null);
  }
 @Override
 protected void handleMouseQuoteExitedUnquote() {
   org.alice.ide.IDE ide = org.alice.ide.IDE.getActiveInstance();
   // <lg/> This should only show when editing code...
   if ((ide != null) && ide.getDocumentFrame().isInCodePerspective()) {
     ide.hideDropReceptorsStencil();
   }
   super.handleMouseQuoteExitedUnquote();
 }
 @Override
 protected void handleMouseQuoteEnteredUnquote() {
   super.handleMouseQuoteEnteredUnquote();
   org.alice.ide.IDE ide = org.alice.ide.IDE.getActiveInstance();
   // <lg/> This should only show when editing code...
   if ((ide != null) && ide.getDocumentFrame().isInCodePerspective()) {
     ide.showDropReceptorsStencilOver(this, getExpressionType());
   }
 }
 public FillInExpressionListPropertyEdit(
     edu.cmu.cs.dennisc.codec.BinaryDecoder binaryDecoder, Object step) {
   super(binaryDecoder, step);
   org.alice.ide.IDE ide = org.alice.ide.IDE.getActiveInstance();
   org.lgna.project.Project project = ide.getProject();
   java.util.UUID prevExpressionId = binaryDecoder.decodeId();
   this.prevExpression =
       org.lgna.project.ProgramTypeUtilities.lookupNode(project, prevExpressionId);
   java.util.UUID nextExpressionId = binaryDecoder.decodeId();
   this.nextExpression =
       org.lgna.project.ProgramTypeUtilities.lookupNode(project, nextExpressionId);
 }
Пример #5
0
 public static org.lgna.project.ast.NamedUserType getSceneUserType() {
   if (sceneUserTypeStack.isEmpty()) {
     // note: currently necessary for scene editor set up
     org.alice.ide.IDE ide = org.alice.ide.IDE.getActiveInstance();
     if (ide != null) {
       org.lgna.project.Project project = ide.getProject();
       if (project != null) {
         for (org.lgna.project.ast.UserField field :
             project.getProgramType().getDeclaredFields()) {
           if (field.valueType.getValue().isAssignableTo(org.lgna.story.SScene.class)) {
             return (org.lgna.project.ast.NamedUserType) field.valueType.getValue();
           }
         }
       }
     }
     return null;
   } else {
     return sceneUserTypeStack.peek();
   }
 }
 @Override
 protected org.lgna.project.ast.Expression createExpression(
     org.lgna.project.ast.Expression transientValueExpression) {
   return org.alice.ide.IDE.getActiveInstance().createCopy(transientValueExpression);
 }
Пример #7
0
  private static org.lgna.project.ast.NamedUserType createTypeFor(
      org.lgna.project.ast.AbstractType<?, ?, ?> superType,
      String typeName,
      org.lgna.project.ast.AbstractType<?, ?, ?>[] parameterTypes,
      org.lgna.project.ast.Expression[] argumentExpressions) {
    org.lgna.project.ast.NamedUserType rv = new org.lgna.project.ast.NamedUserType();
    rv.name.setValue(typeName);
    rv.superType.setValue(superType);

    for (org.lgna.project.ast.AbstractConstructor superConstructor :
        superType.getDeclaredConstructors()) {
      java.util.List<? extends org.lgna.project.ast.AbstractParameter> javaParameters =
          superConstructor.getRequiredParameters();

      org.lgna.project.ast.NamedUserConstructor userConstructor =
          new org.lgna.project.ast.NamedUserConstructor();
      org.lgna.project.ast.ConstructorBlockStatement body =
          new org.lgna.project.ast.ConstructorBlockStatement();
      org.lgna.project.ast.SuperConstructorInvocationStatement superConstructorInvocationStatement =
          new org.lgna.project.ast.SuperConstructorInvocationStatement();

      superConstructorInvocationStatement.constructor.setValue(superConstructor);

      final int N = javaParameters.size();
      for (int i = 0; i < N; i++) {
        org.lgna.project.ast.AbstractParameter javaParameterI = javaParameters.get(i);
        org.lgna.project.ast.Expression argumentExpressionI;
        if (argumentExpressions != USE_PARAMETER_ACCESSES_AS_ARGUMENTS_TO_SUPER) {
          argumentExpressionI = argumentExpressions[i];
        } else {
          String parameterName = javaParameterI.getName(); // todo?
          if (parameterName != null) {
            // pass
          } else {
            parameterName = "p" + i;
          }
          org.lgna.project.ast.AbstractType<?, ?, ?> parameterTypeI;
          if (parameterTypes != null) {
            parameterTypeI = parameterTypes[i];
          } else {
            parameterTypeI = javaParameterI.getValueType();
          }
          org.lgna.project.ast.UserParameter userParameterI =
              new org.lgna.project.ast.UserParameter(parameterName, parameterTypeI);
          userConstructor.requiredParameters.add(userParameterI);
          argumentExpressionI = new org.lgna.project.ast.ParameterAccess(userParameterI);
        }
        superConstructorInvocationStatement.requiredArguments.add(
            new org.lgna.project.ast.SimpleArgument(javaParameterI, argumentExpressionI));
      }

      body.constructorInvocationStatement.setValue(superConstructorInvocationStatement);
      userConstructor.body.setValue(body);

      rv.constructors.add(userConstructor);
    }

    org.alice.ide.IDE ide = org.alice.ide.IDE.getActiveInstance();
    if (ide != null) {
      ide.getApiConfigurationManager().augmentTypeIfNecessary(rv);
    }
    return rv;
  }