forked from eclipse-jdt/eclipse.jdt.core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix some test cases where a source unit's name is not a file path
Signed-off-by: Rob Stryker <[email protected]> Cleanup Signed-off-by: Rob Stryker <[email protected]>
- Loading branch information
Rob Stryker
committed
Apr 24, 2024
1 parent
43a949a
commit 0ef7ada
Showing
2 changed files
with
129 additions
and
9 deletions.
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
100 changes: 100 additions & 0 deletions
100
org.eclipse.jdt.core.javac/src/org/eclipse/jdt/internal/javac/VirtualFileObject.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,100 @@ | ||
package org.eclipse.jdt.internal.javac; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.io.OutputStream; | ||
import java.io.Reader; | ||
import java.io.Writer; | ||
import java.net.URI; | ||
|
||
import javax.lang.model.element.Modifier; | ||
import javax.lang.model.element.NestingKind; | ||
import javax.tools.JavaFileObject; | ||
|
||
import org.eclipse.jdt.internal.compiler.env.ICompilationUnit; | ||
|
||
public class VirtualFileObject implements JavaFileObject { | ||
private ICompilationUnit sourceUnit; | ||
private Kind kind; | ||
public VirtualFileObject(ICompilationUnit sourceUnit, Kind kind) { | ||
this.sourceUnit = sourceUnit; | ||
this.kind = kind; | ||
} | ||
|
||
@Override | ||
public URI toUri() { | ||
// TODO Auto-generated method stub | ||
return null; | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return new String(sourceUnit.getFileName()); | ||
} | ||
|
||
@Override | ||
public InputStream openInputStream() throws IOException { | ||
// TODO Auto-generated method stub | ||
return null; | ||
} | ||
|
||
@Override | ||
public OutputStream openOutputStream() throws IOException { | ||
// TODO Auto-generated method stub | ||
return null; | ||
} | ||
|
||
@Override | ||
public Reader openReader(boolean ignoreEncodingErrors) throws IOException { | ||
// TODO Auto-generated method stub | ||
return null; | ||
} | ||
|
||
@Override | ||
public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException { | ||
StringBuilder sb = new StringBuilder(); | ||
sb.append(this.sourceUnit.getContents()); | ||
return sb; | ||
} | ||
|
||
@Override | ||
public Writer openWriter() throws IOException { | ||
// TODO Auto-generated method stub | ||
return null; | ||
} | ||
|
||
@Override | ||
public long getLastModified() { | ||
// TODO Auto-generated method stub | ||
return 0; | ||
} | ||
|
||
@Override | ||
public boolean delete() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public Kind getKind() { | ||
return this.kind; | ||
} | ||
|
||
@Override | ||
public boolean isNameCompatible(String simpleName, Kind kind) { | ||
// TODO Auto-generated method stub | ||
return false; | ||
} | ||
|
||
@Override | ||
public NestingKind getNestingKind() { | ||
// TODO Auto-generated method stub | ||
return null; | ||
} | ||
|
||
@Override | ||
public Modifier getAccessLevel() { | ||
// TODO Auto-generated method stub | ||
return null; | ||
} | ||
|
||
} |