コード例 #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);
 }