-
Notifications
You must be signed in to change notification settings - Fork 135
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
Add command to list Java projects #1238
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
174 changes: 174 additions & 0 deletions
174
...oft.java.test.plugin/src/main/java/com/microsoft/java/test/plugin/model/JavaTestItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,174 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2021 Microsoft Corporation and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Microsoft Corporation - initial API and implementation | ||
*******************************************************************************/ | ||
|
||
package com.microsoft.java.test.plugin.model; | ||
|
||
import org.eclipse.lsp4j.Range; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class JavaTestItem { | ||
private String id; | ||
|
||
private String label; | ||
|
||
private String fullName; | ||
|
||
private List<JavaTestItem> children; | ||
|
||
private TestLevel testLevel; | ||
|
||
private TestKind testKind; | ||
|
||
private String projectName; | ||
|
||
private String uri; | ||
|
||
private Range range; | ||
|
||
private String jdtHandler; | ||
|
||
public JavaTestItem() {} | ||
|
||
public JavaTestItem(String displayName, String fullName, String project, String uri, | ||
Range range, TestLevel level, TestKind kind) { | ||
this.label = displayName; | ||
this.fullName = fullName; | ||
this.testLevel = level; | ||
this.testKind = kind; | ||
this.projectName = project; | ||
this.uri = uri; | ||
this.range = range; | ||
|
||
if (level.equals(TestLevel.PROJECT)) { | ||
this.id = fullName; | ||
} else { | ||
this.id = project + "@" + fullName; | ||
} | ||
} | ||
|
||
public Range getRange() { | ||
return range; | ||
} | ||
|
||
public void setRange(Range range) { | ||
this.range = range; | ||
} | ||
|
||
public String getUri() { | ||
return uri; | ||
} | ||
|
||
public void setUri(String uri) { | ||
this.uri = uri; | ||
} | ||
|
||
public String getJdtHandler() { | ||
return jdtHandler; | ||
} | ||
|
||
public void setJdtHandler(String jdtHandler) { | ||
this.jdtHandler = jdtHandler; | ||
} | ||
|
||
public String getId() { | ||
return id; | ||
} | ||
|
||
public String getLabel() { | ||
return label; | ||
} | ||
|
||
public void setLabel(String label) { | ||
this.label = label; | ||
} | ||
|
||
public String getFullName() { | ||
return fullName; | ||
} | ||
|
||
public void setFullName(String fullName) { | ||
this.fullName = fullName; | ||
} | ||
|
||
public List<JavaTestItem> getChildren() { | ||
return children; | ||
} | ||
|
||
public void setChildren(List<JavaTestItem> children) { | ||
this.children = children; | ||
} | ||
|
||
public TestLevel getTestLevel() { | ||
return testLevel; | ||
} | ||
|
||
public void setTestLevel(TestLevel testLevel) { | ||
this.testLevel = testLevel; | ||
} | ||
|
||
public TestKind getTestKind() { | ||
return testKind; | ||
} | ||
|
||
public void setTestKind(TestKind testKind) { | ||
this.testKind = testKind; | ||
} | ||
|
||
public String getProjectName() { | ||
return projectName; | ||
} | ||
|
||
public void setProjectName(String projectName) { | ||
this.projectName = projectName; | ||
} | ||
|
||
public void addChild(JavaTestItem child) { | ||
if (this.children == null) { | ||
this.children = new ArrayList<>(); | ||
} | ||
this.children.add(child); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
final int prime = 31; | ||
int result = 1; | ||
result = prime * result + ((id == null) ? 0 : id.hashCode()); | ||
return result; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (this == obj) { | ||
return true; | ||
} | ||
|
||
if (obj == null) { | ||
return false; | ||
} | ||
|
||
if (getClass() != obj.getClass()) { | ||
return false; | ||
} | ||
final JavaTestItem other = (JavaTestItem) obj; | ||
if (id == null) { | ||
if (other.id != null) { | ||
|
||
return false; | ||
} | ||
} else if (!id.equals(other.id)){ | ||
return false; | ||
} | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sourceRange.getLength() - nameRange.getOffset() + sourceRange.getOffset()
equals tonameRange.getLength()
?can you briefly explain?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sourceRange contains JavaDocs, so
(nameRange.getOffset() - sourceRange.getOffset())
equals to the length of JavaDoc, I'll add a comment for it.