Search in sources :

Example 6 with CfmlMappingsConfig

use of com.intellij.coldFusion.UI.config.CfmlMappingsConfig in project intellij-plugins by JetBrains.

the class CfmlCompletionTest method testAutocompletePathToScriptIncludeInPresentOfMappingWithFile.

public void testAutocompletePathToScriptIncludeInPresentOfMappingWithFile() throws Throwable {
    addOneComponentToDir(myFixture);
    Map<String, String> mappings = new HashMap<>();
    for (VirtualFile root : ProjectRootManager.getInstance(getProject()).getContentRoots()) {
        String directoryName = root.getPresentableUrl() + "/subfolder";
        VirtualFile fileByUrl = LocalFileSystem.getInstance().findFileByPath(directoryName);
        if (fileByUrl != null) {
            mappings.put("/subfolder", directoryName);
        }
    }
    CfmlProjectConfiguration.State defaultState = CfmlProjectConfiguration.getInstance(getProject()).getState();
    CfmlProjectConfiguration.State state = new CfmlProjectConfiguration.State(new CfmlMappingsConfig(mappings));
    try {
        CfmlProjectConfiguration.getInstance(getProject()).loadState(state);
        doTestCompletionVariants("ComponentName.cfc");
    } finally {
        CfmlProjectConfiguration.getInstance(getProject()).loadState(defaultState);
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) CfmlMappingsConfig(com.intellij.coldFusion.UI.config.CfmlMappingsConfig) HashMap(java.util.HashMap) CfmlProjectConfiguration(com.intellij.coldFusion.UI.config.CfmlProjectConfiguration)

Example 7 with CfmlMappingsConfig

use of com.intellij.coldFusion.UI.config.CfmlMappingsConfig in project intellij-plugins by JetBrains.

the class CfmlCompletionTest method testAutocompletePathToIncludeTagInPresentOfMapping.

public void testAutocompletePathToIncludeTagInPresentOfMapping() throws Throwable {
    addOneComponentTo(myFixture);
    Map<String, String> mappings = new HashMap<>();
    for (VirtualFile root : ProjectRootManager.getInstance(getProject()).getContentRoots()) {
        String directoryName = root.getPresentableUrl() + "/folder/subfolder";
        VirtualFile fileByUrl = LocalFileSystem.getInstance().findFileByPath(directoryName);
        if (fileByUrl != null) {
            mappings.put("/myfolder/subfolder", directoryName);
        }
    }
    CfmlProjectConfiguration.State defaultState = CfmlProjectConfiguration.getInstance(getProject()).getState();
    CfmlProjectConfiguration.State state = new CfmlProjectConfiguration.State(new CfmlMappingsConfig(mappings));
    try {
        CfmlProjectConfiguration.getInstance(getProject()).loadState(state);
        doTest();
    } finally {
        CfmlProjectConfiguration.getInstance(getProject()).loadState(defaultState);
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) CfmlMappingsConfig(com.intellij.coldFusion.UI.config.CfmlMappingsConfig) HashMap(java.util.HashMap) CfmlProjectConfiguration(com.intellij.coldFusion.UI.config.CfmlProjectConfiguration)

Example 8 with CfmlMappingsConfig

use of com.intellij.coldFusion.UI.config.CfmlMappingsConfig in project intellij-plugins by JetBrains.

the class CfmlFileReferenceSet method computeDefaultContexts.

@NotNull
@Override
public Collection<PsiFileSystemItem> computeDefaultContexts() {
    ArrayList<PsiFileSystemItem> contexts = new ArrayList<>();
    if (StringUtil.startsWithChar(getPathString(), '/') || StringUtil.startsWithChar(getPathString(), '\\')) {
        PsiReference firstFileReference = getElement().getReferences()[0];
        if ((firstFileReference instanceof FileReference)) {
            CfmlProjectConfiguration.State state = CfmlProjectConfiguration.getInstance(getElement().getProject()).getState();
            if (state == null) {
                return super.computeDefaultContexts();
            }
            CfmlMappingsConfig mappingsConfig = state.getMapps();
            Map<String, String> mapDir = mappingsConfig.getServerMappings();
            for (String value : mapDir.keySet()) {
                final String path = mapDir.get(value);
                VirtualFile dir = findFile(path);
                if (dir != null) {
                    PsiDirectory psiDirectory = getElement().getManager().findDirectory(dir);
                    contexts.add(psiDirectory);
                }
            }
        }
    }
    contexts.addAll(super.computeDefaultContexts());
    return contexts;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) CfmlMappingsConfig(com.intellij.coldFusion.UI.config.CfmlMappingsConfig) CfmlProjectConfiguration(com.intellij.coldFusion.UI.config.CfmlProjectConfiguration) FileReference(com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReference) NotNull(org.jetbrains.annotations.NotNull)

Example 9 with CfmlMappingsConfig

use of com.intellij.coldFusion.UI.config.CfmlMappingsConfig in project intellij-plugins by JetBrains.

the class CfmlCompletionTest method testAutocompletePathToComponentInPresentOfMapping.

public void testAutocompletePathToComponentInPresentOfMapping() throws Throwable {
    addOneComponentTo(myFixture);
    Map<String, String> mappings = new HashMap<>();
    for (VirtualFile root : ProjectRootManager.getInstance(getProject()).getContentRoots()) {
        String directoryName = root.getPresentableUrl() + "/folder/subfolder";
        VirtualFile fileByUrl = LocalFileSystem.getInstance().findFileByPath(directoryName);
        if (fileByUrl != null) {
            mappings.put("/myfolder/subfolder", directoryName);
        }
    }
    CfmlProjectConfiguration.State defaultState = CfmlProjectConfiguration.getInstance(getProject()).getState();
    CfmlProjectConfiguration.State state = new CfmlProjectConfiguration.State(new CfmlMappingsConfig(mappings));
    try {
        CfmlProjectConfiguration.getInstance(getProject()).loadState(state);
        doTest();
    } finally {
        CfmlProjectConfiguration.getInstance(getProject()).loadState(defaultState);
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) CfmlMappingsConfig(com.intellij.coldFusion.UI.config.CfmlMappingsConfig) HashMap(java.util.HashMap) CfmlProjectConfiguration(com.intellij.coldFusion.UI.config.CfmlProjectConfiguration)

Example 10 with CfmlMappingsConfig

use of com.intellij.coldFusion.UI.config.CfmlMappingsConfig in project intellij-plugins by JetBrains.

the class CfmlCompletionTest method testAutocompletePathToScriptIncludeInPresentOfMappingWithEnteredPath.

public void testAutocompletePathToScriptIncludeInPresentOfMappingWithEnteredPath() throws Throwable {
    addOneComponentToDir(myFixture);
    Map<String, String> mappings = new HashMap<>();
    for (VirtualFile root : ProjectRootManager.getInstance(getProject()).getContentRoots()) {
        String directoryName = root.getPresentableUrl() + "/subfolder";
        VirtualFile fileByUrl = LocalFileSystem.getInstance().findFileByPath(directoryName);
        if (fileByUrl != null) {
            mappings.put("/lot", directoryName);
            mappings.put("/fot", directoryName);
        }
    }
    CfmlProjectConfiguration.State defaultState = CfmlProjectConfiguration.getInstance(getProject()).getState();
    CfmlProjectConfiguration.State state = new CfmlProjectConfiguration.State(new CfmlMappingsConfig());
    state.setMapps(new CfmlMappingsConfig(mappings));
    try {
        CfmlProjectConfiguration.getInstance(getProject()).loadState(state);
        doTestCompletionContainsVariants("lot", "fot");
    } finally {
        CfmlProjectConfiguration.getInstance(getProject()).loadState(defaultState);
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) CfmlMappingsConfig(com.intellij.coldFusion.UI.config.CfmlMappingsConfig) HashMap(java.util.HashMap) CfmlProjectConfiguration(com.intellij.coldFusion.UI.config.CfmlProjectConfiguration)

Aggregations

CfmlMappingsConfig (com.intellij.coldFusion.UI.config.CfmlMappingsConfig)13 CfmlProjectConfiguration (com.intellij.coldFusion.UI.config.CfmlProjectConfiguration)13 VirtualFile (com.intellij.openapi.vfs.VirtualFile)13 HashMap (java.util.HashMap)10 CfmlFile (com.intellij.coldFusion.model.files.CfmlFile)2 NotNull (org.jetbrains.annotations.NotNull)2 InsertHandler (com.intellij.codeInsight.completion.InsertHandler)1 InsertionContext (com.intellij.codeInsight.completion.InsertionContext)1 LookupElement (com.intellij.codeInsight.lookup.LookupElement)1 Document (com.intellij.openapi.editor.Document)1 Project (com.intellij.openapi.project.Project)1 FileReference (com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReference)1 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)1 THashSet (gnu.trove.THashSet)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1