當前位置: 首頁>>代碼示例>>Java>>正文


Java FileType類代碼示例

本文整理匯總了Java中com.intellij.openapi.fileTypes.FileType的典型用法代碼示例。如果您正苦於以下問題:Java FileType類的具體用法?Java FileType怎麽用?Java FileType使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


FileType類屬於com.intellij.openapi.fileTypes包,在下文中一共展示了FileType類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: isRBraceToken

import com.intellij.openapi.fileTypes.FileType; //導入依賴的package包/類
@Override
public boolean isRBraceToken(HighlighterIterator iterator, CharSequence fileText, FileType fileType) {
  BracePair pair = findPair(false, iterator, fileText, fileType);
  if (pair == null) return false;
  if (pair.getRightBraceType() != AppleScriptTypes.END)
    return super.isRBraceToken(iterator, fileText, fileType);//true;

  boolean result = false;
  int count = 0;
  while (true) {
    iterator.retreat();
    count++;
    if (iterator.atEnd()) break;
    IElementType eType = iterator.getTokenType();
    if (eType == AppleScriptTypes.NLS || eType == AppleScriptTypes.BLOCK_BODY)
      result = true;
    else break;
  }
  while (count-- > 0) iterator.advance();
  return result;
}
 
開發者ID:ant-druha,項目名稱:AppleScript-IDEA,代碼行數:22,代碼來源:AppleScriptPairedBraceMatcher.java

示例2: SoyLayeredHighlighter

import com.intellij.openapi.fileTypes.FileType; //導入依賴的package包/類
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, ""));
}
 
開發者ID:google,項目名稱:bamboo-soy,代碼行數:23,代碼來源:SoyLayeredHighlighter.java

示例3: doTestCompletion

import com.intellij.openapi.fileTypes.FileType; //導入依賴的package包/類
protected void doTestCompletion(final FileType fileType,
                                final String text,
                                final String toType,
                                final String result) {
  myFixture.configureByText(fileType, text);
  CommandProcessor.getInstance().executeCommand(getProject(), new Runnable() {
    @Override
    public void run() {
      ApplicationManager.getApplication().runWriteAction(new Runnable() {
        @Override
        public void run() {
          myFixture.completeBasic();
          if (toType != null) myFixture.type(toType);
        }
      });
    }
  }, "Typing", DocCommandGroupId.noneGroupId(myFixture.getEditor().getDocument()), myFixture.getEditor().getDocument());
  myFixture.checkResult(result);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:20,代碼來源:XmlSyncTagTest.java

示例4: testNonPhysicalFile

import com.intellij.openapi.fileTypes.FileType; //導入依賴的package包/類
public void testNonPhysicalFile() throws Exception {
  String fileName = "Test.java";
  FileType fileType = FileTypeRegistry.getInstance().getFileTypeByFileName(fileName);
  PsiFile psiFile = PsiFileFactory.getInstance(getProject()).createFileFromText(fileName, fileType, "class Test {}", 0, false);
  VirtualFile virtualFile = psiFile.getViewProvider().getVirtualFile();
  Document document = FileDocumentManager.getInstance().getDocument(virtualFile);
  assertNotNull(document);
  EditorFactory editorFactory = EditorFactory.getInstance();
  Editor editor = editorFactory.createViewer(document, getProject());
  try {
    editor.getSelectionModel().setSelection(0, document.getTextLength());
    String syntaxInfo = getSyntaxInfo(editor, psiFile);
    assertEquals("foreground=java.awt.Color[r=0,g=0,b=128],fontStyle=1,text=class \n" +
                 "foreground=java.awt.Color[r=0,g=0,b=0],fontStyle=0,text=Test {}\n", syntaxInfo);
  }
  finally {
    editorFactory.releaseEditor(editor);
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:20,代碼來源:SyntaxInfoConstructionTest.java

示例5: updateFileTypeForEditorComponent

import com.intellij.openapi.fileTypes.FileType; //導入依賴的package包/類
private void updateFileTypeForEditorComponent(@NotNull ComboBox inputComboBox) {
  final Component editorComponent = inputComboBox.getEditor().getEditorComponent();

  if (editorComponent instanceof EditorTextField) {
    boolean isRegexp = myCbRegularExpressions.isSelectedWhenSelectable();
    FileType fileType = PlainTextFileType.INSTANCE;
    if (isRegexp) {
      Language regexpLanguage = Language.findLanguageByID("RegExp");
      if (regexpLanguage != null) {
        LanguageFileType regexpFileType = regexpLanguage.getAssociatedFileType();
        if (regexpFileType != null) {
          fileType = regexpFileType;
        }
      }
    }
    String fileName = isRegexp ? "a.regexp" : "a.txt";
    final PsiFile file = PsiFileFactory.getInstance(myProject).createFileFromText(fileName, fileType, ((EditorTextField)editorComponent).getText(), -1, true);

    ((EditorTextField)editorComponent).setNewDocumentAndFileType(fileType, PsiDocumentManager.getInstance(myProject).getDocument(file));
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:22,代碼來源:FindDialog.java

示例6: createNewFile

import com.intellij.openapi.fileTypes.FileType; //導入依賴的package包/類
public Exception createNewFile(final VirtualFile parentDirectory, final String newFileName, final FileType fileType, final String initialContent) {
  final Exception[] failReason = new Exception[] { null };
  CommandProcessor.getInstance().executeCommand(
      myProject, new Runnable() {
        public void run() {
          ApplicationManager.getApplication().runWriteAction(new Runnable() {
            public void run() {
              try {
                final String newFileNameWithExtension = newFileName.endsWith('.'+fileType.getDefaultExtension())? newFileName : newFileName+'.'+fileType.getDefaultExtension();
                final VirtualFile file = parentDirectory.createChildData(this, newFileNameWithExtension);
                VfsUtil.saveText(file, initialContent != null ? initialContent : "");
                updateTree();
                select(file, null);
              }
              catch (IOException e) {
                failReason[0] = e;
              }
            }
          });
        }
      },
      UIBundle.message("file.chooser.create.new.file.command.name"),
      null
  );
  return failReason[0];
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:27,代碼來源:FileSystemTreeImpl.java

示例7: beforeCharTyped

import com.intellij.openapi.fileTypes.FileType; //導入依賴的package包/類
@Override
public Result beforeCharTyped(char character, Project project, Editor editor, PsiFile file, FileType fileType) {
  if (!(fileType instanceof PythonFileType)) return Result.CONTINUE; // else we'd mess up with other file types!
  if (character == ':') {
    final Document document = editor.getDocument();
    final int offset = editor.getCaretModel().getOffset();

    PsiElement token = file.findElementAt(offset - 1);
    if (token == null || offset >= document.getTextLength()) return Result.CONTINUE; // sanity check: beyond EOL

    PsiElement here_elt = file.findElementAt(offset);
    if (here_elt == null) return Result.CONTINUE; 
    if (here_elt instanceof PyStringLiteralExpression || here_elt.getParent() instanceof PyStringLiteralExpression) return Result.CONTINUE;

    // double colons aren't found in Python's syntax, so we can safely overtype a colon everywhere but strings.
    String here_text = here_elt.getText();
    if (":".equals(here_text)) {
      editor.getCaretModel().moveToOffset(offset + 1); // overtype, that is, jump over
      return Result.STOP;
    }
    PyUnindentingInsertHandler.unindentAsNeeded(project, editor, file);
  }

  return Result.CONTINUE; // the default
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:26,代碼來源:PyKeywordTypedHandler.java

示例8: CreateTaskFileDialog

import com.intellij.openapi.fileTypes.FileType; //導入依賴的package包/類
@SuppressWarnings("unchecked")
public CreateTaskFileDialog(@Nullable Project project, String generatedFileName, @NotNull final Course course) {
  super(project);
  myCourse = course;
  FileType[] fileTypes = FileTypeManager.getInstance().getRegisteredFileTypes();

  DefaultListModel model = new DefaultListModel();
  for (FileType type : fileTypes) {
    if (!type.isReadOnly() && !type.getDefaultExtension().isEmpty()) {
      model.addElement(type);
    }
  }
  myList.setModel(model);
  myTextField.setText(generatedFileName);
  setTitle("Create New Task File");
  init();
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:18,代碼來源:CreateTaskFileDialog.java

示例9: chooseTool

import com.intellij.openapi.fileTypes.FileType; //導入依賴的package包/類
@Nullable
private DiffTool chooseTool(DiffRequest data) {
  final DiffContent[] contents = data.getContents();

  if (contents.length == 2) {
    final FileType type1 = contents[0].getContentType();
    final FileType type2 = contents[1].getContentType();
    if (type1 == type2 && type1 instanceof UIBasedFileType) {
      return BinaryDiffTool.INSTANCE;
    }

    //todo[kb] register or not this instance in common diff tools ?
    if (type1 == type2 && type1 instanceof ArchiveFileType) {
      return ArchiveDiffTool.INSTANCE;
    }
  }

  for (DiffTool tool : myTools) {
    if (tool.canShow(data)) return tool;
  }
  return null;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:23,代碼來源:CompositeDiffTool.java

示例10: getCumulativeVersion

import com.intellij.openapi.fileTypes.FileType; //導入依賴的package包/類
public static int getCumulativeVersion() {
  int version = VERSION;
  for (final FileType fileType : FileTypeRegistry.getInstance().getRegisteredFileTypes()) {
    if (fileType instanceof LanguageFileType) {
      Language l = ((LanguageFileType)fileType).getLanguage();
      ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(l);
      if (parserDefinition != null) {
        final IFileElementType type = parserDefinition.getFileNodeType();
        if (type instanceof IStubFileElementType) {
          version += ((IStubFileElementType)type).getStubVersion();
        }
      }
    }

    BinaryFileStubBuilder builder = BinaryFileStubBuilders.INSTANCE.forFileType(fileType);
    if (builder != null) {
      version += builder.getStubVersion();
    }
  }
  return version;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:22,代碼來源:CumulativeStubVersion.java

示例11: customize

import com.intellij.openapi.fileTypes.FileType; //導入依賴的package包/類
@Override
public void customize(JList list, FileType type, int index, boolean selected, boolean hasFocus) {
  LayeredIcon layeredIcon = new LayeredIcon(2);
  layeredIcon.setIcon(EMPTY_ICON, 0);
  final Icon icon = type.getIcon();
  if (icon != null) {
    layeredIcon.setIcon(icon, 1, (- icon.getIconWidth() + EMPTY_ICON.getIconWidth())/2, (EMPTY_ICON.getIconHeight() - icon.getIconHeight())/2);
  }

  setIcon(layeredIcon);

  String description = type.getDescription();
  String trimmedDescription = StringUtil.capitalizeWords(description.replaceAll("(?i)\\s*file(?:s)?$", ""), true);
  if (isDuplicated(description)) {
    setText(trimmedDescription + " (" + type.getName() + ")");

  }
  else {
    setText(trimmedDescription);
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:22,代碼來源:FileTypeRenderer.java

示例12: getComponent

import com.intellij.openapi.fileTypes.FileType; //導入依賴的package包/類
@NotNull
@Override
public JComponent getComponent(@NotNull final DiffContext context) {
  final SimpleColoredComponent label = new SimpleColoredComponent();
  label.append("Can't show diff for unknown file type. ",
               new SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN, UIUtil.getInactiveTextColor()));
  if (myFileName != null) {
    label.append("Associate", SimpleTextAttributes.LINK_ATTRIBUTES, new Runnable() {
      @Override
      public void run() {
        DumbService.allowStartingDumbModeInside(DumbModePermission.MAY_START_BACKGROUND, new Runnable() {
          @Override
          public void run() {
            FileType type = FileTypeChooser.associateFileType(myFileName);
            if (type != null) onSuccess(context);
          }
        });
      }
    });
    LinkMouseListenerBase.installSingleTagOn(label);
  }
  return DiffUtil.createMessagePanel(label);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:24,代碼來源:UnknownFileTypeDiffRequest.java

示例13: checkAssociate

import com.intellij.openapi.fileTypes.FileType; //導入依賴的package包/類
public static boolean checkAssociate(final Project project, String fileName, DiffChainContext context) {
  final String pattern = FileUtilRt.getExtension(fileName).toLowerCase();
  if (context.contains(pattern)) return false;
  int rc = Messages.showOkCancelDialog(project,
                               VcsBundle.message("diff.unknown.file.type.prompt", fileName),
                               VcsBundle.message("diff.unknown.file.type.title"),
                                 VcsBundle.message("diff.unknown.file.type.associate"),
                                 CommonBundle.getCancelButtonText(),
                               Messages.getQuestionIcon());
  if (rc == Messages.OK) {
    FileType fileType = FileTypeChooser.associateFileType(fileName);
    return fileType != null && !fileType.isBinary();
  } else {
    context.add(pattern);
  }
  return false;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:18,代碼來源:ChangeDiffRequestPresentable.java

示例14: setupComboBox

import com.intellij.openapi.fileTypes.FileType; //導入依賴的package包/類
private void setupComboBox(final ComboBox combobox, FileType fileType) {
  final EditorComboBoxEditor comboEditor = new StringComboboxEditor(myProject, fileType, combobox) {
    @Override
    public void setItem(Object anObject) {
      myNonHumanChange = true;
      super.setItem(anObject);
    }
  };

  combobox.setEditor(comboEditor);
  combobox.setRenderer(new EditorComboBoxRenderer(comboEditor));

  combobox.setEditable(true);
  combobox.setMaximumRowCount(8);

  comboEditor.selectAll();
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:18,代碼來源:NameSuggestionsField.java

示例15: run

import com.intellij.openapi.fileTypes.FileType; //導入依賴的package包/類
@Override
public void run(FileType fileType) {
    if (m_compiler != null && (fileType instanceof RmlFileType || fileType instanceof OclFileType)) {
        ProcessHandler recreate = m_compiler.recreate();
        if (recreate != null) {
            getBsbConsole().attachToProcess(recreate);
            m_compiler.startNotify();
        }
    }
}
 
開發者ID:reasonml-editor,項目名稱:reasonml-idea-plugin,代碼行數:11,代碼來源:BucklescriptProjectComponent.java


注:本文中的com.intellij.openapi.fileTypes.FileType類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。