Skip to content

Commit

Permalink
Use a default schema provider without path in case none is supplied
Browse files Browse the repository at this point in the history
Even though no search path is provided we need to decode the URL and see
if we can find the schema in the current workspace.

Also fixes an issue where schema can't be opened by double click on
linux.

Fix #890
  • Loading branch information
laeubi authored and iloveeclipse committed Nov 7, 2023
1 parent 1673161 commit 9d7b6a8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
package org.eclipse.pde.internal.core.schema;

import java.io.PrintWriter;
import java.util.Objects;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.pde.internal.core.PDECore;
Expand All @@ -24,6 +25,8 @@

public class SchemaInclude extends SchemaObject implements ISchemaInclude {

private static final PathSchemaProvider DEFAULT_SCHEMA_PROVIDER = new PathSchemaProvider(null);

private static final long serialVersionUID = 1L;

private String fLocation;
Expand Down Expand Up @@ -57,7 +60,7 @@ public SchemaInclude(ISchemaObject parent, String location, boolean abbreviated,
super(parent, location);
fLocation = location;
fAbbreviated = abbreviated;
this.schemaProvider = schemaProvider;
this.schemaProvider = Objects.requireNonNullElse(schemaProvider, DEFAULT_SCHEMA_PROVIDER);
}

/**
Expand Down Expand Up @@ -98,7 +101,7 @@ public ISchema getIncludedSchema() {
if (fAbbreviated) {
SchemaRegistry registry = PDECore.getDefault().getSchemaRegistry();
fIncludedSchema = registry.getIncludedSchema(descriptor, fLocation);
} else if (fIncludedSchema == null && schemaProvider != null) {
} else if (fIncludedSchema == null) {
fIncludedSchema = schemaProvider.createSchema(descriptor, fLocation);
}
return fIncludedSchema;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,17 @@ public static boolean openSchema(IFile file) {

public static boolean openSchema(IPath path) {
String pluginId = path.segment(0);
int remove;
if ("schema:".equals(pluginId)) { //$NON-NLS-1$
pluginId = path.segment(1);
remove = 2;
} else {
remove = 1;
}
IPluginModelBase model = PluginRegistry.findModel(pluginId);
if (model != null && model.getUnderlyingResource() != null) {
IProject project = model.getUnderlyingResource().getProject();
IFile file = project.getFile(path.removeFirstSegments(1));
IFile file = project.getFile(path.removeFirstSegments(remove));
return openSchema(file);
}
return false;
Expand Down

0 comments on commit 9d7b6a8

Please sign in to comment.