Ejemplo n.º 1
0
 private void registerLanguageKeyMaps(Language language) {
   SModel editorModelDescriptor = LanguageAspect.EDITOR.get(language);
   SModel editorModel = (editorModelDescriptor != null ? editorModelDescriptor.getSModel() : null);
   List<KeyMap> keyMaps;
   if (editorModel != null) {
     keyMaps = ListSequence.fromList(new ArrayList<KeyMap>());
     for (SNode keyMapDeclaration :
         ListSequence.fromList(
             SModelOperations.getRoots(
                 editorModel, "jetbrains.mps.lang.editor.structure.CellKeyMapDeclaration"))) {
       try {
         Class<KeyMap> keyMapClass = findKeyMapClassByDeclaration(keyMapDeclaration);
         if (keyMapClass != null) {
           KeyMap keyMap = keyMapClass.newInstance();
           if (keyMap.isApplicableToEveryModel()) {
             ListSequence.fromList(keyMaps).addElement(keyMap);
           }
         }
       } catch (Throwable t) {
         LOG.error(t);
       }
     }
   } else {
     keyMaps = Collections.emptyList();
   }
   MapSequence.fromMap(myLanguagesToKeyMaps).put(language, keyMaps);
 }
Ejemplo n.º 2
0
 public static SNode getBinaryOperationType(SNode leftType, SNode rightType, boolean mayBeString) {
   List<SNode> leastCommonSupertypes =
       SubtypingUtil.leastCommonSuperTypes(Arrays.asList(leftType, rightType), null);
   if (mayBeString) {
     SModel javaLangJavaStubModelDescriptor =
         SModelRepository.getInstance()
             .getModelDescriptor(SModelReference.fromString("java.lang@java_stub"));
     assert javaLangJavaStubModelDescriptor != null;
     SModel javaLang = javaLangJavaStubModelDescriptor.getSModel();
     SNode stringClass = SModelOperations.getRootByName(javaLang, "String");
     if (SNodeOperations.isInstanceOf(
                 leftType, "jetbrains.mps.baseLanguage.structure.ClassifierType")
             && SLinkOperations.getTarget(
                     (SNodeOperations.cast(
                         leftType, "jetbrains.mps.baseLanguage.structure.ClassifierType")),
                     "classifier",
                     false)
                 == stringClass
         || SNodeOperations.isInstanceOf(
                 rightType, "jetbrains.mps.baseLanguage.structure.ClassifierType")
             && SLinkOperations.getTarget(
                     (SNodeOperations.cast(
                         rightType, "jetbrains.mps.baseLanguage.structure.ClassifierType")),
                     "classifier",
                     false)
                 == stringClass) {
       SNode classifierType =
           SConceptOperations.createNewNode(
               "jetbrains.mps.baseLanguage.structure.ClassifierType", null);
       SLinkOperations.setTarget(
           classifierType,
           "classifier",
           SNodeOperations.cast(stringClass, "jetbrains.mps.baseLanguage.structure.Classifier"),
           false);
       return classifierType;
     }
   }
   if (leastCommonSupertypes.isEmpty()) {
     SNode runtimeErrorType =
         SConceptOperations.createNewNode(
             "jetbrains.mps.lang.typesystem.structure.RuntimeErrorType", null);
     SPropertyOperations.set(runtimeErrorType, "errorText", "incompatible types");
     return runtimeErrorType;
   }
   SNode type = leastCommonSupertypes.iterator().next();
   {
     IMatchingPattern pattern_j6k1pf_e0c =
         HUtil.createMatchingPatternByConceptFQName(
             "jetbrains.mps.baseLanguage.structure.PrimitiveType");
     SNode coercedNode_j6k1pf_e0c =
         TypeChecker.getInstance().getRuntimeSupport().coerce_(type, pattern_j6k1pf_e0c);
     if (coercedNode_j6k1pf_e0c != null) {
       return coercedNode_j6k1pf_e0c;
     } else {
       return type;
     }
   }
 }
Ejemplo n.º 3
0
 private static SModel check_p1xi3x_b0a0c(SModel checkedDotOperand) {
   if (null != checkedDotOperand) {
     return checkedDotOperand.getSModel();
   }
   return null;
 }