Skip to content

Commit 98cdf5a

Browse files
committed
Fixed some issues handling Java and IDL import statements
1 parent 6a822ee commit 98cdf5a

3 files changed

Lines changed: 38 additions & 7 deletions

File tree

src/filedef.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1484,7 +1484,7 @@ void FileDefImpl::addUsingDeclaration(const Definition *d)
14841484

14851485
void FileDefImpl::addIncludeDependency(const FileDef *fd,const QCString &incName,IncludeKind kind)
14861486
{
1487-
//printf("FileDefImpl::addIncludeDependency(%p,%s,%d)\n",fd,incName,local);
1487+
//printf("FileDefImpl::addIncludeDependency(%p,%s,%d)\n",(void*)fd,qPrint(incName),kind);
14881488
QCString iName = fd ? fd->absFilePath() : incName;
14891489
if (!iName.isEmpty() && m_includeMap.find(iName.str())==m_includeMap.end())
14901490
{

src/filedef.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ enum class IncludeKind : uint32_t
5252
ImportLocalObjC = 0x0008,
5353
ImportSystem = 0x0010, // C++20 header import
5454
ImportLocal = 0x0020, // C++20 header import
55-
ImportModule = 0x0040 // C++20 module import
55+
ImportModule = 0x0040 // C++20/Java module import
5656
};
5757

5858
inline constexpr uint32_t operator|(IncludeKind a, IncludeKind b) { return static_cast<uint32_t>(a) | static_cast<uint32_t>(b); }

src/scanner.l

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,7 @@ NONLopt [^\n]*
382382
%x Comment
383383
%x PackageName
384384
%x JavaImport
385+
%x IDLImport
385386
%x PHPUse
386387
%x PHPUseAs
387388
%x CSAccessorDecl
@@ -1963,20 +1964,33 @@ NONLopt [^\n]*
19631964
QCString scope=yytext;
19641965
yyextra->current->name=removeRedundantWhiteSpace(substitute(scope.left(scope.length()-1),".","::"));
19651966
yyextra->current->fileName = yyextra->fileName;
1967+
bool ambig = false;
1968+
FileDef *incFd = findFileDef(Doxygen::inputNameLinkedMap,yyextra->fileName,ambig);
1969+
if (incFd)
1970+
{
1971+
incFd->addIncludeDependency(nullptr,scope,IncludeKind::ImportModule);
1972+
}
19661973
yyextra->current->section = EntryType::makeUsingDir();
19671974
yyextra->current_root->moveToSubEntryAndRefresh(yyextra->current);
19681975
initEntry(yyscanner);
19691976
BEGIN(Using);
19701977
}
19711978
<JavaImport>({ID}{BN}*"."{BN}*)+{ID} { // class import => add as a using declaration
1972-
ModuleManager::instance().addImport(yyextra->fileName,
1973-
yyextra->yyLineNr,
1974-
yytext,
1975-
yyextra->current->exported);
19761979
lineCount(yyscanner);
19771980
QCString scope=yytext;
19781981
yyextra->current->name=removeRedundantWhiteSpace(substitute(scope,".","::"));
19791982
yyextra->current->fileName = yyextra->fileName;
1983+
bool ambig = false;
1984+
FileDef *fromFd = findFileDef(Doxygen::inputNameLinkedMap,yyextra->fileName,ambig);
1985+
FileDef *toFd = findFileDef(Doxygen::inputNameLinkedMap,scope,ambig);
1986+
if (fromFd)
1987+
{
1988+
fromFd->addIncludeDependency(toFd,scope,IncludeKind::ImportModule);
1989+
}
1990+
if (toFd && fromFd)
1991+
{
1992+
toFd->addIncludedByDependency(fromFd,fromFd->docName(),IncludeKind::ImportModule);
1993+
}
19801994
if (yyextra->insideD)
19811995
{
19821996
yyextra->current->section = EntryType::makeUsingDir();
@@ -1991,6 +2005,23 @@ NONLopt [^\n]*
19912005
initEntry(yyscanner);
19922006
BEGIN(Using);
19932007
}
2008+
<IDLImport>"\""[^"]*"\"" {
2009+
QCString fileName(&yytext[1],yyleng-2);
2010+
bool ambig = false;
2011+
FileDef *fromFd = findFileDef(Doxygen::inputNameLinkedMap,yyextra->fileName,ambig);
2012+
FileDef *toFd = findFileDef(Doxygen::inputNameLinkedMap,fileName,ambig);
2013+
if (fromFd)
2014+
{
2015+
fromFd->addIncludeDependency(toFd,fileName,IncludeKind::ImportModule);
2016+
}
2017+
if (toFd && fromFd)
2018+
{
2019+
toFd->addIncludedByDependency(fromFd,fromFd->docName(),IncludeKind::ImportModule);
2020+
}
2021+
}
2022+
<IDLImport>";" {
2023+
BEGIN(FindMembers);
2024+
}
19942025
<FindMembers>"using"{BN}+/("::"{ID}("::"{ID})*)? {
19952026
if (yyextra->insideJava) REJECT;
19962027
yyextra->current->startLine=yyextra->yyLineNr;
@@ -2430,7 +2461,7 @@ NONLopt [^\n]*
24302461
else if ((yyextra->insideIDL || yyextra->insideJava || yyextra->insideD) && yyleng==6 && qstrcmp(yytext,"import")==0)
24312462
{
24322463
if (yyextra->insideIDL)
2433-
BEGIN(NextSemi);
2464+
BEGIN(IDLImport);
24342465
else // yyextra->insideJava or yyextra->insideD
24352466
BEGIN(JavaImport);
24362467
}

0 commit comments

Comments
 (0)