org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer Java Examples
The following examples show how to use
org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: InMemoryJavaCompiler.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
@Override public NameEnvironmentAnswer findType(final char[][] compoundTypeName) { try { final Function1<char[], String> _function = (char[] it) -> { return String.valueOf(it); }; String _join = IterableExtensions.join(ListExtensions.<char[], String>map(((List<char[]>)Conversions.doWrapArray(compoundTypeName)), _function), "/"); final String fileName = (_join + ".class"); boolean _containsKey = this.cache.containsKey(fileName); if (_containsKey) { return this.cache.get(fileName); } final URL url = this.classLoader.getResource(fileName); if ((url == null)) { this.cache.put(fileName, null); return null; } final ClassFileReader reader = ClassFileReader.read(url.openStream(), fileName); final NameEnvironmentAnswer result = new NameEnvironmentAnswer(reader, null); this.cache.put(fileName, result); return result; } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example #2
Source File: Classpath.java From takari-lifecycle with Eclipse Public License 1.0 | 6 votes |
private NameEnvironmentAnswer findType(String packageName, String typeName) { NameEnvironmentAnswer suggestedAnswer = null; Collection<ClasspathEntry> entries = !packageName.isEmpty() ? packages.get(packageName) : this.entries; if (entries != null) { for (ClasspathEntry entry : entries) { NameEnvironmentAnswer answer = entry.findType(packageName, typeName); if (answer != null) { if (!answer.ignoreIfBetter()) { if (answer.isBetter(suggestedAnswer)) { return answer; } } else if (answer.isBetter(suggestedAnswer)) { // remember suggestion and keep looking suggestedAnswer = answer; } } } } return suggestedAnswer; }
Example #3
Source File: InMemoryJavaCompiler.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Override public NameEnvironmentAnswer findType(final char[][] compoundTypeName) { try { final Function1<char[], String> _function = (char[] it) -> { return String.valueOf(it); }; String _join = IterableExtensions.join(ListExtensions.<char[], String>map(((List<char[]>)Conversions.doWrapArray(compoundTypeName)), _function), "/"); final String fileName = (_join + ".class"); boolean _containsKey = this.cache.containsKey(fileName); if (_containsKey) { return this.cache.get(fileName); } final URL url = this.classLoader.getResource(fileName); if ((url == null)) { this.cache.put(fileName, null); return null; } final ClassFileReader reader = ClassFileReader.read(url.openStream(), fileName); final NameEnvironmentAnswer result = new NameEnvironmentAnswer(reader, null); this.cache.put(fileName, result); return result; } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example #4
Source File: SourcepathDirectory.java From takari-lifecycle with Eclipse Public License 1.0 | 6 votes |
@Override public NameEnvironmentAnswer findType(String packageName, String typeName, AccessRestriction accessRestriction) { Path javaFile = getFile(packageName, typeName); // Could be looking for a nested class, so try using outer class file name. // ASSUMPTION: '$' is ONLY used in a compiler generated class file names. if (javaFile == null && typeName.indexOf("$") > 0) { javaFile = getFile(packageName, typeName.split("\\$")[0]); } if (javaFile != null) { CompilationUnit cu = new ClasspathCompilationUnit(javaFile, encoding); return new NameEnvironmentAnswer(cu, accessRestriction); } return null; }
Example #5
Source File: SearchableEnvironment.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * @see org.eclipse.jdt.internal.compiler.env.INameEnvironment#findType(char[][]) */ public NameEnvironmentAnswer findType(char[][] compoundTypeName) { if (compoundTypeName == null) return null; int length = compoundTypeName.length; if (length <= 1) { if (length == 0) return null; return find(new String(compoundTypeName[0]), null); } int lengthM1 = length - 1; char[][] packageName = new char[lengthM1][]; System.arraycopy(compoundTypeName, 0, packageName, 0, lengthM1); return find( new String(compoundTypeName[lengthM1]), CharOperation.toString(packageName)); }
Example #6
Source File: InMemoryJavaCompiler.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Override public NameEnvironmentAnswer findType(final char[] typeName, final char[][] packageName) { try { final Function1<char[], String> _function = (char[] it) -> { return String.valueOf(it); }; String _join = IterableExtensions.join(ListExtensions.<char[], String>map(((List<char[]>)Conversions.doWrapArray(packageName)), _function), "/"); String _plus = (_join + "/"); String _valueOf = String.valueOf(typeName); String _plus_1 = (_plus + _valueOf); final String fileName = (_plus_1 + ".class"); boolean _containsKey = this.cache.containsKey(fileName); if (_containsKey) { return this.cache.get(fileName); } final URL url = this.classLoader.getResource(fileName); if ((url == null)) { this.cache.put(fileName, null); return null; } final ClassFileReader reader = ClassFileReader.read(url.openStream(), fileName); final NameEnvironmentAnswer result = new NameEnvironmentAnswer(reader, null); this.cache.put(fileName, result); return result; } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example #7
Source File: ClasspathDirectory.java From takari-lifecycle with Eclipse Public License 1.0 | 5 votes |
@Override public NameEnvironmentAnswer findType(String packageName, String typeName, AccessRestriction accessRestriction) { try { Path classFile = getFile(packageName, typeName); if (classFile != null) { try (InputStream is = Files.newInputStream(classFile)) { return new NameEnvironmentAnswer(ClassFileReader.read(is, classFile.getFileName().toString(), false), accessRestriction); } } } catch (ClassFormatException | IOException e) { // treat as if type is missing } return null; }
Example #8
Source File: Classpath.java From takari-lifecycle with Eclipse Public License 1.0 | 5 votes |
@Override public NameEnvironmentAnswer findType(char[][] compoundTypeName) { if (compoundTypeName == null) { return null; } int typeNameIndex = compoundTypeName.length - 1; char[][] packageName = CharOperation.subarray(compoundTypeName, 0, typeNameIndex); return findType(new String(CharOperation.concatWith(packageName, '/')), new String(compoundTypeName[typeNameIndex])); }
Example #9
Source File: ClasspathJar.java From takari-lifecycle with Eclipse Public License 1.0 | 5 votes |
@Override public NameEnvironmentAnswer findType(String packageName, String typeName, AccessRestriction accessRestriction) { try { String qualifiedFileName = packageName + "/" + typeName + SUFFIX_STRING_class; ClassFileReader reader = ClassFileReader.read(this.zipFile, qualifiedFileName); if (reader != null) { return new NameEnvironmentAnswer(reader, accessRestriction); } } catch (ClassFormatException | IOException e) { // treat as if class file is missing } return null; }
Example #10
Source File: OutputDirectoryClasspathEntry.java From takari-lifecycle with Eclipse Public License 1.0 | 5 votes |
@Override public NameEnvironmentAnswer findType(String packageName, String typeName) { Path file = delegate.getFile(packageName, typeName); if (file != null && !staleOutputs.contains(file.toFile())) { return delegate.findType(packageName, typeName, null); } return null; }
Example #11
Source File: ClasspathSourceJar.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public NameEnvironmentAnswer findClass(char[] typeName, String qualifiedPackageName, String qualifiedBinaryFileName, boolean asBinaryOnly) { if (!isPackage(qualifiedPackageName)) return null; // most common case ZipEntry sourceEntry = this.zipFile.getEntry(qualifiedBinaryFileName.substring(0, qualifiedBinaryFileName.length() - 6) + SUFFIX_STRING_java); if (sourceEntry != null) { try { InputStream stream = null; char[] contents = null; try { stream = this.zipFile.getInputStream(sourceEntry); contents = Util.getInputStreamAsCharArray(stream, -1, this.encoding); } finally { if (stream != null) stream.close(); } return new NameEnvironmentAnswer( new CompilationUnit( contents, qualifiedBinaryFileName.substring(0, qualifiedBinaryFileName.length() - 6) + SUFFIX_STRING_java, this.encoding, this.destinationPath), fetchAccessRestriction(qualifiedBinaryFileName)); } catch (IOException e) { // treat as if source file is missing } } return null; }
Example #12
Source File: FileSystem.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public NameEnvironmentAnswer findType(char[] typeName, char[][] packageName) { if (typeName != null) return findClass( new String(CharOperation.concatWith(packageName, typeName, '/')), typeName, false); return null; }
Example #13
Source File: FileSystem.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public NameEnvironmentAnswer findType(char[][] compoundName, boolean asBinaryOnly) { if (compoundName != null) return findClass( new String(CharOperation.concatWith(compoundName, '/')), compoundName[compoundName.length - 1], asBinaryOnly); return null; }
Example #14
Source File: FileSystem.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public NameEnvironmentAnswer findType(char[][] compoundName) { if (compoundName != null) return findClass( new String(CharOperation.concatWith(compoundName, '/')), compoundName[compoundName.length - 1], false); return null; }
Example #15
Source File: IndexAwareNameEnvironment.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Override public NameEnvironmentAnswer findType(char[] typeName, char[][] packageName) { List<String> segments = Arrays.stream(packageName).map(String::valueOf).collect(Collectors.toList()); segments.add(String.valueOf(typeName)); QualifiedName className = QualifiedName.create(segments); return findType(className); }
Example #16
Source File: InMemoryJavaCompiler.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override public NameEnvironmentAnswer findType(final char[] typeName, final char[][] packageName) { try { final Function1<char[], String> _function = (char[] it) -> { return String.valueOf(it); }; String _join = IterableExtensions.join(ListExtensions.<char[], String>map(((List<char[]>)Conversions.doWrapArray(packageName)), _function), "/"); String _plus = (_join + "/"); String _valueOf = String.valueOf(typeName); String _plus_1 = (_plus + _valueOf); final String fileName = (_plus_1 + ".class"); boolean _containsKey = this.cache.containsKey(fileName); if (_containsKey) { return this.cache.get(fileName); } final URL url = this.classLoader.getResource(fileName); if ((url == null)) { this.cache.put(fileName, null); return null; } final ClassFileReader reader = ClassFileReader.read(url.openStream(), fileName); final NameEnvironmentAnswer result = new NameEnvironmentAnswer(reader, null); this.cache.put(fileName, result); return result; } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example #17
Source File: JavaSearchNameEnvironment.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public NameEnvironmentAnswer findType(char[] typeName, char[][] packageName) { if (typeName != null) return findClass( new String(CharOperation.concatWith(packageName, typeName, '/')), typeName); return null; }
Example #18
Source File: JavaSearchNameEnvironment.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public NameEnvironmentAnswer findType(char[][] compoundName) { if (compoundName != null) return findClass( new String(CharOperation.concatWith(compoundName, '/')), compoundName[compoundName.length - 1]); return null; }
Example #19
Source File: SearchableEnvironment.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * @see org.eclipse.jdt.internal.compiler.env.INameEnvironment#findType(char[], char[][]) */ public NameEnvironmentAnswer findType(char[] name, char[][] packageName) { if (name == null) return null; return find( new String(name), packageName == null || packageName.length == 0 ? null : CharOperation.toString(packageName)); }
Example #20
Source File: ClasspathSourceDirectory.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public NameEnvironmentAnswer findClass(String sourceFileWithoutExtension, String qualifiedPackageName, String qualifiedSourceFileWithoutExtension) { SimpleLookupTable dirTable = directoryTable(qualifiedPackageName); if (dirTable != null && dirTable.elementSize > 0) { IFile file = (IFile) dirTable.get(sourceFileWithoutExtension); if (file != null) { return new NameEnvironmentAnswer(new ResourceCompilationUnit(file, file.getLocationURI()), null /* no access restriction */); } } return null; }
Example #21
Source File: CodeSnippetEnvironment.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * @see INameEnvironment#findType(char[], char[][]) */ public NameEnvironmentAnswer findType(char[] typeName, char[][] packageName) { NameEnvironmentAnswer result = this.env.findType(typeName, packageName); if (result != null) { return result; } return findType(CharOperation.arrayConcat(packageName, typeName)); }
Example #22
Source File: ClasspathDirectory.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
public NameEnvironmentAnswer findClass(char[] typeName, String qualifiedPackageName, String qualifiedBinaryFileName) { return findClass(typeName, qualifiedPackageName, qualifiedBinaryFileName, false); }
Example #23
Source File: IndexAwareNameEnvironment.java From xtext-extras with Eclipse Public License 2.0 | 4 votes |
@Override public NameEnvironmentAnswer findType(char[][] compoundTypeName) { List<String> segments = Arrays.stream(compoundTypeName).map(String::valueOf).collect(Collectors.toList()); QualifiedName className = QualifiedName.create(segments); return findType(className); }
Example #24
Source File: Classpath.java From takari-lifecycle with Eclipse Public License 1.0 | 4 votes |
@Override public NameEnvironmentAnswer findType(char[] typeName, char[][] packageName) { return findType(new String(CharOperation.concatWith(packageName, '/')), new String(typeName)); }
Example #25
Source File: DependencyClasspathEntry.java From takari-lifecycle with Eclipse Public License 1.0 | 4 votes |
@Override public NameEnvironmentAnswer findType(String packageName, String typeName) { return findType(packageName, typeName, getAccessRestriction(packageName)); }
Example #26
Source File: AccessRestrictionClasspathEntry.java From takari-lifecycle with Eclipse Public License 1.0 | 4 votes |
@Override public NameEnvironmentAnswer findType(String packageName, String typeName) { return entry.findType(packageName, typeName, accessRestriction); }
Example #27
Source File: ClasspathJar.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
public NameEnvironmentAnswer findClass(char[] typeName, String qualifiedPackageName, String qualifiedBinaryFileName) { return findClass(typeName, qualifiedPackageName, qualifiedBinaryFileName, false); }
Example #28
Source File: ClasspathSourceJar.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
public NameEnvironmentAnswer findClass(char[] typeName, String qualifiedPackageName, String qualifiedBinaryFileName) { return findClass(typeName, qualifiedPackageName, qualifiedBinaryFileName, false); }
Example #29
Source File: CancelableNameEnvironment.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
public NameEnvironmentAnswer findType(char[] name, char[][] packageName) { checkCanceled(); return super.findType(name, packageName); }
Example #30
Source File: CancelableNameEnvironment.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
public NameEnvironmentAnswer findType(char[][] compoundTypeName) { checkCanceled(); return super.findType(compoundTypeName); }