Examples of JSClass


Examples of com.intellij.lang.javascript.psi.ecmal4.JSClass

{

    public static <K, V> Vector<UsageMapping> getMappingByClassAndFunctionProject(Project project, String classQName, String[] functionNames)
    {
        Vector<UsageMapping> fileToListOfMappings = new Vector<UsageMapping>();
        JSClass jsClass = (JSClass) JSResolveUtil.findClassByQName(classQName, GlobalSearchScope.allScope(project));

        if (jsClass != null)
        {
            for (String functionName : functionNames)
            {
                //Find the "mapView" function on IMediatorMap so we can find where it's used throughout the app
                JSFunction foundFunction = jsClass.findFunctionByName(functionName);

                if (foundFunction != null)
                {
                    //Find all the usages of "mapView" and return then as UsageInfo
                    List<UsageInfo2UsageAdapter> mapViewUsages = FindUsagesUtils.findUsagesOfPsiElement(foundFunction, project);
View Full Code Here

Examples of com.intellij.lang.javascript.psi.ecmal4.JSClass

            this.itemUnderMouse = itemUnderMouse;
        }

        public void run()
        {
            JSClass editorClass = JSPsiImplUtils.findClass((JSFile) targetFile);
            JSClass jsClass = (JSClass) itemUnderMouse;
            String nameOfInjectedClass = jsClass.getName();
            JSFile containingFile = (JSFile) jsClass.getContainingFile();
            String importStatement = "import " + JSPsiImplUtils.findPackageStatement(containingFile).getQualifiedName() + "." + jsClass.getName();
            PsiElement importLine = JSChangeUtil.createJSTreeFromText(project, importStatement, JavaScriptSupportLoader.ECMA_SCRIPT_L4).getPsi();
            editorClass.addBefore(importLine, editorClass.getFirstChild());

            String lowercaseNameOfClass = nameOfInjectedClass.substring(0, 1).toLowerCase() + nameOfInjectedClass.substring(1, nameOfInjectedClass.length());
View Full Code Here

Examples of com.intellij.lang.javascript.psi.ecmal4.JSClass

    {
        PsiFile psiFile = e.getData(DataKeys.PSI_FILE);
        if (psiFile instanceof JSFile)
        {
            JSFile jsFile = (JSFile) psiFile;
            JSClass jsClass = JSPsiImplUtils.findClass(jsFile);
            //Are there null object patterns in place, or just a lot of null checks when searching the psi?
            if (jsClass != null)
            {
                //What's the easiest way to check if the class "is a flash.display.DisplayObjectContainer"?
                if (isDisplayObjectContainer(jsClass))
                {
                    String className = jsClass.getName() + "Mediator.as";
                    PsiDirectory directory = jsFile.getContainingDirectory();

                    //This works, but throws "Assertion failed: Write access is allowed inside write-action only (see com.intellij.openapi.application.Application.runWriteAction()) "?
                    PsiFile file = directory.createFile(className);
                    //TODO: How do a I create a psi from scratch? Or should I just use a template?
View Full Code Here

Examples of com.intellij.lang.javascript.psi.ecmal4.JSClass

                        //todo: replace with different strategies depending on file type, e.g. XmlBackedJSClassImpl for MXML
                        if (targetFile instanceof JSFile)
                        {
                            //We need the psiFile to be able to access psi elements (constructor, methods, etc) and add/edit/update them
                            JSFile jsFile = (JSFile) targetFile;
                            final JSClass jsClass = JSPsiImplUtils.findClass(jsFile);


                            String relativePathFromRoot = getRelativePathFromSourceRoot(targetFile, psiFile, project);

                            //Because an image can start with a number (and a var can't), prepend the image name with "image_"
                            String statement = "[Embed(source=\"" + relativePathFromRoot + "\")]\npublic var image_" + psiFile.getName().replace(".jpg", "") + ":Class;";
                            ASTNode jsTreeFromText = JSChangeUtil.createJSTreeFromText(project, statement, JavaScriptSupportLoader.ECMA_SCRIPT_L4);

                            if (jsClass.getConstructor() != null)
                            {
                                jsClass.addBefore(jsTreeFromText.getPsi(), jsClass.getConstructor());
                            }
                            else
                            {
                                jsClass.add(jsTreeFromText.getPsi());
                            }
                        }
                    }

                }
View Full Code Here

Examples of com.intellij.lang.javascript.psi.ecmal4.JSClass

    private void goToFlexUnitTestOrCodeAction(AnActionEvent e){
        final Module module = e.getData(DataKeys.MODULE);
        project = e.getData(PlatformDataKeys.PROJECT);
        Editor editor = e.getData(PlatformDataKeys.EDITOR);

        JSClass jsClass = JSPsiImplUtils.findClass((JSFile) psiFile);
        final String packageName = JSResolveUtil.getPackageName(jsClass);

        final VirtualFile testFolder = getTestFolderFromCurrentModule(module);
        Runnable runnable = new Runnable(){
            public void run(){
View Full Code Here

Examples of com.intellij.lang.javascript.psi.ecmal4.JSClass

        PsiElement psiElement = generateHandlerFromParams(project, (JSFile) file, signalHandlerName, signalParams);
        moveCursorInsideMethod(editor, psiElement);
    }

    private PsiElement generateHandlerFromParams(Project project, JSFile file, String signalHandlerName, JSArgumentList signalParams){
        JSClass jsClass = JSPsiImplUtils.findClass(file);

        importClassesFromParameters(signalParams, jsClass);

        String result = SignalsUtils.buildParametersFromClassParameters(signalParams.getText());


        ASTNode jsTreeFromText = JSChangeUtil.createJSTreeFromText(project, "protected function " + signalHandlerName + result + ":void{" + "" + "\n}\n", JavaScriptSupportLoader.ECMA_SCRIPT_L4);

        final PsiElement functionElement = jsTreeFromText.getPsi();

        return jsClass.add(functionElement);
    }
View Full Code Here

Examples of com.intellij.lang.javascript.psi.ecmal4.JSClass

    private void buildMappingData(Project project, String className, String functionName)
    {
        PsiDocumentManager.getInstance(project).commitAllDocuments();

        //What's a better way to find a JSClass from a String? I want to find: org.robotlegs.core.IMediatorMap
        JSClass jsClass = (JSClass) JSResolveUtil.findElementsByName(className, project, GlobalSearchScope.allScope(project)).iterator().next();

        //Find the "mapView" function on IMediatorMap so we can find where it's used throughout the app
        JSFunction mapView = jsClass.findFunctionByName(functionName);

        //Find all the usages of "mapView" and return then as UsageInfo
        List<UsageInfo2UsageAdapter> mapViewUsages = findUsagesOfPsiElement(mapView, project);

        //Create a map of the first param (the "view") to the second param (the "mediator")
View Full Code Here

Examples of com.intellij.lang.javascript.psi.ecmal4.JSClass

            PsiElement context = mapViewUsage.getElement().getContext();

            //move to args: mediatorMap.mapView(View, Mediator) -> (View, Mediator)
            PsiElement[] children = context.getChildren()[1].getChildren();

            JSClass view = (JSClass) ((PsiReference) children[0]).resolve();
            JSClass mediator = (JSClass) ((PsiReference) children[1]).resolve();

            //map the view to the mediator
            HashMap<JSClass, JSClass> viewToMediatorMap = new HashMap<JSClass, JSClass>();
            viewToMediatorMap.put(view, mediator);
            viewMediatorMapList.add(viewToMediatorMap);
View Full Code Here

Examples of com.intellij.lang.javascript.psi.ecmal4.JSClass

        PsiElement psiElement = e.getData(LangDataKeys.PSI_ELEMENT);
        if (psiElement instanceof JSVariable)
        {
            JSVariable jsVariable = (JSVariable) psiElement;
            JSClass variableClass = jsVariable.getType().resolveClass();
            createMediatorFromClass(variableClass);
        }

        if (psiElement instanceof JSClass)
        {
            createMediatorFromClass((JSClass) psiElement);
        }

        if (psiElement instanceof JSFile)
        {
            JSClass psiClass = JSPsiImplUtils.findClass((JSFile) psiElement);
            createMediatorFromClass(psiClass);
        }

        if (psiElement != null)
        {
View Full Code Here

Examples of com.intellij.lang.javascript.psi.ecmal4.JSClass

    public void actionPerformed(AnActionEvent e)
    {
        final Project project = e.getData(LangDataKeys.PROJECT);
        PsiFile file = e.getData(LangDataKeys.PSI_FILE);

        final JSClass jsClass = getJSClassFromFile(file);

        if (jsClass != null)
        {
            for (final RobotlegsEnum classType : RobotlegsEnum.values())
            {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.