use of org.jetbrains.idea.maven.model.MavenId in project intellij-community by JetBrains.
the class MavenPropertyPsiReference method collectVariants.
protected void collectVariants(final List<Object> result, Set<String> variants) {
int prefixLength = 0;
if (myText.startsWith("pom.")) {
prefixLength = "pom.".length();
} else if (myText.startsWith("project.")) {
prefixLength = "project.".length();
}
MavenProject mavenProject = myMavenProject;
while (myText.startsWith("parent.", prefixLength)) {
MavenId parentId = mavenProject.getParentId();
if (parentId == null)
return;
mavenProject = myProjectsManager.findProject(parentId);
if (mavenProject == null)
return;
prefixLength += "parent.".length();
}
final String prefix = prefixLength == 0 ? null : myText.substring(0, prefixLength);
PsiDirectory baseDir = getBaseDir(mavenProject);
addVariant(result, "basedir", baseDir, prefix, MavenIcons.MavenLogo);
if (prefix == null) {
result.add(createLookupElement(baseDir, "project.baseUri", MavenIcons.MavenLogo));
result.add(createLookupElement(baseDir, "pom.baseUri", MavenIcons.MavenLogo));
result.add(LookupElementBuilder.create(TIMESTAMP_PROP).withIcon(MavenIcons.MavenLogo));
}
processSchema(MavenSchemaProvider.MAVEN_PROJECT_SCHEMA_URL, new SchemaProcessor<Object>() {
@Override
public Object process(@NotNull String property, XmlElementDescriptor descriptor) {
if (property.startsWith("project.")) {
addVariant(result, property.substring("project.".length()), descriptor, prefix, MavenIcons.MavenLogo);
}
return null;
}
});
processSchema(MavenSchemaProvider.MAVEN_SETTINGS_SCHEMA_URL, new SchemaProcessor<Object>() {
@Override
public Object process(@NotNull String property, XmlElementDescriptor descriptor) {
result.add(createLookupElement(descriptor, property, MavenIcons.MavenLogo));
return null;
}
});
collectPropertiesVariants(result, variants);
collectSystemEnvProperties(MavenPropertiesVirtualFileSystem.SYSTEM_PROPERTIES_FILE, null, result, variants);
collectSystemEnvProperties(MavenPropertiesVirtualFileSystem.ENV_PROPERTIES_FILE, "env.", result, variants);
MavenRunnerSettings runnerSettings = MavenRunner.getInstance(myProject).getSettings();
for (String prop : runnerSettings.getMavenProperties().keySet()) {
if (variants.add(prefix)) {
result.add(LookupElementBuilder.create(prop).withIcon(PlatformIcons.PROPERTY_ICON));
}
}
for (String prop : MavenUtil.getPropertiesFromMavenOpts().keySet()) {
if (variants.add(prop)) {
result.add(LookupElementBuilder.create(prop).withIcon(PlatformIcons.PROPERTY_ICON));
}
}
for (Object key : myMavenProject.getProperties().keySet()) {
if (key instanceof String) {
String property = (String) key;
if (variants.add(property)) {
result.add(LookupElementBuilder.create(property).withIcon(PlatformIcons.PROPERTY_ICON));
}
}
}
MavenDomConfiguration pluginCfg = DomUtil.findDomElement(myElement, MavenDomConfiguration.class);
if (pluginCfg != null) {
MavenPluginDescriptor.processDescriptors(descriptor -> {
if (descriptor.properties != null) {
for (MavenPluginDescriptor.ModelProperty property : descriptor.properties) {
if (property.insideConfigurationOnly) {
result.add(LookupElementBuilder.create(property.name).withIcon(PlatformIcons.PROPERTY_ICON));
}
}
}
return true;
}, pluginCfg);
}
}
use of org.jetbrains.idea.maven.model.MavenId in project intellij-community by JetBrains.
the class MavenDomProjectProcessorUtils method findParent.
@Nullable
public static MavenDomProjectModel findParent(@NotNull MavenDomParent mavenDomParent, Project project) {
if (!DomUtil.hasXml(mavenDomParent))
return null;
MavenId id = new MavenId(mavenDomParent.getGroupId().getStringValue(), mavenDomParent.getArtifactId().getStringValue(), mavenDomParent.getVersion().getStringValue());
MavenProject mavenProject = MavenProjectsManager.getInstance(project).findProject(id);
return mavenProject != null ? MavenDomUtil.getMavenDomProjectModel(project, mavenProject.getFile()) : null;
}
use of org.jetbrains.idea.maven.model.MavenId in project intellij-community by JetBrains.
the class MavenDomUtil method updateMavenParent.
public static MavenDomParent updateMavenParent(MavenDomProjectModel mavenModel, MavenProject parentProject) {
MavenDomParent result = mavenModel.getMavenParent();
VirtualFile pomFile = DomUtil.getFile(mavenModel).getVirtualFile();
Project project = mavenModel.getXmlElement().getProject();
MavenId parentId = parentProject.getMavenId();
result.getGroupId().setStringValue(parentId.getGroupId());
result.getArtifactId().setStringValue(parentId.getArtifactId());
result.getVersion().setStringValue(parentId.getVersion());
if (!Comparing.equal(pomFile.getParent().getParent(), parentProject.getDirectoryFile())) {
result.getRelativePath().setValue(PsiManager.getInstance(project).findFile(parentProject.getFile()));
}
return result;
}
use of org.jetbrains.idea.maven.model.MavenId in project intellij-community by JetBrains.
the class MavenArtifactCoordinatesConverter method getVariants.
@NotNull
public Collection<String> getVariants(ConvertContext context) {
MavenProjectIndicesManager manager = MavenProjectIndicesManager.getInstance(context.getProject());
MavenId id = MavenArtifactCoordinatesHelper.getId(context);
MavenDomShortArtifactCoordinates coordinates = MavenArtifactCoordinatesHelper.getCoordinates(context);
return selectStrategy(context).getVariants(id, manager, coordinates);
}
use of org.jetbrains.idea.maven.model.MavenId in project intellij-community by JetBrains.
the class MavenArtifactCoordinatesConverter method resolve.
@Override
public PsiElement resolve(String o, ConvertContext context) {
MavenId id = MavenArtifactCoordinatesHelper.getId(context);
PsiFile result = selectStrategy(context).resolve(id, context);
return result != null ? result : super.resolve(o, context);
}
Aggregations