コード例 #1
0
 private static void addInnerSequencePathCompletionsIfNeeded(
     @NotNull CompletionParameters parameters,
     @NotNull CompletionResultSet result,
     @NotNull BipartiteString caretBipartiteElementText) {
   PsiElement element = parameters.getPosition();
   YAMLKeyValue keyValue =
       JstdConfigFileUtils.getVerifiedHierarchyHead(
           element.getParent(),
           new Class[] {YAMLSequence.class, YAMLCompoundValue.class},
           YAMLKeyValue.class);
   BasePathInfo basePathInfo = newBasePathInfo(parameters);
   boolean keyMatched =
       keyValue != null && JstdConfigFileUtils.isTopLevelKeyWithInnerFileSequence(keyValue);
   if (basePathInfo != null && keyMatched) {
     VirtualFile basePath = basePathInfo.getBasePath();
     if (basePath != null && keyValue.getParent() instanceof YAMLDocument) {
       addPathCompletions(result, caretBipartiteElementText, basePath, false);
     }
   }
 }
コード例 #2
0
 private static void addTopLevelKeysCompletionIfNeeded(
     @NotNull CompletionParameters parameters,
     @NotNull CompletionResultSet result,
     @NotNull BipartiteString caretBipartiteElementText) {
   PsiElement element = parameters.getPosition();
   YAMLDocument yamlDocument = ObjectUtils.tryCast(element.getParent(), YAMLDocument.class);
   if (yamlDocument == null) {
     yamlDocument =
         JstdConfigFileUtils.getVerifiedHierarchyHead(
             element.getParent(), new Class[] {YAMLKeyValue.class}, YAMLDocument.class);
   }
   if (yamlDocument != null) {
     String prefix = caretBipartiteElementText.getPrefix();
     result = result.withPrefixMatcher(prefix);
     for (String key : JstdConfigFileUtils.VALID_TOP_LEVEL_KEYS) {
       if (key.startsWith(prefix)) {
         result.addElement(LookupItem.fromString(key + ":"));
       }
     }
   }
 }