Merge pull request #2917 from ethereum/importautocomplete
add imports to auto-completepull/5370/head
commit
db0224bd49
@ -0,0 +1,82 @@ |
||||
'use strict' |
||||
import { CodeParser } from "../code-parser"; |
||||
|
||||
export type CodeParserImportsData= { |
||||
files?: string[], |
||||
modules?: string[], |
||||
packages?: string[], |
||||
} |
||||
|
||||
export default class CodeParserImports { |
||||
plugin: CodeParser |
||||
|
||||
data: CodeParserImportsData = {} |
||||
constructor(plugin: CodeParser) { |
||||
this.plugin = plugin |
||||
this.init() |
||||
} |
||||
|
||||
async getImports(){ |
||||
return this.data |
||||
} |
||||
|
||||
async init() { |
||||
// @ts-ignore
|
||||
const txt = await import('raw-loader!libs/remix-ui/editor/src/lib/providers/completion/contracts/contracts.txt') |
||||
this.data.modules = txt.default.split('\n') |
||||
.filter(x => x !== '') |
||||
.map(x => x.replace('./node_modules/', '')) |
||||
.filter(x => { |
||||
if(x.includes('@openzeppelin')) { |
||||
return !x.includes('mock') |
||||
}else{ |
||||
return true |
||||
}
|
||||
}) |
||||
|
||||
// get unique first words of the values in the array
|
||||
this.data.packages = [...new Set(this.data.modules.map(x => x.split('/')[0]))] |
||||
} |
||||
|
||||
setFileTree = async () => { |
||||
this.data.files = await this.getDirectory('/') |
||||
this.data.files = this.data.files.filter(x => x.endsWith('.sol') && !x.startsWith('.deps') && !x.startsWith('.git')) |
||||
} |
||||
|
||||
getDirectory = async (dir: string) => { |
||||
let result = [] |
||||
const files = await this.plugin.call('fileManager', 'readdir', dir) |
||||
const fileArray = this.normalize(files) |
||||
for (const fi of fileArray) { |
||||
if (fi) { |
||||
const type = fi.data.isDirectory |
||||
if (type === true) { |
||||
result = [...result, ...(await this.getDirectory(`${fi.filename}`))] |
||||
} else { |
||||
result = [...result, fi.filename] |
||||
} |
||||
} |
||||
} |
||||
return result |
||||
} |
||||
|
||||
normalize = filesList => { |
||||
const folders = [] |
||||
const files = [] |
||||
Object.keys(filesList || {}).forEach(key => { |
||||
if (filesList[key].isDirectory) { |
||||
folders.push({ |
||||
filename: key, |
||||
data: filesList[key] |
||||
}) |
||||
} else { |
||||
files.push({ |
||||
filename: key, |
||||
data: filesList[key] |
||||
}) |
||||
} |
||||
}) |
||||
return [...folders, ...files] |
||||
} |
||||
|
||||
} |
@ -0,0 +1,198 @@ |
||||
./node_modules/@openzeppelin/contracts/access/AccessControl.sol |
||||
./node_modules/@openzeppelin/contracts/access/AccessControlCrossChain.sol |
||||
./node_modules/@openzeppelin/contracts/access/AccessControlEnumerable.sol |
||||
./node_modules/@openzeppelin/contracts/access/IAccessControl.sol |
||||
./node_modules/@openzeppelin/contracts/access/IAccessControlEnumerable.sol |
||||
./node_modules/@openzeppelin/contracts/access/Ownable.sol |
||||
./node_modules/@openzeppelin/contracts/crosschain/amb/CrossChainEnabledAMB.sol |
||||
./node_modules/@openzeppelin/contracts/crosschain/amb/LibAMB.sol |
||||
./node_modules/@openzeppelin/contracts/crosschain/arbitrum/CrossChainEnabledArbitrumL1.sol |
||||
./node_modules/@openzeppelin/contracts/crosschain/arbitrum/CrossChainEnabledArbitrumL2.sol |
||||
./node_modules/@openzeppelin/contracts/crosschain/arbitrum/LibArbitrumL1.sol |
||||
./node_modules/@openzeppelin/contracts/crosschain/arbitrum/LibArbitrumL2.sol |
||||
./node_modules/@openzeppelin/contracts/crosschain/CrossChainEnabled.sol |
||||
./node_modules/@openzeppelin/contracts/crosschain/errors.sol |
||||
./node_modules/@openzeppelin/contracts/crosschain/optimism/CrossChainEnabledOptimism.sol |
||||
./node_modules/@openzeppelin/contracts/crosschain/optimism/LibOptimism.sol |
||||
./node_modules/@openzeppelin/contracts/crosschain/polygon/CrossChainEnabledPolygonChild.sol |
||||
./node_modules/@openzeppelin/contracts/finance/PaymentSplitter.sol |
||||
./node_modules/@openzeppelin/contracts/finance/VestingWallet.sol |
||||
./node_modules/@openzeppelin/contracts/governance/compatibility/GovernorCompatibilityBravo.sol |
||||
./node_modules/@openzeppelin/contracts/governance/compatibility/IGovernorCompatibilityBravo.sol |
||||
./node_modules/@openzeppelin/contracts/governance/extensions/GovernorCountingSimple.sol |
||||
./node_modules/@openzeppelin/contracts/governance/extensions/GovernorPreventLateQuorum.sol |
||||
./node_modules/@openzeppelin/contracts/governance/extensions/GovernorProposalThreshold.sol |
||||
./node_modules/@openzeppelin/contracts/governance/extensions/GovernorSettings.sol |
||||
./node_modules/@openzeppelin/contracts/governance/extensions/GovernorTimelockCompound.sol |
||||
./node_modules/@openzeppelin/contracts/governance/extensions/GovernorTimelockControl.sol |
||||
./node_modules/@openzeppelin/contracts/governance/extensions/GovernorVotes.sol |
||||
./node_modules/@openzeppelin/contracts/governance/extensions/GovernorVotesComp.sol |
||||
./node_modules/@openzeppelin/contracts/governance/extensions/GovernorVotesQuorumFraction.sol |
||||
./node_modules/@openzeppelin/contracts/governance/extensions/IGovernorTimelock.sol |
||||
./node_modules/@openzeppelin/contracts/governance/Governor.sol |
||||
./node_modules/@openzeppelin/contracts/governance/IGovernor.sol |
||||
./node_modules/@openzeppelin/contracts/governance/TimelockController.sol |
||||
./node_modules/@openzeppelin/contracts/governance/utils/IVotes.sol |
||||
./node_modules/@openzeppelin/contracts/governance/utils/Votes.sol |
||||
./node_modules/@openzeppelin/contracts/interfaces/draft-IERC1822.sol |
||||
./node_modules/@openzeppelin/contracts/interfaces/draft-IERC2612.sol |
||||
./node_modules/@openzeppelin/contracts/interfaces/IERC1155.sol |
||||
./node_modules/@openzeppelin/contracts/interfaces/IERC1155MetadataURI.sol |
||||
./node_modules/@openzeppelin/contracts/interfaces/IERC1155Receiver.sol |
||||
./node_modules/@openzeppelin/contracts/interfaces/IERC1271.sol |
||||
./node_modules/@openzeppelin/contracts/interfaces/IERC1363.sol |
||||
./node_modules/@openzeppelin/contracts/interfaces/IERC1363Receiver.sol |
||||
./node_modules/@openzeppelin/contracts/interfaces/IERC1363Spender.sol |
||||
./node_modules/@openzeppelin/contracts/interfaces/IERC165.sol |
||||
./node_modules/@openzeppelin/contracts/interfaces/IERC1820Implementer.sol |
||||
./node_modules/@openzeppelin/contracts/interfaces/IERC1820Registry.sol |
||||
./node_modules/@openzeppelin/contracts/interfaces/IERC20.sol |
||||
./node_modules/@openzeppelin/contracts/interfaces/IERC20Metadata.sol |
||||
./node_modules/@openzeppelin/contracts/interfaces/IERC2981.sol |
||||
./node_modules/@openzeppelin/contracts/interfaces/IERC3156.sol |
||||
./node_modules/@openzeppelin/contracts/interfaces/IERC3156FlashBorrower.sol |
||||
./node_modules/@openzeppelin/contracts/interfaces/IERC3156FlashLender.sol |
||||
./node_modules/@openzeppelin/contracts/interfaces/IERC4626.sol |
||||
./node_modules/@openzeppelin/contracts/interfaces/IERC721.sol |
||||
./node_modules/@openzeppelin/contracts/interfaces/IERC721Enumerable.sol |
||||
./node_modules/@openzeppelin/contracts/interfaces/IERC721Metadata.sol |
||||
./node_modules/@openzeppelin/contracts/interfaces/IERC721Receiver.sol |
||||
./node_modules/@openzeppelin/contracts/interfaces/IERC777.sol |
||||
./node_modules/@openzeppelin/contracts/interfaces/IERC777Recipient.sol |
||||
./node_modules/@openzeppelin/contracts/interfaces/IERC777Sender.sol |
||||
./node_modules/@openzeppelin/contracts/metatx/ERC2771Context.sol |
||||
./node_modules/@openzeppelin/contracts/metatx/MinimalForwarder.sol |
||||
./node_modules/@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol |
||||
./node_modules/@openzeppelin/contracts/proxy/beacon/IBeacon.sol |
||||
./node_modules/@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol |
||||
./node_modules/@openzeppelin/contracts/proxy/Clones.sol |
||||
./node_modules/@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol |
||||
./node_modules/@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol |
||||
./node_modules/@openzeppelin/contracts/proxy/Proxy.sol |
||||
./node_modules/@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol |
||||
./node_modules/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol |
||||
./node_modules/@openzeppelin/contracts/proxy/utils/Initializable.sol |
||||
./node_modules/@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol |
||||
./node_modules/@openzeppelin/contracts/security/Pausable.sol |
||||
./node_modules/@openzeppelin/contracts/security/PullPayment.sol |
||||
./node_modules/@openzeppelin/contracts/security/ReentrancyGuard.sol |
||||
./node_modules/@openzeppelin/contracts/token/common/ERC2981.sol |
||||
./node_modules/@openzeppelin/contracts/token/ERC1155/ERC1155.sol |
||||
./node_modules/@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Burnable.sol |
||||
./node_modules/@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Pausable.sol |
||||
./node_modules/@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Supply.sol |
||||
./node_modules/@openzeppelin/contracts/token/ERC1155/extensions/ERC1155URIStorage.sol |
||||
./node_modules/@openzeppelin/contracts/token/ERC1155/extensions/IERC1155MetadataURI.sol |
||||
./node_modules/@openzeppelin/contracts/token/ERC1155/IERC1155.sol |
||||
./node_modules/@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol |
||||
./node_modules/@openzeppelin/contracts/token/ERC1155/presets/ERC1155PresetMinterPauser.sol |
||||
./node_modules/@openzeppelin/contracts/token/ERC1155/utils/ERC1155Holder.sol |
||||
./node_modules/@openzeppelin/contracts/token/ERC1155/utils/ERC1155Receiver.sol |
||||
./node_modules/@openzeppelin/contracts/token/ERC20/ERC20.sol |
||||
./node_modules/@openzeppelin/contracts/token/ERC20/extensions/draft-ERC20Permit.sol |
||||
./node_modules/@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol |
||||
./node_modules/@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol |
||||
./node_modules/@openzeppelin/contracts/token/ERC20/extensions/ERC20Capped.sol |
||||
./node_modules/@openzeppelin/contracts/token/ERC20/extensions/ERC20FlashMint.sol |
||||
./node_modules/@openzeppelin/contracts/token/ERC20/extensions/ERC20Pausable.sol |
||||
./node_modules/@openzeppelin/contracts/token/ERC20/extensions/ERC20Snapshot.sol |
||||
./node_modules/@openzeppelin/contracts/token/ERC20/extensions/ERC20Votes.sol |
||||
./node_modules/@openzeppelin/contracts/token/ERC20/extensions/ERC20VotesComp.sol |
||||
./node_modules/@openzeppelin/contracts/token/ERC20/extensions/ERC20Wrapper.sol |
||||
./node_modules/@openzeppelin/contracts/token/ERC20/extensions/ERC4626.sol |
||||
./node_modules/@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol |
||||
./node_modules/@openzeppelin/contracts/token/ERC20/IERC20.sol |
||||
./node_modules/@openzeppelin/contracts/token/ERC20/presets/ERC20PresetFixedSupply.sol |
||||
./node_modules/@openzeppelin/contracts/token/ERC20/presets/ERC20PresetMinterPauser.sol |
||||
./node_modules/@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol |
||||
./node_modules/@openzeppelin/contracts/token/ERC20/utils/TokenTimelock.sol |
||||
./node_modules/@openzeppelin/contracts/token/ERC721/ERC721.sol |
||||
./node_modules/@openzeppelin/contracts/token/ERC721/extensions/draft-ERC721Votes.sol |
||||
./node_modules/@openzeppelin/contracts/token/ERC721/extensions/ERC721Burnable.sol |
||||
./node_modules/@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol |
||||
./node_modules/@openzeppelin/contracts/token/ERC721/extensions/ERC721Pausable.sol |
||||
./node_modules/@openzeppelin/contracts/token/ERC721/extensions/ERC721Royalty.sol |
||||
./node_modules/@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol |
||||
./node_modules/@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol |
||||
./node_modules/@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol |
||||
./node_modules/@openzeppelin/contracts/token/ERC721/IERC721.sol |
||||
./node_modules/@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol |
||||
./node_modules/@openzeppelin/contracts/token/ERC721/presets/ERC721PresetMinterPauserAutoId.sol |
||||
./node_modules/@openzeppelin/contracts/token/ERC721/utils/ERC721Holder.sol |
||||
./node_modules/@openzeppelin/contracts/token/ERC777/ERC777.sol |
||||
./node_modules/@openzeppelin/contracts/token/ERC777/IERC777.sol |
||||
./node_modules/@openzeppelin/contracts/token/ERC777/IERC777Recipient.sol |
||||
./node_modules/@openzeppelin/contracts/token/ERC777/IERC777Sender.sol |
||||
./node_modules/@openzeppelin/contracts/token/ERC777/presets/ERC777PresetFixedSupply.sol |
||||
./node_modules/@openzeppelin/contracts/utils/Address.sol |
||||
./node_modules/@openzeppelin/contracts/utils/Arrays.sol |
||||
./node_modules/@openzeppelin/contracts/utils/Base64.sol |
||||
./node_modules/@openzeppelin/contracts/utils/Checkpoints.sol |
||||
./node_modules/@openzeppelin/contracts/utils/Context.sol |
||||
./node_modules/@openzeppelin/contracts/utils/Counters.sol |
||||
./node_modules/@openzeppelin/contracts/utils/Create2.sol |
||||
./node_modules/@openzeppelin/contracts/utils/cryptography/draft-EIP712.sol |
||||
./node_modules/@openzeppelin/contracts/utils/cryptography/ECDSA.sol |
||||
./node_modules/@openzeppelin/contracts/utils/cryptography/MerkleProof.sol |
||||
./node_modules/@openzeppelin/contracts/utils/cryptography/SignatureChecker.sol |
||||
./node_modules/@openzeppelin/contracts/utils/escrow/ConditionalEscrow.sol |
||||
./node_modules/@openzeppelin/contracts/utils/escrow/Escrow.sol |
||||
./node_modules/@openzeppelin/contracts/utils/escrow/RefundEscrow.sol |
||||
./node_modules/@openzeppelin/contracts/utils/introspection/ERC165.sol |
||||
./node_modules/@openzeppelin/contracts/utils/introspection/ERC165Checker.sol |
||||
./node_modules/@openzeppelin/contracts/utils/introspection/ERC165Storage.sol |
||||
./node_modules/@openzeppelin/contracts/utils/introspection/ERC1820Implementer.sol |
||||
./node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol |
||||
./node_modules/@openzeppelin/contracts/utils/introspection/IERC1820Implementer.sol |
||||
./node_modules/@openzeppelin/contracts/utils/introspection/IERC1820Registry.sol |
||||
./node_modules/@openzeppelin/contracts/utils/math/Math.sol |
||||
./node_modules/@openzeppelin/contracts/utils/math/SafeCast.sol |
||||
./node_modules/@openzeppelin/contracts/utils/math/SafeMath.sol |
||||
./node_modules/@openzeppelin/contracts/utils/math/SignedMath.sol |
||||
./node_modules/@openzeppelin/contracts/utils/math/SignedSafeMath.sol |
||||
./node_modules/@openzeppelin/contracts/utils/Multicall.sol |
||||
./node_modules/@openzeppelin/contracts/utils/StorageSlot.sol |
||||
./node_modules/@openzeppelin/contracts/utils/Strings.sol |
||||
./node_modules/@openzeppelin/contracts/utils/structs/BitMaps.sol |
||||
./node_modules/@openzeppelin/contracts/utils/structs/DoubleEndedQueue.sol |
||||
./node_modules/@openzeppelin/contracts/utils/structs/EnumerableMap.sol |
||||
./node_modules/@openzeppelin/contracts/utils/structs/EnumerableSet.sol |
||||
./node_modules/@openzeppelin/contracts/utils/Timers.sol |
||||
./node_modules/@openzeppelin/contracts/vendor/amb/IAMB.sol |
||||
./node_modules/@openzeppelin/contracts/vendor/arbitrum/IArbSys.sol |
||||
./node_modules/@openzeppelin/contracts/vendor/arbitrum/IBridge.sol |
||||
./node_modules/@openzeppelin/contracts/vendor/arbitrum/IInbox.sol |
||||
./node_modules/@openzeppelin/contracts/vendor/arbitrum/IMessageProvider.sol |
||||
./node_modules/@openzeppelin/contracts/vendor/arbitrum/IOutbox.sol |
||||
./node_modules/@openzeppelin/contracts/vendor/compound/ICompoundTimelock.sol |
||||
./node_modules/@openzeppelin/contracts/vendor/optimism/ICrossDomainMessenger.sol |
||||
./node_modules/@openzeppelin/contracts/vendor/polygon/IFxMessageProcessor.sol |
||||
./node_modules/@uniswap/v3-core/contracts/interfaces/callback/IUniswapV3FlashCallback.sol |
||||
./node_modules/@uniswap/v3-core/contracts/interfaces/callback/IUniswapV3MintCallback.sol |
||||
./node_modules/@uniswap/v3-core/contracts/interfaces/callback/IUniswapV3SwapCallback.sol |
||||
./node_modules/@uniswap/v3-core/contracts/interfaces/IERC20Minimal.sol |
||||
./node_modules/@uniswap/v3-core/contracts/interfaces/IUniswapV3Factory.sol |
||||
./node_modules/@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol |
||||
./node_modules/@uniswap/v3-core/contracts/interfaces/IUniswapV3PoolDeployer.sol |
||||
./node_modules/@uniswap/v3-core/contracts/interfaces/pool/IUniswapV3PoolActions.sol |
||||
./node_modules/@uniswap/v3-core/contracts/interfaces/pool/IUniswapV3PoolDerivedState.sol |
||||
./node_modules/@uniswap/v3-core/contracts/interfaces/pool/IUniswapV3PoolEvents.sol |
||||
./node_modules/@uniswap/v3-core/contracts/interfaces/pool/IUniswapV3PoolImmutables.sol |
||||
./node_modules/@uniswap/v3-core/contracts/interfaces/pool/IUniswapV3PoolOwnerActions.sol |
||||
./node_modules/@uniswap/v3-core/contracts/interfaces/pool/IUniswapV3PoolState.sol |
||||
./node_modules/@uniswap/v3-core/contracts/libraries/BitMath.sol |
||||
./node_modules/@uniswap/v3-core/contracts/libraries/FixedPoint128.sol |
||||
./node_modules/@uniswap/v3-core/contracts/libraries/FixedPoint96.sol |
||||
./node_modules/@uniswap/v3-core/contracts/libraries/FullMath.sol |
||||
./node_modules/@uniswap/v3-core/contracts/libraries/LiquidityMath.sol |
||||
./node_modules/@uniswap/v3-core/contracts/libraries/LowGasSafeMath.sol |
||||
./node_modules/@uniswap/v3-core/contracts/libraries/Oracle.sol |
||||
./node_modules/@uniswap/v3-core/contracts/libraries/Position.sol |
||||
./node_modules/@uniswap/v3-core/contracts/libraries/SafeCast.sol |
||||
./node_modules/@uniswap/v3-core/contracts/libraries/SqrtPriceMath.sol |
||||
./node_modules/@uniswap/v3-core/contracts/libraries/SwapMath.sol |
||||
./node_modules/@uniswap/v3-core/contracts/libraries/Tick.sol |
||||
./node_modules/@uniswap/v3-core/contracts/libraries/TickBitmap.sol |
||||
./node_modules/@uniswap/v3-core/contracts/libraries/TickMath.sol |
||||
./node_modules/@uniswap/v3-core/contracts/libraries/TransferHelper.sol |
||||
./node_modules/@uniswap/v3-core/contracts/libraries/UnsafeMath.sol |
@ -1 +1,3 @@ |
||||
export { SearchTab } from './lib/components/Search'; |
||||
export { SearchTab } from './lib/components/Search'; |
||||
export * from './lib/components/results/SearchHelper'; |
||||
export * from './lib/types'; |
Loading…
Reference in new issue