com.intellij.lang.javascript.JavaScriptFileType Java Examples

The following examples show how to use com.intellij.lang.javascript.JavaScriptFileType. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Unity3dProjectImportUtil.java    From consulo-unity3d with Apache License 2.0 6 votes vote down vote up
private static Module createAssemblyUnityScriptModuleFirstPass(Project project,
															   ModifiableModuleModel newModel,
															   Sdk unityBundle,
															   MultiMap<Module, VirtualFile> virtualFilesByModule,
															   ProgressIndicator progressIndicator,
															   UnityProjectImportContext context)
{
	if(isVersionHigherOrEqual(unityBundle, "2018.2"))
	{
		Module module = newModel.findModuleByName(ASSEMBLY_UNITYSCRIPT_FIRSTPASS);
		if(module != null)
		{
			newModel.disposeModule(module);
		}
		return null;
	}
	else
	{
		return createAndSetupModule(ASSEMBLY_UNITYSCRIPT_FIRSTPASS, project, newModel, FIRST_PASS_PATHS, unityBundle, null, "unity3d-unityscript-child", JavaScriptFileType.INSTANCE,
				virtualFilesByModule, progressIndicator, context);
	}
}
 
Example #2
Source File: ExtJsUtilTest.java    From idea-php-shopware-plugin with MIT License 6 votes vote down vote up
/**
 * @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));
    }
}
 
Example #3
Source File: SnippetIndex.java    From idea-php-shopware-plugin with MIT License 5 votes vote down vote up
@NotNull
@Override
public FileBasedIndex.InputFilter getInputFilter() {
    return file -> {
        FileType fileType = file.getFileType();
        return fileType == SmartyFileType.INSTANCE || fileType == JavaScriptFileType.INSTANCE || "ini".equalsIgnoreCase(file.getExtension());
    };
}
 
Example #4
Source File: UnityScriptDotNetTypeDeclaration.java    From consulo-unity3d with Apache License 2.0 5 votes vote down vote up
@RequiredWriteAction
@Override
public PsiElement setName(@NonNls @Nonnull String name) throws IncorrectOperationException
{
	myFile.setName(name + "." + JavaScriptFileType.INSTANCE.getDefaultExtension());
	return this;
}
 
Example #5
Source File: UnityScriptFileProjectViewProvider.java    From consulo-unity3d with Apache License 2.0 5 votes vote down vote up
@RequiredReadAction
@Nonnull
private Collection<AbstractTreeNode> doModify(Collection<AbstractTreeNode> children, ViewSettings settings)
{
	Unity3dRootModuleExtension rootModuleExtension = Unity3dModuleExtensionUtil.getRootModuleExtension(myProject);
	if(rootModuleExtension == null)
	{
		return children;
	}

	List<AbstractTreeNode> nodes = new ArrayList<>(children.size());
	for(AbstractTreeNode child : children)
	{
		ProgressManager.checkCanceled();

		Object value = child.getValue();
		if(value instanceof JSFile && ((JSFile) value).getFileType() == JavaScriptFileType.INSTANCE)
		{
			Module moduleForPsiElement = ModuleUtilCore.findModuleForPsiElement((PsiElement) value);
			if(moduleForPsiElement != null)
			{
				nodes.add(new UnityScriptFileNode(myProject, (PsiFile) value, settings));
				continue;
			}
		}
		nodes.add(child);
	}
	return nodes;
}
 
Example #6
Source File: DefaultUnity3dProjectSourceFileTypeFactory.java    From consulo-unity3d with Apache License 2.0 5 votes vote down vote up
@Override
public void registerFileTypes(Consumer<FileType> consumer)
{
	consumer.accept(DotNetModuleFileType.INSTANCE);
	consumer.accept(CSharpFileType.INSTANCE);
	consumer.accept(JavaScriptFileType.INSTANCE);
}
 
Example #7
Source File: Unity3dModuleResolver.java    From consulo-unity3d with Apache License 2.0 5 votes vote down vote up
@Nullable
@RequiredReadAction
public Module resolveModuleImpl(@Nonnull PsiDirectory psiDirectory, @Nonnull FileType fileType)
{
	if(fileType == CSharpFileType.INSTANCE)
	{
		return findModule(psiDirectory, "CSharp");
	}
	else if(fileType == JavaScriptFileType.INSTANCE)
	{
		return findModule(psiDirectory, "UnityScript");
	}
	return null;
}
 
Example #8
Source File: ExtJsUtilTest.java    From idea-php-shopware-plugin with MIT License 5 votes vote down vote up
/**
 * @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));
}
 
Example #9
Source File: ExtJsGoToDeclarationHandlerTest.java    From idea-php-shopware-plugin with MIT License 5 votes vote down vote up
public void testNamespaceAsCommentNavigation() {
    assertNavigationMatch(
        JavaScriptFileType.INSTANCE,
        "\n//{namespace name=foo<caret>bar/widgets}",
        PlatformPatterns.psiFile()
    );
}
 
Example #10
Source File: ExtJsGoToDeclarationHandlerTest.java    From idea-php-shopware-plugin with MIT License 5 votes vote down vote up
public void testSnippetsNavigation() {
    assertNavigationMatch(
        JavaScriptFileType.INSTANCE,
        "var foo = \"{s name='swag-last-registr<caret>ations/customer' namespace='foobar/widgets'}{/s}\"",
        PlatformPatterns.psiFile()
    );
}
 
Example #11
Source File: ShopwareJavaScriptCompletionTest.java    From idea-php-shopware-plugin with MIT License 5 votes vote down vote up
public void testCompletionPrefixForCommentNamespace() {
    assertCompletionContains(
        JavaScriptFileType.INSTANCE,
        "//{namespace name=<caret>}",
        "foobar/widgets"
    );
}
 
Example #12
Source File: ShopwareJavaScriptCompletionTest.java    From idea-php-shopware-plugin with MIT License 5 votes vote down vote up
public void testCompletionPrefixForSnippetNamespace() {
    String[] dataProvider = {
        "{s namespace='<caret>'}",
        "{s namespace=<caret>}",
    };

    for (String s : dataProvider) {
        assertCompletionContains(
            JavaScriptFileType.INSTANCE,
            "var foo = {foo: \"" + s + "\"}",
            "foobar/widgets"
        );
    }
}
 
Example #13
Source File: ShopwareJavaScriptCompletionTest.java    From idea-php-shopware-plugin with MIT License 5 votes vote down vote up
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"
        );
    }
}
 
Example #14
Source File: ShopwareJavaScriptCompletionTest.java    From idea-php-shopware-plugin with MIT License 5 votes vote down vote up
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"
        );
    }
}
 
Example #15
Source File: JsEnvironmentVariablesUsagesProvider.java    From idea-php-dotenv-plugin with MIT License 4 votes vote down vote up
@Override
public boolean acceptFile(VirtualFile file) {
    return (file.getFileType().equals(JavaScriptFileType.INSTANCE) || file.getFileType().equals(TypeScriptFileType.INSTANCE))
            && !file.getPath().contains("/node_modules/");
}
 
Example #16
Source File: ESLintExternalAnnotator.java    From eslint-plugin with MIT License 4 votes vote down vote up
private static boolean isJavaScriptFile(PsiFile file, String ext) {
    return file instanceof JSFile && file.getFileType().equals(JavaScriptFileType.INSTANCE) || (!StringUtils.isEmpty(ext) && isInList(file.getName(), ext));
}
 
Example #17
Source File: JumpToAttachPointAction.java    From needsmoredojo with Apache License 2.0 4 votes vote down vote up
@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);
    }
}
 
Example #18
Source File: MockPsiFile.java    From needsmoredojo with Apache License 2.0 4 votes vote down vote up
@NotNull
@Override
public FileType getFileType() {
    return new JavaScriptFileType();
}