Permalink
Browse files

added option for loading hintPath tag

  • Loading branch information...
VISTALL committed Jan 29, 2018
1 parent 482d6dd commit b3070b186397d28b3c9c8216a267baad483113a3
@@ -27,6 +27,7 @@
import org.jetbrains.annotations.Nullable;
import com.intellij.openapi.extensions.ExtensionPointName;
import com.intellij.openapi.util.NotNullLazyValue;
import com.intellij.openapi.vfs.VirtualFile;
import consulo.msbuild.dom.Project;
import consulo.msbuild.importProvider.MSBuildModuleImportContext;
import consulo.msbuild.importProvider.item.MSBuildImportProject;
@@ -84,7 +85,10 @@ static MSBuildProjectType getProjectType(@NotNull String guid)
return ourExtensionsValue.getValue();
}

void setupModule(@NotNull Project domProject, @Nullable MSBuildSolutionManager.ProjectOptions projectOptions, @NotNull ModifiableModuleRootLayer modifiableRootModel);
void setupModule(@NotNull VirtualFile projectFile,
@NotNull Project domProject,
@Nullable MSBuildSolutionManager.ProjectOptions projectOptions,
@NotNull ModifiableModuleRootLayer modifiableRootModel);

@NotNull
MSBuildImportProject createImportItem(SlnProject project, MSBuildModuleImportContext context);
@@ -4,7 +4,6 @@
package consulo.msbuild.dom;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import com.intellij.util.xml.DomElement;
import com.intellij.util.xml.GenericAttributeValue;
import com.intellij.util.xml.NameStrategy;
@@ -61,6 +60,6 @@
@NotNull
GenericAttributeValue<String> getCondition();

@Nullable
@NotNull
ReferenceHintPath getHintPath();
}
@@ -16,17 +16,17 @@

package consulo.msbuild.dom;

import com.intellij.openapi.paths.PathReference;
import com.intellij.util.xml.Convert;
import org.jetbrains.annotations.Nullable;
import com.intellij.util.xml.DomElement;
import com.intellij.util.xml.converters.PathReferenceConverter;
import com.intellij.util.xml.TagValue;

/**
* @author VISTALL
* @since 28-Jan-17
*/
public interface ReferenceHintPath extends DomElement
{
@Convert(PathReferenceConverter.class)
PathReference getValue();
@TagValue
@Nullable
String getValue();
}
@@ -16,6 +16,8 @@

package consulo.msbuild.impl;

import java.io.File;
import java.io.IOException;
import java.util.Comparator;
import java.util.List;

@@ -25,10 +27,17 @@
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.projectRoots.SdkTable;
import com.intellij.openapi.projectRoots.SdkType;
import com.intellij.openapi.roots.libraries.Library;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.VirtualFileManager;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.io.URLUtil;
import consulo.dotnet.dll.DotNetModuleFileType;
import consulo.dotnet.roots.orderEntry.DotNetLibraryOrderEntryImpl;
import consulo.module.extension.MutableModuleInheritableNamedPointer;
import consulo.msbuild.MSBuildProjectType;
@@ -48,6 +57,7 @@
import consulo.msbuild.solution.reader.SlnProject;
import consulo.roots.ModifiableModuleRootLayer;
import consulo.roots.impl.ModuleRootLayerImpl;
import consulo.roots.types.BinariesOrderRootType;

/**
* @author VISTALL
@@ -76,7 +86,7 @@ private static MSBuildDotNetImportTarget findTarget(@Nullable MSBuildSolutionMan
}

@Override
public final void setupModule(@NotNull Project domProject, @Nullable MSBuildSolutionManager.ProjectOptions projectOptions, @NotNull ModifiableModuleRootLayer rootLayer)
public final void setupModule(@NotNull VirtualFile projectFile, @NotNull Project domProject, @Nullable MSBuildSolutionManager.ProjectOptions projectOptions, @NotNull ModifiableModuleRootLayer rootLayer)
{
// setup .NET extension
MSBuildMutableDotNetModuleExtension moduleExtension = rootLayer.getExtensionWithoutCheck(MSBuildMutableDotNetModuleExtension.class);
@@ -130,10 +140,38 @@ public final void setupModule(@NotNull Project domProject, @Nullable MSBuildSolu
List<Reference> references = itemGroup.getReferences();
for(Reference reference : references)
{
String stringValue = reference.getInclude().getStringValue();
if(stringValue != null)
String hintPath = reference.getHintPath().getValue();
if(hintPath != null)
{
rootLayer.addOrderEntry(new DotNetLibraryOrderEntryImpl((ModuleRootLayerImpl) rootLayer, stringValue));
File file = new File(hintPath);
if(!file.isAbsolute())
{
file = new File(VfsUtil.virtualToIoFile(projectFile.getParent()), FileUtil.toSystemIndependentName(hintPath));
}

String fullPath = file.getPath();
try
{
fullPath = file.getCanonicalPath();
}
catch(IOException ignored)
{
}

String url = VirtualFileManager.constructUrl(DotNetModuleFileType.PROTOCOL, FileUtil.toSystemIndependentName(fullPath)) + URLUtil.ARCHIVE_SEPARATOR;

Library library = rootLayer.getModuleLibraryTable().createLibrary(file.getName());
Library.ModifiableModel modifiableModel = library.getModifiableModel();
modifiableModel.addRoot(url, BinariesOrderRootType.getInstance());
modifiableModel.commit();
}
else
{
String includeName = reference.getInclude().getStringValue();
if(includeName != null)
{
rootLayer.addOrderEntry(new DotNetLibraryOrderEntryImpl((ModuleRootLayerImpl) rootLayer, includeName));
}
}
}

@@ -93,7 +93,7 @@ public void runActivity(@NotNull UIAccess uiAccess, @NotNull Project project)
MSBuildProjectType projectType = MSBuildProjectType.getProjectType(wProject.getTypeGUID());
if(projectType != null)
{
projectType.setupModule(domProject, projectOptions, (ModifiableModuleRootLayer) modifiableRootModel.getCurrentLayer());
projectType.setupModule(projectFile, domProject, projectOptions, (ModifiableModuleRootLayer) modifiableRootModel.getCurrentLayer());
}

SolutionVirtualDirectory directory = ReadAction.compute(() -> SolutionVirtualBuilder.build(domProject, projectFile.getParent()));

0 comments on commit b3070b1

Please sign in to comment.