} else if (this.openable instanceof ModularClassFile) { try { IModuleDescription module = ((ModularClassFile) this.openable).getModule();
public void locateMatches(MatchLocator locator, ModularClassFile mClassFile) throws CoreException { SearchPattern pattern = locator.pattern; this.modularClassFile = mClassFile; this.binaryModule = this.modularClassFile.getBinaryModuleInfo(); if (this.binaryModule == null) return; // cache all the details this.moduleDesc = mClassFile.getModule(); this.moduleName = this.binaryModule.name(); this.module = locator.lookupEnvironment.getModule(this.moduleName); matchModuleDeclaration(pattern, locator); matchModuleReferences(pattern, locator); matchPackageReferences(pattern, locator); matchTypeReferences(pattern, locator); } private void matchModuleDeclaration(SearchPattern pattern, MatchLocator locator) throws CoreException {
public void locateMatches(MatchLocator locator, ModularClassFile mClassFile) throws CoreException { SearchPattern pattern = locator.pattern; this.modularClassFile = mClassFile; this.binaryModule = this.modularClassFile.getBinaryModuleInfo(); if (this.binaryModule == null) return; // cache all the details this.moduleDesc = mClassFile.getModule(); this.moduleName = this.binaryModule.name(); this.module = locator.lookupEnvironment.getModule(this.moduleName); matchModuleDeclaration(pattern, locator); matchModuleReferences(pattern, locator); matchPackageReferences(pattern, locator); matchTypeReferences(pattern, locator); } private void matchModuleDeclaration(SearchPattern pattern, MatchLocator locator) throws CoreException {
/** * @see ITypeRoot */ public IJavaElement getElementAt(int position) throws JavaModelException { IJavaElement parentElement = getParent(); while (parentElement.getElementType() != IJavaElement.PACKAGE_FRAGMENT_ROOT) { parentElement = parentElement.getParent(); } PackageFragmentRoot root = (PackageFragmentRoot) parentElement; SourceMapper mapper = root.getSourceMapper(); if (mapper == null) { return null; } else { // ensure this class file's buffer is open so that source ranges are computed getBuffer(); IModuleDescription module = getModule(); return findElement(module, position, mapper); } } @Override
/** * @see ITypeRoot */ @Override public IJavaElement getElementAt(int position) throws JavaModelException { IJavaElement parentElement = getParent(); while (parentElement.getElementType() != IJavaElement.PACKAGE_FRAGMENT_ROOT) { parentElement = parentElement.getParent(); } PackageFragmentRoot root = (PackageFragmentRoot) parentElement; SourceMapper mapper = root.getSourceMapper(); if (mapper == null) { return null; } else { // ensure this class file's buffer is open so that source ranges are computed getBuffer(); IModuleDescription module = getModule(); return findElement(module, position, mapper); } } @Override
public char[] getContents() { char[] contents = (this.source == NO_SOURCE_FILE) ? null : this.source; if (this.source == null) { if (this.openable instanceof AbstractClassFile) { String fileName = getSourceFileName(); if (fileName == NO_SOURCE_FILE_NAME) return CharOperation.NO_CHAR; SourceMapper sourceMapper = this.openable.getSourceMapper(); if (sourceMapper != null) { if (this.openable instanceof ClassFile) { IType type = ((ClassFile) this.openable).getType(); contents = sourceMapper.findSource(type, fileName); } else if (this.openable instanceof ModularClassFile) { try { IModuleDescription module = ((ModularClassFile) this.openable).getModule(); contents = module != null ? sourceMapper.findSource(module) : CharOperation.NO_CHAR; // FIXME(SHMOD) } catch (JavaModelException e) { return CharOperation.NO_CHAR; } } } } else { contents = this.document.getCharContents(); } this.source = (contents == null) ? NO_SOURCE_FILE : contents; } return contents; } /**
/** Loads the buffer via SourceMapper, and maps it in SourceMapper */ private IBuffer mapSource(SourceMapper mapper) throws JavaModelException { char[] contents = mapper.findSource(getModule()); if (contents != null) { // create buffer IBuffer buffer = BufferManager.createBuffer(this); if (buffer == null) return null; BufferManager bufManager = getBufferManager(); bufManager.addBuffer(buffer); // set the buffer source if (buffer.getCharacters() == null){ buffer.setContents(contents); } // listen to buffer changes buffer.addBufferChangedListener(this); // do the source mapping mapper.mapSource((NamedMember) getModule(), contents, null); return buffer; } else { // create buffer IBuffer buffer = BufferManager.createNullBuffer(this); if (buffer == null) return null; BufferManager bufManager = getBufferManager(); bufManager.addBuffer(buffer); // listen to buffer changes buffer.addBufferChangedListener(this); return buffer; } }
/** Loads the buffer via SourceMapper, and maps it in SourceMapper */ private IBuffer mapSource(SourceMapper mapper) throws JavaModelException { char[] contents = mapper.findSource(getModule()); if (contents != null) { // create buffer IBuffer buffer = BufferManager.createBuffer(this); if (buffer == null) return null; BufferManager bufManager = getBufferManager(); bufManager.addBuffer(buffer); // set the buffer source if (buffer.getCharacters() == null){ buffer.setContents(contents); } // listen to buffer changes buffer.addBufferChangedListener(this); // do the source mapping mapper.mapSource((NamedMember) getModule(), contents, null); return buffer; } else { // create buffer IBuffer buffer = BufferManager.createNullBuffer(this); if (buffer == null) return null; BufferManager bufManager = getBufferManager(); bufManager.addBuffer(buffer); // listen to buffer changes buffer.addBufferChangedListener(this); return buffer; } }