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


Java LanguageFileType類代碼示例

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


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

示例1: fromTemplate

import com.intellij.openapi.fileTypes.LanguageFileType; //導入依賴的package包/類
/**
 * @param templateFile        Name of the generated file
 * @param destinationPath     Relative path to the target file system entry
 * @param extensionDefinition Extension definition containing all relevant metadata
 * @param context             Template Context variables
 * @param project             Project in context
 */
public static PsiElement fromTemplate(@NotNull String templateFile, @NotNull String destinationPath, @NotNull String destinationFileName, @NotNull TYPO3ExtensionDefinition extensionDefinition, @NotNull Map<String, String> context, Project project) {
    String template = readTemplateToString(templateFile, context);

    VirtualFile targetDirectory = getOrCreateDestinationPath(extensionDefinition.getRootDirectory(), destinationPath);

    LanguageFileType fileType = FileTypes.PLAIN_TEXT;
    if (templateFile.endsWith(".php")) {
        fileType = PhpFileType.INSTANCE;
    }

    PsiFile fileFromText = PsiFileFactory.getInstance(project).createFileFromText(destinationFileName, fileType, template);
    CodeStyleManager.getInstance(project).reformat(fileFromText);
    return PsiDirectoryFactory
            .getInstance(project)
            .createDirectory(targetDirectory)
            .add(fileFromText);
}
 
開發者ID:cedricziel,項目名稱:idea-php-typo3-plugin,代碼行數:25,代碼來源:ExtensionFileGenerationUtil.java

示例2: publicClassName

import com.intellij.openapi.fileTypes.LanguageFileType; //導入依賴的package包/類
@NotNull
private static String publicClassName(@NotNull Project project, @NotNull TaskFile taskFile, @NotNull LanguageFileType fileType) {
  String fileName = "Main";
  PsiFile file = PsiFileFactory.getInstance(project).createFileFromText(taskFile.name, fileType, taskFile.text);
  if (file instanceof PsiClassOwner) {
    PsiClassOwner fileFromText = (PsiClassOwner) file;
    PsiClass[] classes = fileFromText.getClasses();
    for (PsiClass aClass : classes) {
      boolean isPublic = aClass.hasModifierProperty(PsiModifier.PUBLIC);
      if (isPublic && aClass.getName() != null) {
        fileName = aClass.getName();
        break;
      }
    }
  }

  return fileName;
}
 
開發者ID:medvector,項目名稱:educational-plugin,代碼行數:19,代碼來源:EduIntellijUtils.java

示例3: assertIntentionIsAvailable

import com.intellij.openapi.fileTypes.LanguageFileType; //導入依賴的package包/類
public void assertIntentionIsAvailable(LanguageFileType languageFileType, String configureByText, String intentionText) {
    myFixture.configureByText(languageFileType, configureByText);
    PsiElement psiElement = myFixture.getFile().findElementAt(myFixture.getCaretOffset());

    Set<String> items = new HashSet<>();

    for (IntentionAction intentionAction : IntentionManager.getInstance().getIntentionActions()) {
        if(!intentionAction.isAvailable(getProject(), getEditor(), psiElement.getContainingFile())) {
            continue;
        }

        String text = intentionAction.getText();
        items.add(text);

        if(!text.equals(intentionText)) {
            continue;
        }

        return;
    }

    fail(String.format("Fail intention action '%s' is available in element '%s' with '%s'", intentionText, psiElement.getText(), items));
}
 
開發者ID:Haehnchen,項目名稱:idea-php-behat-plugin,代碼行數:24,代碼來源:BehatLightCodeInsightFixtureTestCase.java

示例4: getAssociatedFileType

import com.intellij.openapi.fileTypes.LanguageFileType; //導入依賴的package包/類
private static LanguageFileType getAssociatedFileType(VirtualFile file, Project project) {
    if (project == null) {
        return null;
    }
    Language language = TemplateDataLanguageMappings.getInstance(project).getMapping(file);

    LanguageFileType associatedFileType = null;
    if (language != null) {
        associatedFileType = language.getAssociatedFileType();
    }

    if (language == null || associatedFileType == null) {
        associatedFileType = RythmLanguage.getDefaultTemplateLang();
    }
    return associatedFileType;
}
 
開發者ID:scireum-incubator,項目名稱:rythm_plugin,代碼行數:17,代碼來源:RythmFileType.java

示例5: getAssociatedFileType

import com.intellij.openapi.fileTypes.LanguageFileType; //導入依賴的package包/類
private static LanguageFileType getAssociatedFileType(VirtualFile file, Project project) {
    if (project == null) {
        return null;
    }
    Language language = TemplateDataLanguageMappings.getInstance(project).getMapping(file);

    LanguageFileType associatedFileType = null;
    if (language != null) {
        associatedFileType = language.getAssociatedFileType();
    }

    if (language == null || associatedFileType == null) {
        associatedFileType = JetLanguage.getDefaultTemplateLang();
    }
    return associatedFileType;
}
 
開發者ID:jhsx,項目名稱:GoJetPlugin,代碼行數:17,代碼來源:JetFileType.java

示例6: JSR45PositionManager

import com.intellij.openapi.fileTypes.LanguageFileType; //導入依賴的package包/類
public JSR45PositionManager(DebugProcess debugProcess, Scope scope, final String stratumId, final LanguageFileType[] acceptedFileTypes,
                            final SourcesFinder<Scope> sourcesFinder) {
  myDebugProcess = debugProcess;
  myScope = scope;
  myStratumId = stratumId;
  myFileTypes = Collections.unmodifiableSet(new HashSet<LanguageFileType>(Arrays.asList(acceptedFileTypes)));
  mySourcesFinder = sourcesFinder;
  String generatedClassPattern = getGeneratedClassesPackage();
  if(generatedClassPattern.length() == 0) {
    generatedClassPattern = getGeneratedClassesNamePattern();
  }
  else {
    generatedClassPattern = generatedClassPattern + "." + getGeneratedClassesNamePattern();
  }
  GENERATED_CLASS_PATTERN = generatedClassPattern;
  myGeneratedClassPatternMatcher = Pattern.compile(generatedClassPattern.replaceAll("\\*", ".*")).matcher("");
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:18,代碼來源:JSR45PositionManager.java

示例7: acceptInput

import com.intellij.openapi.fileTypes.LanguageFileType; //導入依賴的package包/類
@Override
public boolean acceptInput(@NotNull final VirtualFile file) {
  if (!file.isInLocalFileSystem()) {
    return false; // do not index TODOs in library sources
  }

  final FileType fileType = file.getFileType();

  if (fileType instanceof LanguageFileType) {
    final Language lang = ((LanguageFileType)fileType).getLanguage();
    final ParserDefinition parserDef = LanguageParserDefinitions.INSTANCE.forLanguage(lang);
    final TokenSet commentTokens = parserDef != null ? parserDef.getCommentTokens() : null;
    return commentTokens != null;
  }

  return PlatformIdTableBuilding.isTodoIndexerRegistered(fileType) ||
         fileType instanceof CustomSyntaxTableFileType;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:19,代碼來源:TodoIndex.java

示例8: createTreeFromText

import com.intellij.openapi.fileTypes.LanguageFileType; //導入依賴的package包/類
public static PsiElement[] createTreeFromText(String text,
                                              PatternTreeContext context,
                                              FileType fileType,
                                              Language language,
                                              String contextName,
                                              Project project,
                                              boolean physical) throws IncorrectOperationException {
  if (language == null && fileType instanceof LanguageFileType) {
    language = ((LanguageFileType)fileType).getLanguage();
  }
  if (language != null) {
    StructuralSearchProfile profile = StructuralSearchUtil.getProfileByLanguage(language);
    if (profile != null) {
      return profile.createPatternTree(text, context, fileType, language, contextName, null, project, physical);
    }
  }
  return PsiElement.EMPTY_ARRAY;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:19,代碼來源:MatcherImplUtil.java

示例9: canHaveStub

import com.intellij.openapi.fileTypes.LanguageFileType; //導入依賴的package包/類
@Override
public boolean canHaveStub(VirtualFile file) {
  final FileType fileType = file.getFileType();
  if (fileType instanceof LanguageFileType) {
    Language l = ((LanguageFileType)fileType).getLanguage();
    ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(l);
    if (parserDefinition == null) return false;
    final IFileElementType elementType = parserDefinition.getFileNodeType();
    return elementType instanceof IStubFileElementType && ((IStubFileElementType)elementType).shouldBuildStubFor(file);
  }
  else if (fileType.isBinary()) {
    final BinaryFileStubBuilder builder = BinaryFileStubBuilders.INSTANCE.forFileType(fileType);
    return builder != null && builder.acceptsFile(file);
  }
  return false;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:17,代碼來源:CoreStubTreeLoader.java

示例10: getCumulativeVersion

import com.intellij.openapi.fileTypes.LanguageFileType; //導入依賴的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: calcBaseLanguage

import com.intellij.openapi.fileTypes.LanguageFileType; //導入依賴的package包/類
private static Language calcBaseLanguage(@NotNull VirtualFile file, @NotNull Project project, @NotNull final FileType fileType) {
  if (file instanceof LightVirtualFile) {
    final Language language = ((LightVirtualFile)file).getLanguage();
    if (language != null) {
      return language;
    }
  }

  if (fileType.isBinary()) return Language.ANY;
  if (isTooLargeForIntelligence(file)) return PlainTextLanguage.INSTANCE;

  if (fileType instanceof LanguageFileType) {
    return LanguageSubstitutors.INSTANCE.substituteLanguage(((LanguageFileType)fileType).getLanguage(), file, project);
  }

  return PlainTextLanguage.INSTANCE;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:18,代碼來源:SingleRootFileViewProvider.java

示例12: createFileFromText

import com.intellij.openapi.fileTypes.LanguageFileType; //導入依賴的package包/類
@Override
@NotNull
public PsiFile createFileFromText(@NotNull String name,
                                  @NotNull FileType fileType,
                                  @NotNull CharSequence text,
                                  long modificationStamp,
                                  final boolean eventSystemEnabled,
                                  boolean markAsCopy) {
  final LightVirtualFile virtualFile = new LightVirtualFile(name, fileType, text, modificationStamp);
  if(fileType instanceof LanguageFileType){
    final Language language =
        LanguageSubstitutors.INSTANCE.substituteLanguage(((LanguageFileType)fileType).getLanguage(), virtualFile, myManager.getProject());
    final PsiFile file = trySetupPsiForFile(virtualFile, language, eventSystemEnabled, markAsCopy);
    if (file != null) return file;
  }
  final SingleRootFileViewProvider singleRootFileViewProvider =
    new SingleRootFileViewProvider(myManager, virtualFile, eventSystemEnabled);
  final PsiPlainTextFileImpl plainTextFile = new PsiPlainTextFileImpl(singleRootFileViewProvider);
  if(markAsCopy) CodeEditUtil.setNodeGenerated(plainTextFile.getNode(), true);
  return plainTextFile;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:22,代碼來源:PsiFileFactoryImpl.java

示例13: substituteFileType

import com.intellij.openapi.fileTypes.LanguageFileType; //導入依賴的package包/類
@NotNull
public static FileType substituteFileType(@NotNull VirtualFile file, @NotNull FileType fileType, Project project) {
  if (project == null) {
    return fileType;
  }
  if (fileType instanceof LanguageFileType) {
    final Language language = ((LanguageFileType)fileType).getLanguage();
    final Language substitutedLanguage = LanguageSubstitutors.INSTANCE.substituteLanguage(language, file, project);
    LanguageFileType substFileType = substitutedLanguage.getAssociatedFileType();
    if (!substitutedLanguage.equals(language) && substFileType != null) {
      return new SubstitutedFileType(fileType, substFileType, substitutedLanguage);
    }
  }

  return fileType;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:17,代碼來源:SubstitutedFileType.java

示例14: canHaveStub

import com.intellij.openapi.fileTypes.LanguageFileType; //導入依賴的package包/類
public static boolean canHaveStub(@NotNull VirtualFile file) {
  final FileType fileType = file.getFileType();
  if (fileType instanceof LanguageFileType) {
    final Language l = ((LanguageFileType)fileType).getLanguage();
    final ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(l);
    if (parserDefinition == null) {
      return false;
    }

    final IFileElementType elementType = parserDefinition.getFileNodeType();
    if (elementType instanceof IStubFileElementType) {
      if (((IStubFileElementType)elementType).shouldBuildStubFor(file)) {
        return true;
      }
      if (IndexingStamp.isFileIndexedStateCurrent(file, INDEX_ID)) {
        return true;
      }
    }
  }
  final BinaryFileStubBuilder builder = BinaryFileStubBuilders.INSTANCE.forFileType(fileType);
  return builder != null && builder.acceptsFile(file);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:23,代碼來源:StubUpdatingIndex.java

示例15: updateFileTypeForEditorComponent

import com.intellij.openapi.fileTypes.LanguageFileType; //導入依賴的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


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