/** * @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)); } }
@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(); }
@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; }
@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; }
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()); } }); }
protected boolean isGraphQLRelatedFile(VirtualFile file) { if(file.getFileType() == JSGraphQLFileType.INSTANCE) { return true; } if(JavaScriptFileType.getFileTypesCompilableToJavaScript().contains(file.getFileType())) { return true; } return false; }
@NotNull @Override public FileBasedIndex.InputFilter getInputFilter() { return file -> { FileType fileType = file.getFileType(); return fileType == SmartyFileType.INSTANCE || fileType == JavaScriptFileType.INSTANCE || "ini".equalsIgnoreCase(file.getExtension()); }; }
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" ); } }
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" ); } }
public void testCompletionPrefixForSnippetNamespace() { String[] dataProvider = { "{s namespace='<caret>'}", "{s namespace=<caret>}", }; for (String s : dataProvider) { assertCompletionContains( JavaScriptFileType.INSTANCE, "var foo = {foo: \"" + s + "\"}", "foobar/widgets" ); } }
public void testCompletionPrefixForCommentNamespace() { assertCompletionContains( JavaScriptFileType.INSTANCE, "//{namespace name=<caret>}", "foobar/widgets" ); }
public void testSnippetsNavigation() { assertNavigationMatch( JavaScriptFileType.INSTANCE, "var foo = \"{s name='swag-last-registr<caret>ations/customer' namespace='foobar/widgets'}{/s}\"", PlatformPatterns.psiFile() ); }
public void testNamespaceAsCommentNavigation() { assertNavigationMatch( JavaScriptFileType.INSTANCE, "\n//{namespace name=foo<caret>bar/widgets}", PlatformPatterns.psiFile() ); }
/** * @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)); }
@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; }
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); }
@Override public void registerFileTypes(Consumer<FileType> consumer) { consumer.accept(DotNetModuleFileType.INSTANCE); consumer.accept(CSharpFileType.INSTANCE); consumer.accept(JavaScriptFileType.INSTANCE); }
@RequiredWriteAction @Override public PsiElement setName(@NonNls @NotNull String name) throws IncorrectOperationException { myFile.setName(name + "." + JavaScriptFileType.INSTANCE.getDefaultExtension()); return this; }
@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; }
@Override protected void buildDialog(Project project, PsiDirectory directory, CreateFileFromTemplateDialog.Builder builder) { builder.setTitle("Create JavaScript File"); builder.addKind("Empty File", JavaScriptFileType.INSTANCE.getIcon(), "JavaScriptFile"); }
@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); }
@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; }
@Override public boolean acceptFile(VirtualFile file) { return file.getFileType().equals(JavaScriptFileType.INSTANCE); }
private boolean isGraphQLInjectionRelatedFile(VirtualFile file) { return JavaScriptFileType.getFileTypesCompilableToJavaScript().contains(file.getFileType()); }
private static boolean isJavaScriptFile(PsiFile file, String ext) { return file instanceof JSFile && file.getFileType().equals(JavaScriptFileType.INSTANCE) || isInList(file.getName(), ext); }
public static boolean isJSFileType(@Nullable FileType fileType) { return fileType != null && fileType.equals(JavaScriptFileType.INSTANCE); }
@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); } }
@NotNull @Override public FileType getFileType() { return new JavaScriptFileType(); }
@NotNull @Override public FileType getFileType() { return JavaScriptFileType.INSTANCE; }
@Override public void createFileTypes(@NotNull FileTypeConsumer consumer) { consumer.consume(JavaScriptFileType.INSTANCE); }
public JavaScriptCreateFileAction() { super(null, null, JavaScriptFileType.INSTANCE.getIcon()); }
@Nullable @Override protected FileType getFileTypeForModuleResolve() { return JavaScriptFileType.INSTANCE; }
@Override public FileType getFileType() { return JavaScriptFileType.INSTANCE; }
@Override @NotNull protected FileType getFileType() { return JavaScriptFileType.INSTANCE; }
@Nullable @Override public LanguageFileType getAssociatedFileType() { return JavaScriptFileType.INSTANCE; }