Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding support for folder attribute in example project environment. #92

Merged
merged 3 commits into from
Dec 2, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions com.arm.cmsis.pack.data/src/com/arm/cmsis/pack/data/CpExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,22 @@ public String getBoardId() {

@Override
public String getLoadPath(String environmentName) {
if(environmentName == null)
return getEnvironmentAttribute(environmentName, CmsisConstants.LOAD);
}

@Override
public String getProjectFolder(String environmentName) {
return getEnvironmentAttribute(environmentName, CmsisConstants.FOLDER);
}

private String getEnvironmentAttribute(String environmentName, String attributeName) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please change visibility to protected and add a comment. CpItem-based classes should be kept open for extension.

if (environmentName == null)
return null;
Collection<? extends ICpItem> environments = getGrandChildren(CmsisConstants.PROJECT_TAG);
if (environments != null) {
for (ICpItem environment : environments) {
if (environment.getName().equals(environmentName)){
return environment.getAttribute(CmsisConstants.LOAD);
if (environment.getName().equals(environmentName)) {
return environment.getAttribute(attributeName);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,11 @@ public interface ICpExample extends ICpItem {
* @return true if contains board
*/
boolean containsBoard(String boardId);

/**
* Gets the folder attribute stored in the environment tag.
* @return folder in the project, or null of it does not exist.
*/
String getProjectFolder(String environmentName);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interface change: requires default implementation


}
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,19 @@ default String getEnvironment(ICpExample example) {
return null;
return getName();
}

/**
* Gets the project folder, i.e., the folder attribute listed in the environment tag.
* @param example ICpExample to get the environment folder from.
* @return the project relative path to the folder listed in the environment,
* <code>null</code> if not supported.
*/
default String getProjectFolder(ICpExample example) {
if (example == null)
return null;
return example.getProjectFolder(getName());
}


/**
* Contributes to newly created CMSIS RTE project. It could be an additional project nature, additional files, etc.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,11 @@ public interface IRteExampleItem extends ICmsisMapItem<IRteExampleItem> {
*/
String getLoadPath();

/**
* Return the folder attribute
* @return folder path, null if not supported.
*/
String getProjectFolder();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interface change: requires default implementation



}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public class RteExampleItem extends CmsisMapItem<IRteExampleItem> implements IRt
protected Boolean fImport = null;
protected String fEnvironment = null;
protected String fLoadPath = null;
protected String fProjectFolder = null;
protected ICpPack fPack = null; // example's pack

/**
Expand Down Expand Up @@ -237,6 +238,15 @@ public String getLoadPath() {
return fLoadPath;
}

@Override
public String getProjectFolder() {
if (fProjectFolder == null && isSupported()) {
ICpEnvironmentProvider envProvider = CpPlugIn.getEnvironmentProvider();
fProjectFolder = envProvider.getProjectFolder(getExample());
edriouk marked this conversation as resolved.
Show resolved Hide resolved
}
return fProjectFolder;
}

@Override
public boolean isToImport() {
if(fImport == null && isSupported()) {
Expand Down