Java 类com.intellij.lang.javascript.JavaScriptFileType 实例源码

项目:idea-php-shopware-plugin    文件:ExtJsUtilTest.java   
/**
 * @see ExtJsUtil#getSnippetNamespaceFromFile
 */
public void testGetSnippetNamespaceFromFile() {
    String[] foo = {
        "//{namespace name=backend/index/view/widgets}",
        "//{namespace name = backend/index/view/widgets}",
        "//{namespace foobar='aaaa' name='backend/index/view/widgets' }",
        "//{namespace name=\"backend/index/view/widgets\" }",
    };

    for (String s : foo) {
        PsiFile fileFromText = PsiFileFactory.getInstance(getProject())
            .createFileFromText("foo.js", JavaScriptFileType.INSTANCE, s);

        assertEquals("backend/index/view/widgets", ExtJsUtil.getSnippetNamespaceFromFile(fileFromText));
    }
}
项目:consulo-nodejs    文件:NodeJSBundleType.java   
@Override
public void setupSdkPaths(Sdk sdk)
{
    SdkModificator modificator = sdk.getSdkModificator();

    VirtualFile stubsDirectory = LocalFileSystem.getInstance().findFileByIoFile(new File(PluginManager.getPluginPath(NodeJSBundleType.class), "stubs"));
    if(stubsDirectory != null)
    {
        for(VirtualFile file : stubsDirectory.getChildren())
        {
            if(file.getFileType() == JavaScriptFileType.INSTANCE)
            {
                modificator.addRoot(file, BinariesOrderRootType.getInstance());
                modificator.addRoot(file, SourcesOrderRootType.getInstance());
            }
        }
    }

    modificator.commitChanges();
}
项目:consulo-nodejs    文件:NodeJSConfigurationProducerUtil.java   
@Nullable
public static VirtualFile findExecutableFile(ConfigurationContext configurationContext, @Nullable Condition<JSFile> condition)
{
    PsiElement psiLocation = configurationContext.getPsiLocation();
    PsiFile psiFile = psiLocation == null ? null : psiLocation.getContainingFile();
    if(psiFile instanceof JSFile && psiFile.getFileType() == JavaScriptFileType.INSTANCE)
    {
        if(condition != null && !condition.value((JSFile) psiFile))
        {
            return null;
        }
        Module module = configurationContext.getModule();
        if(module == null)
        {
            return null;
        }
        NodeJSModuleExtension extension = ModuleUtilCore.getExtension(module, NodeJSModuleExtension.class);
        if(extension == null)
        {
            return null;
        }
        return psiFile.getVirtualFile();
    }
    return null;
}
项目:phpstorm-plugin-mediawiki    文件:MediaWikiJsPredefinedCodeStyle.java   
@Override
public void apply(CodeStyleSettings settings) {
    CommonCodeStyleSettings commonSettings = settings.getCommonSettings(getLanguage());

    commonSettings.SPACE_WITHIN_PARENTHESES = true;
    commonSettings.SPACE_WITHIN_METHOD_CALL_PARENTHESES = true;
    commonSettings.SPACE_WITHIN_METHOD_PARENTHESES = true;
    commonSettings.SPACE_WITHIN_IF_PARENTHESES = true;
    commonSettings.SPACE_WITHIN_WHILE_PARENTHESES = true;
    commonSettings.SPACE_WITHIN_FOR_PARENTHESES = true;
    commonSettings.SPACE_WITHIN_CATCH_PARENTHESES = true;
    commonSettings.SPACE_WITHIN_SWITCH_PARENTHESES = true;
    commonSettings.SPACE_WITHIN_ARRAY_INITIALIZER_BRACES = true;
    commonSettings.SPACE_AFTER_TYPE_CAST = true;

    CodeStyleSettings.IndentOptions indentOptions = settings.getIndentOptions(JavaScriptFileType.INSTANCE);
    indentOptions.USE_TAB_CHARACTER = true;
    indentOptions.SMART_TABS = true;
    indentOptions.TAB_SIZE = 4;
    indentOptions.INDENT_SIZE = 4;
    indentOptions.CONTINUATION_INDENT_SIZE = 4;
    indentOptions.LABEL_INDENT_SIZE = 0;
    indentOptions.LABEL_INDENT_ABSOLUTE = false;
    indentOptions.USE_RELATIVE_INDENTS = false;
}
项目:consulo-javascript    文件:JavaScriptLineBreakpointType.java   
public JavaScriptLineBreakpointType()
{
    super("javascript", "JavaScript Breakpoints", new XDebuggerEditorsProvider()
    {
        @NotNull
        @Override
        public FileType getFileType()
        {
            return JavaScriptFileType.INSTANCE;
        }

        @NotNull
        @Override
        public Document createDocument(@NotNull Project project, @NotNull String s, @Nullable XSourcePosition sourcePosition, @NotNull EvaluationMode evaluationMode)
        {
            return JSDebuggerSupportUtils.createDocument(s, project, sourcePosition == null ? null : sourcePosition.getFile(), sourcePosition == null ? 0 : sourcePosition.getOffset());
        }
    });
}
项目:js-graphql-intellij-plugin    文件:JSGraphQLNodeInterpreterEditorNotificationProvider.java   
protected boolean isGraphQLRelatedFile(VirtualFile file) {
    if(file.getFileType() == JSGraphQLFileType.INSTANCE) {
        return true;
    }
    if(JavaScriptFileType.getFileTypesCompilableToJavaScript().contains(file.getFileType())) {
        return true;
    }
    return false;
}
项目:idea-php-shopware-plugin    文件:SnippetIndex.java   
@NotNull
@Override
public FileBasedIndex.InputFilter getInputFilter() {
    return file -> {
        FileType fileType = file.getFileType();
        return fileType == SmartyFileType.INSTANCE || fileType == JavaScriptFileType.INSTANCE || "ini".equalsIgnoreCase(file.getExtension());
    };
}
项目:idea-php-shopware-plugin    文件:ShopwareJavaScriptCompletionTest.java   
public void testCompletionPrefixForSnippetNameWithFileScopeNamespace() {
    String[] dataProvider = {
        "{s name='<caret>'}",
        "{s name=<caret>}",
    };

    for (String s : dataProvider) {
        assertCompletionContains(
            JavaScriptFileType.INSTANCE,
            "//{namespace name=foobar/widgets}\n" +
                "var foo = {foo: \"" + s + "\"}",
            "swag-last-registrations/customer"
        );
    }
}
项目:idea-php-shopware-plugin    文件:ShopwareJavaScriptCompletionTest.java   
public void testCompletionPrefixForSnippetNameWithInlineNamespace() {
    String[] dataProvider = {
        "{s name='<caret>' name=foobar/widgets}",
        "{s name=<caret>} name=foobar/widgets}",
    };

    for (String s : dataProvider) {
        assertCompletionContains(
            JavaScriptFileType.INSTANCE,
            "//{namespace name=foobar/widgets}\n" +
                "var foo = {foo: \"" + s + "\"}",
            "swag-last-registrations/customer"
        );
    }
}
项目:idea-php-shopware-plugin    文件:ShopwareJavaScriptCompletionTest.java   
public void testCompletionPrefixForSnippetNamespace() {
    String[] dataProvider = {
        "{s namespace='<caret>'}",
        "{s namespace=<caret>}",
    };

    for (String s : dataProvider) {
        assertCompletionContains(
            JavaScriptFileType.INSTANCE,
            "var foo = {foo: \"" + s + "\"}",
            "foobar/widgets"
        );
    }
}
项目:idea-php-shopware-plugin    文件:ShopwareJavaScriptCompletionTest.java   
public void testCompletionPrefixForCommentNamespace() {
    assertCompletionContains(
        JavaScriptFileType.INSTANCE,
        "//{namespace name=<caret>}",
        "foobar/widgets"
    );
}
项目:idea-php-shopware-plugin    文件:ExtJsGoToDeclarationHandlerTest.java   
public void testSnippetsNavigation() {
    assertNavigationMatch(
        JavaScriptFileType.INSTANCE,
        "var foo = \"{s name='swag-last-registr<caret>ations/customer' namespace='foobar/widgets'}{/s}\"",
        PlatformPatterns.psiFile()
    );
}
项目:idea-php-shopware-plugin    文件:ExtJsGoToDeclarationHandlerTest.java   
public void testNamespaceAsCommentNavigation() {
    assertNavigationMatch(
        JavaScriptFileType.INSTANCE,
        "\n//{namespace name=foo<caret>bar/widgets}",
        PlatformPatterns.psiFile()
    );
}
项目:idea-php-shopware-plugin    文件:ExtJsUtilTest.java   
/**
 * @see ExtJsUtil#getNamespaceFromStringLiteral
 */
public void testGetNamespaceFromStringLiteral() {
    myFixture.configureByText(
        JavaScriptFileType.INSTANCE,
        "var foo = { foo: \"{s name=backend/inde<caret>x/view/widgets namespace='foobar'}\"}"
    );

    PsiElement psiElement = myFixture.getFile().findElementAt(myFixture.getCaretOffset()).getParent();

    assertEquals("foobar", ExtJsUtil.getNamespaceFromStringLiteral((JSLiteralExpression) psiElement));
}
项目:consulo-unity3d    文件:Unity3dModuleResolver.java   
@Nullable
@RequiredReadAction
public Module resolveModuleImpl(@NotNull PsiDirectory psiDirectory, @NotNull FileType fileType)
{
    if(fileType == CSharpFileType.INSTANCE)
    {
        return findModule(psiDirectory, "CSharp");
    }
    else if(fileType == JavaScriptFileType.INSTANCE)
    {
        return findModule(psiDirectory, "UnityScript");
    }
    return null;
}
项目:consulo-unity3d    文件:Unity3dProjectImportUtil.java   
private static Module createAssemblyUnityScriptModuleFirstPass(final Project project,
        ModifiableModuleModel newModel,
        final Sdk unityBundle,
        MultiMap<Module, VirtualFile> virtualFilesByModule,
        ProgressIndicator progressIndicator)
{

    return createAndSetupModule("Assembly-UnityScript-firstpass", project, newModel, FIRST_PASS_PATHS, unityBundle, null, "unity3d-unityscript-child", JavaScriptFileType.INSTANCE,
            virtualFilesByModule, progressIndicator);
}
项目:consulo-unity3d    文件:DefaultUnity3dProjectSourceFileTypeFactory.java   
@Override
public void registerFileTypes(Consumer<FileType> consumer)
{
    consumer.accept(DotNetModuleFileType.INSTANCE);
    consumer.accept(CSharpFileType.INSTANCE);
    consumer.accept(JavaScriptFileType.INSTANCE);
}
项目:consulo-unity3d    文件:UnityScriptDotNetTypeDeclaration.java   
@RequiredWriteAction
@Override
public PsiElement setName(@NonNls @NotNull String name) throws IncorrectOperationException
{
    myFile.setName(name + "." + JavaScriptFileType.INSTANCE.getDefaultExtension());
    return this;
}
项目:consulo-nodejs    文件:NodeJSFileTypeDetector.java   
@Nullable
@Override
public FileType detect(@NotNull VirtualFile file, @NotNull ByteSequence byteSequence, @Nullable CharSequence charSequence)
{
    if(FileUtil.isHashBangLine(charSequence, "/usr/bin/env node"))
    {
        return JavaScriptFileType.INSTANCE;
    }
    return null;
}
项目:consulo-javascript    文件:JavaScriptCreateFileAction.java   
@Override
protected void buildDialog(Project project, PsiDirectory directory, CreateFileFromTemplateDialog.Builder builder)
{
    builder.setTitle("Create JavaScript File");

    builder.addKind("Empty File", JavaScriptFileType.INSTANCE.getIcon(), "JavaScriptFile");
}
项目:consulo-javascript    文件:BaseJSGenerateAction.java   
@Override
public void update(final AnActionEvent e)
{
    final VirtualFile file = e.getData(PlatformDataKeys.VIRTUAL_FILE);

    boolean status = false;

    if(file != null)
    {
        if(file.getFileType() == JavaScriptFileType.INSTANCE)
        {
            final Editor editor = e.getData(PlatformDataKeys.EDITOR);
            final PsiFile psifile = e.getData(LangDataKeys.PSI_FILE);

            if(editor != null && psifile != null)
            {
                status = psifile.getLanguage() == JavaScriptSupportLoader.ECMA_SCRIPT_L4;
            }
        }
        else if(JavaScriptSupportLoader.isFlexMxmFile(file))
        {
            status = true;
        }
    }

    e.getPresentation().setEnabled(status);
    e.getPresentation().setVisible(status);
}
项目:consulo-javascript    文件:JSReferencesSearchExecutor.java   
@Override
public boolean execute(final ReferencesSearch.SearchParameters queryParameters, final Processor<PsiReference> consumer)
{
    final PsiElement sourceElement = queryParameters.getElementToSearch();

    if(sourceElement instanceof PsiNamedElement &&
            sourceElement.getLanguage().isKindOf(JavaScriptLanguage.INSTANCE) &&
            queryParameters.getScope() instanceof GlobalSearchScope &&
            !(sourceElement.getUseScope() instanceof LocalSearchScope))
    {
        final String s = ReadAction.compute(() -> ((PsiNamedElement) sourceElement).getName());
        if(s == null)
        {
            return true;
        }
        PsiSearchHelper.SERVICE.getInstance(sourceElement.getProject()).processAllFilesWithWordInLiterals(s, GlobalSearchScope.getScopeRestrictedByFileTypes(GlobalSearchScope.projectScope
                (sourceElement.getProject()), JavaScriptFileType.INSTANCE), new Processor<PsiFile>()
        {
            @Override
            public boolean process(final PsiFile psiFile)
            {
                /*if(psiFile.getLanguage() == JavaScriptSupportLoader.JSON)
                {
                    ReferencesSearch.search(sourceElement, new LocalSearchScope(psiFile)).forEach(consumer);
                }         */
                return true;
            }
        });
    }
    return true;
}
项目:idea-php-dotenv-plugin    文件:JsEnvironmentVariablesUsagesProvider.java   
@Override
public boolean acceptFile(VirtualFile file) {
    return file.getFileType().equals(JavaScriptFileType.INSTANCE);
}
项目:js-graphql-intellij-plugin    文件:JSGraphQLApolloLokkaEditorNotificationProvider.java   
private boolean isGraphQLInjectionRelatedFile(VirtualFile file) {
    return JavaScriptFileType.getFileTypesCompilableToJavaScript().contains(file.getFileType());
}
项目:eslint-plugin    文件:ESLintExternalAnnotator.java   
private static boolean isJavaScriptFile(PsiFile file, String ext) {
    return file instanceof JSFile && file.getFileType().equals(JavaScriptFileType.INSTANCE) || isInList(file.getName(), ext);
}
项目:CommonJSAutoComplete    文件:LangUtil.java   
public static boolean isJSFileType(@Nullable FileType fileType) {
    return fileType != null && fileType.equals(JavaScriptFileType.INSTANCE);
}
项目:needsmoredojo    文件:JumpToAttachPointAction.java   
@Override
public void update(AnActionEvent e)
{
    Editor editor = e.getData(PlatformDataKeys.EDITOR);

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

    PsiFile file = e.getData(LangDataKeys.PSI_FILE);

    if(file == null)
    {
        e.getPresentation().setEnabled(false);
        return;
    }

    if(!ServiceManager.getService(file.getProject(), DojoSettings.class).isNeedsMoreDojoEnabled())
    {
        e.getPresentation().setEnabled(false);
        return;
    }
    else
    {
        e.getPresentation().setEnabled(true);
    }

    e.getPresentation().setEnabled(true);

    if(!(file.getFileType() instanceof JavaScriptFileType))
    {
        e.getPresentation().setEnabled(false);
        return;
    }

    PsiElement element = file.findElementAt(editor.getCaretModel().getOffset());
    if(!AMDValidator.elementIsAttachPoint(element))
    {
        e.getPresentation().setEnabled(false);
    }
}
项目:needsmoredojo    文件:MockPsiFile.java   
@NotNull
@Override
public FileType getFileType() {
    return new JavaScriptFileType();
}
项目:consulo-javascript    文件:JavaScriptEditorsProvider.java   
@NotNull
@Override
public FileType getFileType()
{
    return JavaScriptFileType.INSTANCE;
}
项目:consulo-javascript    文件:JavaScriptFileTypeFactory.java   
@Override
public void createFileTypes(@NotNull FileTypeConsumer consumer)
{
    consumer.consume(JavaScriptFileType.INSTANCE);
}
项目:consulo-javascript    文件:JavaScriptCreateFileAction.java   
public JavaScriptCreateFileAction()
{
    super(null, null, JavaScriptFileType.INSTANCE.getIcon());
}
项目:consulo-javascript    文件:JavaScriptCreateFileAction.java   
@Nullable
@Override
protected FileType getFileTypeForModuleResolve()
{
    return JavaScriptFileType.INSTANCE;
}
项目:consulo-javascript    文件:JavaScriptIndentOptionsProvider.java   
@Override
public FileType getFileType()
{
    return JavaScriptFileType.INSTANCE;
}
项目:consulo-javascript    文件:JSCodeStylePanel.java   
@Override
@NotNull
protected FileType getFileType()
{
    return JavaScriptFileType.INSTANCE;
}
项目:consulo-javascript    文件:JavaScriptLanguage.java   
@Nullable
@Override
public LanguageFileType getAssociatedFileType()
{
    return JavaScriptFileType.INSTANCE;
}