Package com.intellij.psi.impl

Examples of com.intellij.psi.impl.PsiElementFactoryImpl


            String relativePathToContainingFile = FileUtil.getRelativePath(pathToContainingFile, newFilePath, File.separatorChar);
            if (null == relativePathToContainingFile) {
                return null;
            }

            PsiElementFactory factory = new PsiElementFactoryImpl(getManager());
            /*
            // The parser has a problem with parsing just simple string literals in that they don't fall into any of the
            // element patterns it expects.  With no context, the string literal falls through to an error handler and
            // gets marked with an error annotation.
            // To make a long story short, it's easier "for now" to construct a full import statement and replace the
            // import declaration element than to fix the parser.
            // - TC
            PsiElement newEl = factory.createDummyHolder(("\"" + relativePathToContainingFile + "\""), elementType, getContext());
            return this.replace(newEl);
            */

            PsiElement newEl = factory.createDummyHolder(("import \"" + relativePathToContainingFile + "\";"), PbElementTypes.IMPORT_DECL, getContext());
            newEl = newEl.getFirstChild(); // The first child of the dummy holder is the element we need.
            PsiElement newImportEl = this.getParent().replace(newEl);
            PsiElement newImportRefEl = newImportEl.getFirstChild();
            return newImportRefEl;
        }
View Full Code Here

TOP

Related Classes of com.intellij.psi.impl.PsiElementFactoryImpl

Copyright © 2018 www.massapicom. 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.