Java 类com.intellij.lang.properties.psi.impl.PropertiesFileImpl 实例源码

项目:intellij-ce-playground    文件:WrongPropertyKeyValueDelimiterInspection.java   
@NotNull
@Override
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
  if (!(holder.getFile() instanceof PropertiesFileImpl)) {
    return PsiElementVisitor.EMPTY_VISITOR;
  }
  final PropertiesCodeStyleSettings codeStyleSettings = PropertiesCodeStyleSettings.getInstance(holder.getProject());
  final char codeStyleKeyValueDelimiter = codeStyleSettings.KEY_VALUE_DELIMITER;
  return new PsiElementVisitor() {
    @Override
    public void visitElement(PsiElement element) {
      if (element instanceof PropertyImpl) {
        final Character delimiter = ((PropertyImpl)element).getKeyValueDelimiter();
        if (delimiter != null && !delimiter.equals(codeStyleKeyValueDelimiter)) {
          holder.registerProblem(element, PropertiesBundle.message("wrong.property.key.value.delimiter.inspection.display.name"), new ReplaceKeyValueDelimiterQuickFix(element));
        }
      }
    }
  };
}
项目:camel-idea-plugin    文件:CamelSmartCompletionEndpointOptions.java   
/**
 * We need special logic to determine when it should insert "=" at the end of the options
 */
@NotNull
private static LookupElementBuilder addInsertHandler(final Editor editor, final LookupElementBuilder builder, String suffix) {
    return builder.withInsertHandler((context, item) -> {
        // enforce using replace select char as we want to replace any existing option
        if (context.getCompletionChar() == Lookup.NORMAL_SELECT_CHAR) {
            int endSelectOffBy = 0;
            if (context.getFile() instanceof PropertiesFileImpl) {
                //if it's a property file the PsiElement does not start and end with an quot
                endSelectOffBy = 1;
            }
            final char text = context.getDocument().getCharsSequence().charAt(context.getSelectionEndOffset() - endSelectOffBy);
            if (text != '=') {
                EditorModificationUtil.insertStringAtCaret(editor, "=");
            }
        } else if (context.getCompletionChar() == Lookup.REPLACE_SELECT_CHAR) {
            // we still want to keep the suffix because they are other options
            String value = suffix;
            int pos = value.indexOf("&");
            if (pos > -1) {
                // strip out first part of suffix until next option
                value = value.substring(pos);
            }
            EditorModificationUtil.insertStringAtCaret(editor, "=" + value);
            // and move cursor back again
            int offset = -1 * value.length();
            EditorModificationUtil.moveCaretRelatively(editor, offset);
        }

    });
}
项目:intellij-ce-playground    文件:PropertiesStructureViewBuilderFactory.java   
@NotNull
public StructureViewBuilder getStructureViewBuilder(final PsiFile psiFile) {
  return new StructureViewBuilder() {
    @NotNull
    public StructureView createStructureView(FileEditor fileEditor, @NotNull Project project) {
      return new PropertiesFileStructureViewComponent(project, (PropertiesFileImpl)psiFile, fileEditor);
    }
  };
}
项目:intellij-ce-playground    文件:AlphaUnsortedPropertiesFileInspection.java   
@NotNull
@Override
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
  return new PsiElementVisitor() {
    @Override
    public void visitFile(PsiFile file) {
      final PropertiesFile propertiesFile = PropertiesImplUtil.getPropertiesFile(file);
      if (!(propertiesFile instanceof PropertiesFileImpl)) {
        return;
      }
      for (AlphaUnsortedPropertiesFileInspectionSuppressor filter : AlphaUnsortedPropertiesFileInspectionSuppressor.EP_NAME.getExtensions()) {
        if (filter.suppressInspectionFor(propertiesFile)) {
          return;
        }
      }
      final ResourceBundle resourceBundle = propertiesFile.getResourceBundle();
      final String resourceBundleBaseName = resourceBundle.getBaseName();
      if (!isResourceBundleAlphaSortedExceptOneFile(resourceBundle, propertiesFile)) {
        final List<PropertiesFile> allFiles = resourceBundle.getPropertiesFiles();
        holder.registerProblem(file, String.format(MESSAGE_TEMPLATE_WHOLE_RESOURCE_BUNDLE, resourceBundleBaseName),
                               ProblemHighlightType.INFO,
                               new PropertiesSorterQuickFix(true, allFiles.toArray(new PropertiesFile[allFiles.size()])));
        return;
      }
      if (!propertiesFile.isAlphaSorted()) {
        holder.registerProblem(file, "Properties file is unsorted", ProblemHighlightType.INFO, new PropertiesSorterQuickFix(true, propertiesFile));
      }
    }
  };
}
项目:intellij-ce-playground    文件:AlphaUnsortedPropertiesFileInspection.java   
private static boolean isResourceBundleAlphaSortedExceptOneFile(final @NotNull ResourceBundle resourceBundle,
                                                                final @NotNull PropertiesFile exceptedFile) {
  for (PropertiesFile file : resourceBundle.getPropertiesFiles()) {
    if (!(file instanceof PropertiesFileImpl)) {
      return true;
    }
    if (!file.equals(exceptedFile) && !file.isAlphaSorted()) {
      return false;
    }
  }
  return true;
}
项目:tools-idea    文件:PropertiesStructureViewBuilderFactory.java   
@NotNull
public StructureViewBuilder getStructureViewBuilder(final PsiFile psiFile) {
  return new StructureViewBuilder() {
    @NotNull
    public StructureView createStructureView(FileEditor fileEditor, Project project) {
      return new PropertiesFileStructureViewComponent(project, (PropertiesFileImpl)psiFile, fileEditor);
    }
  };
}
项目:intellij-ce-playground    文件:PropertiesFileStructureViewComponent.java   
public PropertiesFileStructureViewComponent(Project project, PropertiesFileImpl propertiesFile, FileEditor editor) {
  super(project, editor, new PropertiesFileStructureViewModel(propertiesFile));
  myPropertiesFile = propertiesFile;
}
项目:intellij-ce-playground    文件:PropertiesFileStructureViewElement.java   
protected PropertiesFileStructureViewElement(PropertiesFileImpl propertiesFile) {
  super(propertiesFile);
}
项目:intellij-ce-playground    文件:PropertiesFileStructureViewModel.java   
public PropertiesFileStructureViewModel(final PropertiesFileImpl root) {
  super(root);
  myPropertiesFile = root;
  String separator = PropertiesSeparatorManager.getInstance(root.getProject()).getSeparator(root.getResourceBundle());
  myByWordPrefixesGrouper = new GroupByWordPrefixes(separator);
}
项目:intellij-ce-playground    文件:PropertiesParserDefinition.java   
public PsiFile createFile(FileViewProvider viewProvider) {
  return new PropertiesFileImpl(viewProvider);
}
项目:tools-idea    文件:PropertiesFileStructureViewComponent.java   
public PropertiesFileStructureViewComponent(Project project, PropertiesFileImpl propertiesFile, FileEditor editor) {
  super(project, editor, new PropertiesFileStructureViewModel(propertiesFile));
  myPropertiesFile = propertiesFile;
}
项目:tools-idea    文件:PropertiesFileStructureViewElement.java   
protected PropertiesFileStructureViewElement(PropertiesFileImpl propertiesFile) {
  super(propertiesFile);
}
项目:tools-idea    文件:PropertiesFileStructureViewModel.java   
public PropertiesFileStructureViewModel(final PropertiesFileImpl root) {
  super(root);
  myPropertiesFile = root;
  String separator = PropertiesSeparatorManager.getInstance().getSeparator(root.getProject(), root.getVirtualFile());
  myGroupByWordPrefixes = new GroupByWordPrefixes(separator);
}
项目:tools-idea    文件:PropertiesParserDefinition.java   
public PsiFile createFile(FileViewProvider viewProvider) {
  return new PropertiesFileImpl(viewProvider);
}