// Path: src/cmake/filetypes/CMakeFile.java
// public class CMakeFile extends PsiFileBase{
//     public static CMakeFile create(@NotNull FileViewProvider viewProvider) {
//         return new CMakeFile(viewProvider);
//     }
//     protected CMakeFile(@NotNull FileViewProvider viewProvider) {
//         super(viewProvider, CMakeLanguage.INSTANCE);
//     }
// 
//     @NotNull
//     @Override
//     public FileType getFileType() {
//         return CMakeFileType.INSTANCE;
//     }
// 
//     @Override
//     public String toString() {
//         return "CMake";
//     }
// 
//     @Override
//     public Icon getIcon(int flags) {
//         return super.getIcon(flags);
//     }
// }
// 
// Path: src/cmake/filetypes/CMakeFileType.java
// public class CMakeFileType extends LanguageFileType {
//     public static final CMakeFileType INSTANCE = new CMakeFileType();
//     private static final String[] DEFAULT_EXTENSIONS = {"cmake","txt"};
// 
//     protected CMakeFileType() {
//         super(CMakeLanguage.INSTANCE);
//     }
// 
//     @NotNull
//     @Override
//     public String getName() {
//         return "CMake";
//     }
// 
//     @NotNull
//     @Override
//     public String getDescription() {
//         return "CMake build system file";
//     }
// 
//     @NotNull
//     @Override
//     public String getDefaultExtension() {
//         return DEFAULT_EXTENSIONS[0];
//     }
// 
//     @Nullable
//     @Override
//     public Icon getIcon() {
//         return CMakeIcons.FILE;
//     }
// 
//     @Override
//     public boolean isReadOnly() {
//         return false;
//     }
// 
//     @Nullable
//     @Override
//     public String getCharset(@NotNull VirtualFile virtualFile, @NotNull byte[] bytes) {
//         Charset charset = EncodingRegistry.getInstance().getDefaultCharsetForPropertiesFiles(virtualFile);
//         if (charset == null) {
//             charset = CharsetToolkit.getDefaultSystemCharset();
//         }
//         return charset.name();
//     }
// }
// 
// Path: src/cmake/icons/CMakeIcons.java
// public class CMakeIcons {
//     public static final Icon FILE = IconLoader.getIcon("/icons/cmake.png");
//     public static final Icon MACRO = IconLoader.getIcon("/icons/hashtag.png");
//     public static final Icon FUN = IconLoader.getIcon("/icons/fun.jpg");
//     public static final Icon LOOP = IconLoader.getIcon("/icons/loop.png");
// }


import cmake.filetypes.CMakeFile;
import cmake.filetypes.CMakeFileType;
import cmake.icons.CMakeIcons;
import cmake.psi.*;
import com.intellij.lang.ASTNode;
import com.intellij.navigation.ItemPresentation;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFileFactory;
import com.intellij.psi.PsiManager;
import com.intellij.psi.PsiRecursiveElementWalkingVisitor;
import com.intellij.psi.search.FileTypeIndex;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.PairProcessor;
import com.intellij.util.indexing.FileBasedIndex;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
package cmake.parsing;



/**
 * Created by alex on 1/6/15.
 */
public class CMakeParserUtilImpl {
    public static String getName(CMakeCommandName element) {
        return element.getText();
    }

    public static PsiElement setName(CMakeCommandName element, String newName) {
        ASTNode commandNameNode = element.getFirstChild().getNode();
// FIXME: node replacement
//        if (commandNameNode != null) {
//            CMakeCommandName newNode = CMakeTypes.Factory.createElement(new CMakeN)
//            ASTNode newKeyNode = property.getFirstChild().getNode();
//            element.getNode().replaceChild(commandNameNode, newKeyNode);
//        }
        return element;
    }

    public static class CMakeNamedElementFactory {
//        public static CMake createElement(Project project, String name) {
//            final CMakeFile file = createFile(project, name);
        // TODO: use tree walker to get command name in AST
//            return (SimpleProperty) file.getFirstChild();
//        }

// Path: src/cmake/filetypes/CMakeFile.java
// public class CMakeFile extends PsiFileBase{
//     public static CMakeFile create(@NotNull FileViewProvider viewProvider) {
//         return new CMakeFile(viewProvider);
//     }
//     protected CMakeFile(@NotNull FileViewProvider viewProvider) {
//         super(viewProvider, CMakeLanguage.INSTANCE);
//     }
// 
//     @NotNull
//     @Override
//     public FileType getFileType() {
//         return CMakeFileType.INSTANCE;
//     }
// 
//     @Override
//     public String toString() {
//         return "CMake";
//     }
// 
//     @Override
//     public Icon getIcon(int flags) {
//         return super.getIcon(flags);
//     }
// }
// 
// Path: src/cmake/filetypes/CMakeFileType.java
// public class CMakeFileType extends LanguageFileType {
//     public static final CMakeFileType INSTANCE = new CMakeFileType();
//     private static final String[] DEFAULT_EXTENSIONS = {"cmake","txt"};
// 
//     protected CMakeFileType() {
//         super(CMakeLanguage.INSTANCE);
//     }
// 
//     @NotNull
//     @Override
//     public String getName() {
//         return "CMake";
//     }
// 
//     @NotNull
//     @Override
//     public String getDescription() {
//         return "CMake build system file";
//     }
// 
//     @NotNull
//     @Override
//     public String getDefaultExtension() {
//         return DEFAULT_EXTENSIONS[0];
//     }
// 
//     @Nullable
//     @Override
//     public Icon getIcon() {
//         return CMakeIcons.FILE;
//     }
// 
//     @Override
//     public boolean isReadOnly() {
//         return false;
//     }
// 
//     @Nullable
//     @Override
//     public String getCharset(@NotNull VirtualFile virtualFile, @NotNull byte[] bytes) {
//         Charset charset = EncodingRegistry.getInstance().getDefaultCharsetForPropertiesFiles(virtualFile);
//         if (charset == null) {
//             charset = CharsetToolkit.getDefaultSystemCharset();
//         }
//         return charset.name();
//     }
// }
// 
// Path: src/cmake/icons/CMakeIcons.java
// public class CMakeIcons {
//     public static final Icon FILE = IconLoader.getIcon("/icons/cmake.png");
//     public static final Icon MACRO = IconLoader.getIcon("/icons/hashtag.png");
//     public static final Icon FUN = IconLoader.getIcon("/icons/fun.jpg");
//     public static final Icon LOOP = IconLoader.getIcon("/icons/loop.png");
// }


// Path: src/cmake/parsing/CMakeParserUtilImpl.java
import cmake.filetypes.CMakeFile;
import cmake.filetypes.CMakeFileType;
import cmake.icons.CMakeIcons;
import cmake.psi.*;
import com.intellij.lang.ASTNode;
import com.intellij.navigation.ItemPresentation;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFileFactory;
import com.intellij.psi.PsiManager;
import com.intellij.psi.PsiRecursiveElementWalkingVisitor;
import com.intellij.psi.search.FileTypeIndex;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.PairProcessor;
import com.intellij.util.indexing.FileBasedIndex;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

package cmake.parsing;



/**
 * Created by alex on 1/6/15.
 */
public class CMakeParserUtilImpl {
    public static String getName(CMakeCommandName element) {
        return element.getText();
    }

    public static PsiElement setName(CMakeCommandName element, String newName) {
        ASTNode commandNameNode = element.getFirstChild().getNode();
// FIXME: node replacement
//        if (commandNameNode != null) {
//            CMakeCommandName newNode = CMakeTypes.Factory.createElement(new CMakeN)
//            ASTNode newKeyNode = property.getFirstChild().getNode();
//            element.getNode().replaceChild(commandNameNode, newKeyNode);
//        }
        return element;
    }

    public static class CMakeNamedElementFactory {
//        public static CMake createElement(Project project, String name) {
//            final CMakeFile file = createFile(project, name);
        // TODO: use tree walker to get command name in AST
//            return (SimpleProperty) file.getFirstChild();
//        }

        public static CMakeFile createFile(Project project, String text) {