void (final CharSequence chars, final Consumer<? super String> result) { myLexer.start(chars); JavaSourceRootDetectionUtil.skipWhiteSpaceAndComments(myLexer); if (myLexer.getTokenType() == JavaTokenType.PACKAGE_KEYWORD) { advanceLexer(myLexer); if (readPackageName(chars, myLexer) == null) { return; } } while (true) { if (myLexer.getTokenType() == JavaTokenType.SEMICOLON) { advanceLexer(myLexer); } if (myLexer.getTokenType() != JavaTokenType.IMPORT_KEYWORD) { return; } advanceLexer(myLexer); boolean isStaticImport = false; if (myLexer.getTokenType() == JavaTokenType.STATIC_KEYWORD) { isStaticImport = true; advanceLexer(myLexer); } final String packageName = readPackageName(chars, myLexer); if (packageName == null) { return; } if (packageName.endsWith(".*")) { result.consume(packageName.substring(0, packageName.length() - ".*".length())); } else { int lastDot = packageName.lastIndexOf('.'); if (lastDot > 0) { String _packageName = packageName.substring(0, lastDot); if (isStaticImport) { lastDot = _packageName.lastIndexOf('.'); if (lastDot > 0) { result.consume(_packageName.substring(0, lastDot)); } } else { result.consume(_packageName); } } } } }