Java 类com.intellij.openapi.fileTypes.StdFileTypes 实例源码

项目:bamboo-soy    文件:SoyLayeredHighlighter.java   
public SoyLayeredHighlighter(
    @Nullable Project project,
    @Nullable VirtualFile virtualFile,
    @NotNull EditorColorsScheme colors) {
  // Creating main highlighter.
  super(new SoySyntaxHighlighter(), colors);

  // Highlighter for the outer language.
  FileType type = null;
  if (project == null || virtualFile == null) {
    type = StdFileTypes.PLAIN_TEXT;
  } else {
    Language language = TemplateDataLanguageMappings.getInstance(project).getMapping(virtualFile);
    if (language != null) type = language.getAssociatedFileType();
    if (type == null) type = SoyLanguage.getDefaultTemplateLang();
  }

  SyntaxHighlighter outerHighlighter =
      SyntaxHighlighterFactory.getSyntaxHighlighter(type, project, virtualFile);

  registerLayer(OTHER, new LayerDescriptor(outerHighlighter, ""));
}
项目:json2java4idea    文件:NewClassCommandAction.java   
@Override
protected void run(@NotNull Result<PsiFile> result) throws Throwable {
    final PsiPackage packageElement = directoryService.getPackage(directory);
    if (packageElement == null) {
        throw new InvalidDirectoryException("Target directory does not provide a package");
    }

    final String fileName = Extensions.append(name, StdFileTypes.JAVA);
    final PsiFile found = directory.findFile(fileName);
    if (found != null) {
        throw new ClassAlreadyExistsException("Class '" + name + "'already exists in " + packageElement.getName());
    }

    final String packageName = packageElement.getQualifiedName();
    final String className = Extensions.remove(this.name, StdFileTypes.JAVA);
    try {
        final String java = converter.convert(packageName, className, json);
        final PsiFile classFile = fileFactory.createFileFromText(fileName, JavaFileType.INSTANCE, java);
        CodeStyleManager.getInstance(classFile.getProject()).reformat(classFile);
        JavaCodeStyleManager.getInstance(classFile.getProject()).optimizeImports(classFile);
        final PsiFile created = (PsiFile) directory.add(classFile);
        result.setResult(created);
    } catch (IOException e) {
        throw new ClassCreationException("Failed to create new class from JSON", e);
    }
}
项目:Android-ORM-ASPlugin    文件:Utils.java   
public static List<VirtualFile> getJavaFileTree(Project project, VirtualFile file, boolean recursive) {
    List<VirtualFile> list = new ArrayList<VirtualFile>();
    if (!file.isDirectory()) {
        PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
        if (psiFile instanceof PsiJavaFile || file.getFileType().equals(StdFileTypes.JAVA)) {
            list.add(file);
        }
    } else if (recursive) {
        VirtualFile[] vfs = file.getChildren();
        if (vfs != null) {
            for (VirtualFile vf : vfs) {
                list.addAll(Utils.getJavaFileTree(project, vf, recursive));
            }
        }
    }
    return list;
}
项目:intellij-ce-playground    文件:GuiEditor.java   
private void handleEvent(final PsiTreeChangeEvent event) {
  if (event.getParent() != null) {
    PsiFile containingFile = event.getParent().getContainingFile();
    if (containingFile instanceof PropertiesFile) {
      LOG.debug("Received PSI change event for properties file");
      myAlarm.cancelRequest(myRefreshPropertiesRequest);
      myAlarm.addRequest(myRefreshPropertiesRequest, 500, ModalityState.stateForComponent(GuiEditor.this));
    }
    else if (containingFile instanceof PsiPlainTextFile && containingFile.getFileType().equals(StdFileTypes.GUI_DESIGNER_FORM)) {
      // quick check if relevant
      String resourceName = FormEditingUtil.buildResourceName(containingFile);
      if (myDocument.getText().indexOf(resourceName) >= 0) {
        LOG.debug("Received PSI change event for nested form");
        // TODO[yole]: handle multiple nesting
        myAlarm.cancelRequest(mySynchronizeRequest);
        myAlarm.addRequest(mySynchronizeRequest, 500, ModalityState.stateForComponent(GuiEditor.this));
      }
    }
  }
}
项目:dimenify    文件:BulkGenerateAction.java   
@Override
public void actionPerformed(AnActionEvent e) {
    super.actionPerformed(e);
    psiFile = e.getData(LangDataKeys.PSI_FILE);

    if (psiFile.getFileType() == StdFileTypes.XML) {
        xmlFile = (XmlFile) psiFile;
        String folderName = psiFile.getParent().getName();
        String bucket = null;
        if (folderName.startsWith(VALUES_PREFIX)) {
            bucket = folderName.substring(VALUES_PREFIX.length());
        } else if (folderName.equalsIgnoreCase(VALUES_PREFIX.substring(0, VALUES_PREFIX.length() - 1))) {
            bucket = Constants.MDPI;
        }


        if (bucket != null) {
            currentBucketIndex = getBucketIndex(psiFile);
            showScaleDialog(bucket, currentBucketIndex != -1);

        }
    }

}
项目:intellij-ce-playground    文件:SmartPsiElementPointersTest.java   
public void testUpdateAfterInsertingIdenticalText() {
  PsiJavaFile file = (PsiJavaFile)configureByText(StdFileTypes.JAVA, "class Foo {\n" +
                                                                     "    void m() {\n" +
                                                                     "    }\n" +
                                                                     "<caret>}\n");
  PsiMethod method = file.getClasses()[0].getMethods()[0];
  TextRange originalRange = method.getTextRange();
  SmartPsiElementPointer pointer = createPointer(method);

  EditorModificationUtil.insertStringAtCaret(myEditor, "    void m() {\n" +
                                                       "    }\n");
  PsiDocumentManager.getInstance(myProject).commitDocument(myEditor.getDocument());
  PsiElement element = pointer.getElement();
  assertNotNull(element);
  TextRange newRange = element.getTextRange();
  assertEquals(originalRange, newRange);
}
项目:intellij-ce-playground    文件:ImportModuleFromImlFileAction.java   
private static List<VirtualFile> getModuleNames(AnActionEvent e) {
  final VirtualFile[] files = e.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY);
  final Project project = getEventProject(e);
  if (project == null || files == null || files.length == 0) {
    return Collections.emptyList();
  }

  List<VirtualFile> modulesFiles = new ArrayList<VirtualFile>();
  for (VirtualFile file : files) {
    if (!file.getFileType().equals(StdFileTypes.IDEA_MODULE)) {
      return Collections.emptyList();
    }

    modulesFiles.add(file);
  }

  final ModuleManager moduleManager = ModuleManager.getInstance(project);
  for (Module module : moduleManager.getModules()) {
    modulesFiles.remove(module.getModuleFile());
  }
  return modulesFiles;
}
项目:intellij-ce-playground    文件:FormReferencesSearcher.java   
private static boolean scopeCanContainForms(SearchScope scope) {
  if (!(scope instanceof LocalSearchScope)) return true;
  LocalSearchScope localSearchScope = (LocalSearchScope) scope;
  final PsiElement[] elements = localSearchScope.getScope();
  for (final PsiElement element : elements) {
    if (element instanceof PsiDirectory) return true;
    boolean isForm = ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() {
      @Override
      public Boolean compute() {
        PsiFile file;
        if (element instanceof PsiFile) {
          file = (PsiFile)element;
        }
        else {
          if (!element.isValid()) return false;
          file = element.getContainingFile();
        }
        return file.getFileType() == StdFileTypes.GUI_DESIGNER_FORM;
      }
    });
    if (isForm) return true;
  }
  return false;
}
项目:intellij-ce-playground    文件:AddMethodsDialog.java   
private void showTemplateExample(final PseudoLambdaReplaceTemplate template, final PsiMethod method) {
  final PsiClass aClass = method.getContainingClass();
  LOG.assertTrue(aClass != null);
  final String fqn = aClass.getQualifiedName();
  LOG.assertTrue(fqn != null);
  final String parameters =
    StringUtil.join(ContainerUtil.map(method.getParameterList().getParameters(), new Function<PsiParameter, String>() {
      @Override
      public String fun(PsiParameter parameter) {
        return parameter.getName();
      }
    }), ", ");
  final String expressionText = fqn + "." + method.getName() + "(" + parameters + ")";
  final PsiExpression psiExpression = JavaPsiFacade.getElementFactory(method.getProject())
    .createExpressionFromText(expressionText, null);
  LOG.assertTrue(psiExpression instanceof PsiMethodCallExpression);
  final PsiMethodCallExpression methodCallExpression = (PsiMethodCallExpression)psiExpression;
  template.convertToStream(methodCallExpression, method, false);
  myBeforeActionPanel.reset("void example() {\n  <spot>" + methodCallExpression.getText() + "</spot>;\n}", StdFileTypes.JAVA);
  myAfterActionPanel.reset("void example() {\n  <spot>" + template.convertToStream(methodCallExpression, method, true).getText() + "</spot>\n}", StdFileTypes.JAVA);
}
项目:intellij-ce-playground    文件:JavaLanguageLevelPusher.java   
@Override
public void persistAttribute(@NotNull Project project, @NotNull VirtualFile fileOrDir, @NotNull LanguageLevel level) throws IOException {
  final DataInputStream iStream = PERSISTENCE.readAttribute(fileOrDir);
  if (iStream != null) {
    try {
      final int oldLevelOrdinal = DataInputOutputUtil.readINT(iStream);
      if (oldLevelOrdinal == level.ordinal()) return;
    }
    finally {
      iStream.close();
    }
  }

  final DataOutputStream oStream = PERSISTENCE.writeAttribute(fileOrDir);
  DataInputOutputUtil.writeINT(oStream, level.ordinal());
  oStream.close();

  for (VirtualFile child : fileOrDir.getChildren()) {
    if (!child.isDirectory() && StdFileTypes.JAVA.equals(child.getFileType())) {
      PushedFilePropertiesUpdater.getInstance(project).filePropertiesChanged(child);
    }
  }
}
项目:intellij-ce-playground    文件:JavaFormatterAlignmentTest.java   
public void testMethodCallArgumentsAndSmartTabs() throws IncorrectOperationException {
  // Inspired by IDEADEV-20144.
  getSettings().ALIGN_MULTILINE_PARAMETERS_IN_CALLS = true;
  getSettings().getRootSettings().getIndentOptions(StdFileTypes.JAVA).SMART_TABS = true;
  getSettings().getRootSettings().getIndentOptions(StdFileTypes.JAVA).USE_TAB_CHARACTER = true;
  doTextTest("class Foo {\n" +
             "    void foo() {\n" +
             "        bar(new Object[] {\n" +
             "            \"hello1\",\n" +
             "            \"hello2\", add(\"hello3\",\n" +
             "                           \"world\")\n" +
             "});" +
             "    }}", "class Foo {\n" +
                       "\tvoid foo() {\n" +
                       "\t\tbar(new Object[]{\n" +
                       "\t\t\t\t\"hello1\",\n" +
                       "\t\t\t\t\"hello2\", add(\"hello3\",\n" +
                       "\t\t\t\t              \"world\")\n" +
                       "\t\t});\n" +
                       "\t}\n" +
                       "}");
}
项目:intellij-ce-playground    文件:FormReferencesSearcher.java   
private static boolean processReferencesInFiles(List<PsiFile> files,
                                                PsiManager psiManager, String baseName,
                                                PsiElement element,
                                                LocalSearchScope filterScope,
                                                Processor<PsiReference> processor) {
  psiManager.startBatchFilesProcessingMode();

  try {
    for (PsiFile file : files) {
      ProgressManager.checkCanceled();

      if (file.getFileType() != StdFileTypes.GUI_DESIGNER_FORM) continue;
      if (!processReferences(processor, file, baseName, element, filterScope)) return false;
    }
  }
  finally {
    psiManager.finishBatchFilesProcessingMode();
  }
  return true;
}
项目:intellij-ce-playground    文件:EmmetUpdateTagAction.java   
private static void processTags(@NotNull Project project,
                                @Nullable String templateText,
                                @NotNull PairProcessor<XmlTag, Boolean> processor) {
  if (StringUtil.isNotEmpty(templateText)) {
    final PsiFileFactory psiFileFactory = PsiFileFactory.getInstance(project);
    XmlFile xmlFile = (XmlFile)psiFileFactory.createFileFromText("dummy.xml", StdFileTypes.HTML, templateText);
    XmlTag tag = xmlFile.getRootTag();
    boolean firstTag = true;

    while (tag != null) {
      processor.process(tag, firstTag);
      firstTag = false;
      tag = PsiTreeUtil.getNextSiblingOfType(tag, XmlTag.class);
    }
  }
}
项目:intellij-ce-playground    文件:JavaFormatterTest.java   
public void testLabel() throws Exception {
    final CommonCodeStyleSettings settings = getSettings();
    settings.getRootSettings().getIndentOptions(StdFileTypes.JAVA).LABEL_INDENT_ABSOLUTE = true;
    settings.SPECIAL_ELSE_IF_TREATMENT = true;
    settings.FOR_BRACE_FORCE = CommonCodeStyleSettings.FORCE_BRACES_ALWAYS;
    myTextRange = new TextRange(59, 121);
    doTextTest("public class Foo {\n" +
               "    public void foo() {\n" +
               "label2:\n" +
               "        for (int i = 0; i < 5; i++)\n" +
               "        {doSomething(i);\n" +
               "        }\n" +
               "    }\n" +
"}", "public class Foo {\n" +
     "    public void foo() {\n" +
     "label2:\n" +
     "        for (int i = 0; i < 5; i++) {\n" +
     "            doSomething(i);\n" +
     "        }\n" +
     "    }\n" +
     "}");
  }
项目:intellij-ce-playground    文件:PackageChooserDialog.java   
private void setupPathComponent(final JPanel northPanel) {
  northPanel.add(new TextFieldAction() {
    @Override
    public void linkSelected(LinkLabel aSource, Object aLinkData) {
      toggleShowPathComponent(northPanel, this);
    }
  }, BorderLayout.EAST);
  myPathEditor = new EditorTextField(JavaReferenceEditorUtil.createDocument("", myProject, false), myProject, StdFileTypes.JAVA);
  myPathEditor.addDocumentListener(new DocumentAdapter() {
    @Override
    public void documentChanged(DocumentEvent e) {
      myAlarm.cancelAllRequests();
      myAlarm.addRequest(new Runnable() {
        @Override
        public void run() {
          updateTreeFromPath();
        }
      }, 300);
    }
  });
  myPathEditor.setBorder(BorderFactory.createEmptyBorder(0, 0, 2, 0));
  northPanel.add(myPathEditor, BorderLayout.SOUTH);
}
项目:intellij-ce-playground    文件:ImportHelperTest.java   
@WrapInCommand
public void testConflictingClassesFromCurrentPackage() throws Throwable {
  final PsiFile file = configureByText(StdFileTypes.JAVA, "package java.util; class X{ Date d;}");
  assertEmpty(highlightErrors());

  new WriteCommandAction.Simple(getProject()) {
    @Override
    protected void run() throws Throwable {
      CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(getProject());
      ImportHelper importHelper = new ImportHelper(settings);

      PsiClass psiClass = JavaPsiFacade.getInstance(getProject()).findClass("java.sql.Date", GlobalSearchScope.allScope(getProject()));
      boolean b = importHelper.addImport((PsiJavaFile)file, psiClass);
      assertFalse(b); // must fail
    }
  }.execute().throwException();
}
项目:intellij-ce-playground    文件:ImportHelperTest.java   
public void testAutoImportAfterUncomment() throws Throwable {
  @NonNls String text = "class S { /*ArrayList l; HashMap h; <caret>*/ }";
  configureByText(StdFileTypes.JAVA, text);

  boolean old = CodeInsightSettings.getInstance().ADD_UNAMBIGIOUS_IMPORTS_ON_THE_FLY;
  CodeInsightSettings.getInstance().ADD_UNAMBIGIOUS_IMPORTS_ON_THE_FLY = true;
  DaemonCodeAnalyzerSettings.getInstance().setImportHintEnabled(true);

  try {
    doHighlighting();

    assertEmpty(((PsiJavaFile)getFile()).getImportList().getAllImportStatements());

    CommentByBlockCommentAction action = new CommentByBlockCommentAction();
    action.actionPerformedImpl(getProject(), getEditor());

    assertEmpty(highlightErrors());

    assertNotSame(0, ((PsiJavaFile)getFile()).getImportList().getAllImportStatements().length);
  }
  finally {
     CodeInsightSettings.getInstance().ADD_UNAMBIGIOUS_IMPORTS_ON_THE_FLY = old;
  }
}
项目:intellij-ce-playground    文件:ImportHelperTest.java   
public void testAutoInsertImportForInnerClass() throws Throwable {
  @NonNls String text = "package x; class S { void f(ReadLock r){} } <caret> ";
  configureByText(StdFileTypes.JAVA, text);

  boolean old = CodeInsightSettings.getInstance().ADD_UNAMBIGIOUS_IMPORTS_ON_THE_FLY;
  CodeInsightSettings.getInstance().ADD_UNAMBIGIOUS_IMPORTS_ON_THE_FLY = true;
  DaemonCodeAnalyzerSettings.getInstance().setImportHintEnabled(true);

  try {
    List<HighlightInfo> errs = highlightErrors();
    assertEquals(1, errs.size());

    assertEmpty(((PsiJavaFile)getFile()).getImportList().getAllImportStatements());
    type("/* */");
    doHighlighting();
    UIUtil.dispatchAllInvocationEvents();
    assertEmpty(((PsiJavaFile)getFile()).getImportList().getAllImportStatements());
  }
  finally {
     CodeInsightSettings.getInstance().ADD_UNAMBIGIOUS_IMPORTS_ON_THE_FLY = old;
  }
}
项目:intellij-ce-playground    文件:AndroidProblemFileHighlightingFilter.java   
@Override
public boolean value(VirtualFile file) {
  if (file.getFileType() != StdFileTypes.XML) {
    return false;
  }
  if (SdkConstants.FN_ANDROID_MANIFEST_XML.equals(file.getName())) {
    Module module = ModuleUtil.findModuleForFile(file, myProject);
    return module != null && AndroidFacet.getInstance(module) != null;
  }

  VirtualFile parent = file.getParent();
  if (parent == null) return false;
  parent = parent.getParent();
  if (parent == null) return false;
  return AndroidResourceUtil.isLocalResourceDirectory(parent, myProject);
}
项目:intellij-ce-playground    文件:ImportHelperTest.java   
public void testAutoImportDoNotBreakCode() throws Throwable {
  @NonNls String text = "package x; class S {{ S.<caret>\n Runnable r; }}";
  configureByText(StdFileTypes.JAVA, text);

  boolean old = CodeInsightSettings.getInstance().ADD_UNAMBIGIOUS_IMPORTS_ON_THE_FLY;
  boolean opt = CodeInsightSettings.getInstance().OPTIMIZE_IMPORTS_ON_THE_FLY;
  CodeInsightSettings.getInstance().ADD_UNAMBIGIOUS_IMPORTS_ON_THE_FLY = true;
  CodeInsightSettings.getInstance().OPTIMIZE_IMPORTS_ON_THE_FLY = true;
  DaemonCodeAnalyzerSettings.getInstance().setImportHintEnabled(true);

  try {
    List<HighlightInfo> errs = highlightErrors();
    assertEquals(1, errs.size());
  }
  finally {
     CodeInsightSettings.getInstance().ADD_UNAMBIGIOUS_IMPORTS_ON_THE_FLY = old;
     CodeInsightSettings.getInstance().OPTIMIZE_IMPORTS_ON_THE_FLY = opt;
  }
}
项目:intellij-ce-playground    文件:SSBasedInspectionTest.java   
@Override
protected void setUp() throws Exception {
  super.setUp();
  SSBasedInspection inspection = new SSBasedInspection();
  List<Configuration> configurations = new ArrayList<Configuration>();
  SearchConfiguration configuration = new SearchConfiguration();
  MatchOptions options = new MatchOptions();
  options.setFileType(StdFileTypes.JAVA);
  options.setSearchPattern("int i;");
  configuration.setMatchOptions(options);
  configurations.add(configuration);
  configuration = new SearchConfiguration();
  options = new MatchOptions();
  options.setFileType(StdFileTypes.JAVA);
  options.setSearchPattern("f();");
  configuration.setMatchOptions(options);
  configurations.add(configuration);
  inspection.setConfigurations(configurations, myProject);
  myWrapper = new LocalInspectionToolWrapper(inspection);
}
项目:intellij-ce-playground    文件:ClassToBindProperty.java   
public MyEditor(final Project project) {
  myProject = project;
  myEditorTextField = new EditorTextField("", project, StdFileTypes.JAVA) {
    protected boolean shouldHaveBorder() {
      return false;
    }
  };
  myActionListener = new MyActionListener();
  myTfWithButton = new ComponentWithBrowseButton<EditorTextField>(myEditorTextField, myActionListener);
  myEditorTextField.setBorder(null);
  new MyCancelEditingAction().registerCustomShortcutSet(CommonShortcuts.ESCAPE, myTfWithButton);
  /*
  myEditorTextField.addActionListener(
    new ActionListener() {
      public void actionPerformed(final ActionEvent e) {
        fireValueCommitted();
      }
    }
  );
  */
}
项目:intellij-ce-playground    文件:JoinLinesTest.java   
public void testUnwrapCodeBlock1() throws Exception {
  CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(getProject());
  boolean use_tab_character = settings.useTabCharacter(null);
  boolean smart_tabs = settings.isSmartTabs(null);
  int old = settings.IF_BRACE_FORCE;
  try {
    settings.getIndentOptions(StdFileTypes.JAVA).USE_TAB_CHARACTER = true;
    settings.getIndentOptions(StdFileTypes.JAVA).SMART_TABS = true;
    settings.getCommonSettings(JavaLanguage.INSTANCE).IF_BRACE_FORCE = CommonCodeStyleSettings.FORCE_BRACES_IF_MULTILINE;
    doTest();
  } finally {
    settings.getIndentOptions(StdFileTypes.JAVA).USE_TAB_CHARACTER = use_tab_character;
    settings.getIndentOptions(StdFileTypes.JAVA).SMART_TABS = smart_tabs;
    settings.getCommonSettings(JavaLanguage.INSTANCE).IF_BRACE_FORCE = old;
  }
}
项目:intellij-ce-playground    文件:RestEditorHighlighter.java   
public RestEditorHighlighter(@NotNull EditorColorsScheme scheme, @Nullable Project project, @Nullable VirtualFile file) {
  super(SyntaxHighlighterFactory.getSyntaxHighlighter(RestLanguage.INSTANCE, project, file), scheme);

  registerLayer(RestTokenTypes.PYTHON_LINE, new LayerDescriptor(
    SyntaxHighlighterFactory.getSyntaxHighlighter(PythonFileType.INSTANCE, project, file), "", EditorColors.INJECTED_LANGUAGE_FRAGMENT));

  FileType djangoTemplateFileType = FileTypeManager.getInstance().findFileTypeByName("DjangoTemplate");
  if (djangoTemplateFileType != null) {
    registerLayer(RestTokenTypes.DJANGO_LINE, new LayerDescriptor(
      SyntaxHighlighterFactory.getSyntaxHighlighter(djangoTemplateFileType, project, file), "",
      EditorColors.INJECTED_LANGUAGE_FRAGMENT));
  }

  registerLayer(RestTokenTypes.JAVASCRIPT_LINE, new LayerDescriptor(
    SyntaxHighlighterFactory.getSyntaxHighlighter(StdFileTypes.JS, project, file), "", EditorColors.INJECTED_LANGUAGE_FRAGMENT));
}
项目:Android-ORM-ASPlugin    文件:Utils.java   
public static boolean hasOrm(Project project, VirtualFile vf) {
    PsiFile psiFile = PsiManager.getInstance(project).findFile(vf);
    if (psiFile instanceof PsiJavaFile || vf.getFileType().equals(StdFileTypes.JAVA)) {
        PsiJavaFile jvf = (PsiJavaFile) psiFile;
        PsiClass psiClass = jvf.getClasses()[0];
        return Utils.findOrm(psiClass) != null;
    }
    return false;
}
项目:GravSupport    文件:LanguageNestingNode.java   
public void update(PresentationData presentation) {
    super.update(presentation);
    if (getValue() == null) {
        setValue(null);
    } else {
        presentation.setPresentableText("localization");
        presentation.setIcon(StdFileTypes.PROPERTIES.getIcon());
    }
}
项目:mule-intellij-plugins    文件:MuleConfigUtils.java   
public static boolean isMuleFile(PsiFile psiFile) {
    if (!(psiFile instanceof XmlFile)) {
        return false;
    }
    if (psiFile.getFileType() != StdFileTypes.XML) {
        return false;
    }
    final XmlFile psiFile1 = (XmlFile) psiFile;
    final XmlTag rootTag = psiFile1.getRootTag();
    return isMuleTag(rootTag);
}
项目:intellij-ce-playground    文件:DevKitFileTemplatesFactory.java   
public FileTemplateGroupDescriptor getFileTemplatesDescriptor() {
  FileTemplateGroupDescriptor descriptor = new FileTemplateGroupDescriptor(DevKitBundle.message("plugin.descriptor"),
                                                                           AllIcons.Nodes.Plugin);
  descriptor.addTemplate(new FileTemplateDescriptor("plugin.xml", StdFileTypes.XML.getIcon()));
  descriptor.addTemplate(new FileTemplateDescriptor("ProjectComponent.java", StdFileTypes.JAVA.getIcon()));
  descriptor.addTemplate(new FileTemplateDescriptor("ApplicationComponent.java", StdFileTypes.JAVA.getIcon()));
  descriptor.addTemplate(new FileTemplateDescriptor("ModuleComponent.java", StdFileTypes.JAVA.getIcon()));
  descriptor.addTemplate(new FileTemplateDescriptor("Action.java", StdFileTypes.JAVA.getIcon()));
  descriptor.addTemplate(new FileTemplateDescriptor("InspectionDescription.html", StdFileTypes.HTML.getIcon()));
  return descriptor;
}
项目:mule-intellij-plugins    文件:MuleConfigUtils.java   
@Nullable
private static XmlTag findFlowInScope(Project project, String flowName, GlobalSearchScope searchScope) {
    final Collection<VirtualFile> files = FileTypeIndex.getFiles(StdFileTypes.XML, searchScope);
    for (VirtualFile file : files) {
        XmlTag flow = findFlowInFile(project, flowName, file);
        if (flow != null) {
            return flow;
        }
    }
    return null;
}
项目:intellij-ce-playground    文件:XsltSymbolIndex.java   
@NotNull
@Override
public FileBasedIndex.InputFilter getInputFilter() {
    return new DefaultFileTypeSpecificInputFilter(StdFileTypes.XML) {
        @Override
        public boolean acceptInput(@NotNull VirtualFile file) {
            return !(file.getFileSystem() instanceof JarFileSystem);
        }
    };
}
项目:intellij-ce-playground    文件:JavaFormatterTest.java   
public void testJavaDocIndentation() throws Exception {
    getSettings().getRootSettings().getIndentOptions(StdFileTypes.JAVA).INDENT_SIZE = 2;
    getSettings().getRootSettings().getIndentOptions(StdFileTypes.JAVA).CONTINUATION_INDENT_SIZE = 2;
    getSettings().getRootSettings().getIndentOptions(StdFileTypes.JAVA).TAB_SIZE = 4;

    getSettings().getRootSettings().ENABLE_JAVADOC_FORMATTING = false;

    doTextTest("public interface PsiParser {\n" +
               "  /**\n" +
               "   * Parses the contents of the specified PSI builder and returns an AST tree with the\n" +
               "   * specified type of root element. The PSI builder contents is the entire file\n" +
               "   * or (if chameleon tokens are used) the text of a chameleon token which needs to\n" +
               "   * be reparsed.\n" +
               "   * @param root the type of the root element in the AST tree.\n" +
               "   * @param builder the builder which is used to retrieve the original file tokens and build the AST tree.\n" +
               "   * @return the root of the resulting AST tree.\n" +
               "   */\n" +
               "  ASTNode parse(IElementType root, PsiBuilder builder);\n" +
"}", "public interface PsiParser {\n" +
     "  /**\n" +
     "   * Parses the contents of the specified PSI builder and returns an AST tree with the\n" +
     "   * specified type of root element. The PSI builder contents is the entire file\n" +
     "   * or (if chameleon tokens are used) the text of a chameleon token which needs to\n" +
     "   * be reparsed.\n" +
     "   * @param root the type of the root element in the AST tree.\n" +
     "   * @param builder the builder which is used to retrieve the original file tokens and build the AST tree.\n" +
     "   * @return the root of the resulting AST tree.\n" +
     "   */\n" +
     "  ASTNode parse(IElementType root, PsiBuilder builder);\n" +
     "}");
  }
项目:rythm_plugin    文件:RythmLayeredSyntaxHighlighter.java   
public RythmLayeredSyntaxHighlighter(Project project, EditorColorsScheme scheme, FileType ptype, VirtualFile virtualFile) {
    super(new RythmSyntaxHighlighter(), scheme);

    FileType type = null;

    //Test for Java implementation
    FileType type1 = null;

    if (project == null || virtualFile == null) {
        type = StdFileTypes.PLAIN_TEXT;
    } else {
        Language language = TemplateDataLanguageMappings.getInstance(project).getMapping(virtualFile);
        if (language != null) type = language.getAssociatedFileType();
        if (type == null) {
            type = RythmLanguage.getDefaultTemplateLang();

            //Test for Java implementation
            //type1 = RythmLanguage.getLanguage();
        }

    }

    SyntaxHighlighter outerHighlighter = SyntaxHighlighterFactory.getSyntaxHighlighter(type, project, virtualFile);
    registerLayer(TEXT, new LayerDescriptor(outerHighlighter, ""));


    //Test for Java implementation
   /* SyntaxHighlighter middleHighlighter = SyntaxHighlighterFactory.getSyntaxHighlighter(type1, project, virtualFile);
    registerLayer(TEXT, new LayerDescriptor(middleHighlighter, ""));
   */

}
项目:GoJetPlugin    文件:JetFileViewProvider.java   
public JetFileViewProvider(PsiManager manager, VirtualFile file, boolean physical) {
    super(manager, file, physical);

    Language dataLang = TemplateDataLanguageMappings.getInstance(manager.getProject()).getMapping(file);
    if (dataLang == null) dataLang = StdFileTypes.HTML.getLanguage();

    if (dataLang instanceof TemplateLanguage) {
        myTemplateDataLanguage = PlainTextLanguage.INSTANCE;
    } else {
        myTemplateDataLanguage = LanguageSubstitutors.INSTANCE.substituteLanguage(dataLang, file, manager.getProject());
    }
}
项目:intellij-ce-playground    文件:CreateTypedResourceFileAction.java   
public CreateTypedResourceFileAction(@NotNull String resourcePresentableName,
                                     @NotNull ResourceFolderType resourceFolderType,
                                     boolean valuesResourceFile,
                                     boolean chooseTagName) {
  super(AndroidBundle.message("new.typed.resource.action.title", resourcePresentableName),
        AndroidBundle.message("new.typed.resource.action.description", resourcePresentableName), StdFileTypes.XML.getIcon());
  myResourceType = resourceFolderType;
  myResourcePresentableName = resourcePresentableName;
  myDefaultRootTag = getDefaultRootTagByResourceType(resourceFolderType);
  myValuesResourceFile = valuesResourceFile;
  myChooseTagName = chooseTagName;
}
项目:intellij-ce-playground    文件:AndroidEditorTitleProvider.java   
@Nullable
@Override
public String getEditorTabTitle(Project project, VirtualFile file) {
  if (DumbService.isDumb(project)) {
    return null;
  }

  if (file.getFileType() != StdFileTypes.XML) {
    return null;
  }

  // Resource file?
  if (file.getName().equals(FN_ANDROID_MANIFEST_XML)) {
    return null;
  }

  VirtualFile parent = file.getParent();
  if (parent == null) {
    return null;
  }

  String parentName = parent.getName();
  int index = parentName.indexOf('-');
  if (index == -1 || index == parentName.length() - 1) {
    return null;
  }

  ResourceFolderType folderType = ResourceFolderType.getFolderType(parentName);
  if (folderType == null) {
    return null;
  }

  return parentName.substring(index + 1) + File.separator + file.getPresentableName();
}
项目:intellij-ce-playground    文件:JavaFormatterTest.java   
public void testCastInsideElse() throws Exception {
  final CommonCodeStyleSettings settings = getSettings();
  final CommonCodeStyleSettings.IndentOptions indentOptions = settings.getRootSettings().getIndentOptions(StdFileTypes.JAVA);
  indentOptions.CONTINUATION_INDENT_SIZE = 2;
  indentOptions.INDENT_SIZE = 2;
  indentOptions.LABEL_INDENT_SIZE = 0;
  indentOptions.TAB_SIZE = 8;
  settings.SPACE_WITHIN_CAST_PARENTHESES = false;
  settings.SPACE_AFTER_TYPE_CAST = true;
  settings.ALIGN_MULTILINE_PARENTHESIZED_EXPRESSION = true;
  doTest();
}
项目:intellij-ce-playground    文件:CreateHtmlFileAction.java   
@Override
protected void buildDialog(Project project, PsiDirectory directory, CreateFileFromTemplateDialog.Builder builder) {
  builder
    .setTitle(XmlBundle.message("new.html.file.action"))
    .addKind("HTML 5 file", StdFileTypes.HTML.getIcon(), FileTemplateManager.INTERNAL_HTML5_TEMPLATE_NAME)
    .addKind("HTML 4 file", StdFileTypes.HTML.getIcon(), FileTemplateManager.INTERNAL_HTML_TEMPLATE_NAME)
    .addKind("XHTML file", StdFileTypes.XHTML.getIcon(), FileTemplateManager.INTERNAL_XHTML_TEMPLATE_NAME);
}
项目:intellij-ce-playground    文件:DebuggerUtilsEx.java   
public static String prepareValueText(String text, Project project) {
  text = StringUtil.unquoteString(text);
  text = StringUtil.unescapeStringCharacters(text);
  int tabSize = CodeStyleSettingsManager.getSettings(project).getTabSize(StdFileTypes.JAVA);
  if (tabSize < 0) {
    tabSize = 0;
  }
  return text.replace("\t", StringUtil.repeat(" ", tabSize));
}
项目:intellij-ce-playground    文件:FileIndexUtil.java   
public static boolean isJavaSourceFile(@NotNull Project project, @NotNull VirtualFile file) {
  FileTypeManager fileTypeManager = FileTypeManager.getInstance();
  if (file.isDirectory() || file.getFileType() != StdFileTypes.JAVA || fileTypeManager.isFileIgnored(file)) {
    return false;
  }
  ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
  return fileIndex.isUnderSourceRootOfType(file, JavaModuleSourceRootTypes.SOURCES) || fileIndex.isInLibrarySource(file);
}
项目:intellij-ce-playground    文件:PreviewFormAction.java   
public void update(final AnActionEvent e) {
  final GuiEditor editor = FormEditingUtil.getActiveEditor(e.getDataContext());

  if(editor == null){
    e.getPresentation().setVisible(false);
    return;
  }

  final VirtualFile file = editor.getFile();
  e.getPresentation().setVisible(
    FileDocumentManager.getInstance().getDocument(file) != null &&
    file.getFileType() == StdFileTypes.GUI_DESIGNER_FORM
  );
}