mirror of
				https://github.com/MaskRay/ccls.git
				synced 2025-11-04 06:15:20 +00:00 
			
		
		
		
	Inject anonymous struct/union into parent scopes
This commit is contained in:
		
							parent
							
								
									134126629a
								
							
						
					
					
						commit
						c8a81aeae3
					
				@ -597,13 +597,16 @@ void SetVarDetail(IndexVar& var,
 | 
				
			|||||||
    CXTypeKind k = clang_getCanonicalType(
 | 
					    CXTypeKind k = clang_getCanonicalType(
 | 
				
			||||||
                       clang_getEnumDeclIntegerType(semanticContainer->cursor))
 | 
					                       clang_getEnumDeclIntegerType(semanticContainer->cursor))
 | 
				
			||||||
                       .kind;
 | 
					                       .kind;
 | 
				
			||||||
    std::string hover = qualified_name + " = ";
 | 
					    std::string hover = qualified_name;
 | 
				
			||||||
 | 
					    if (auto* TD = dyn_cast_or_null<EnumConstantDecl>(
 | 
				
			||||||
 | 
					            static_cast<const Decl*>(cursor.cx_cursor.data[0]))) {
 | 
				
			||||||
 | 
					      hover += " = ";
 | 
				
			||||||
      if (k == CXType_Char_U || k == CXType_UChar || k == CXType_UShort ||
 | 
					      if (k == CXType_Char_U || k == CXType_UChar || k == CXType_UShort ||
 | 
				
			||||||
          k == CXType_UInt || k == CXType_ULong || k == CXType_ULongLong)
 | 
					          k == CXType_UInt || k == CXType_ULong || k == CXType_ULongLong)
 | 
				
			||||||
      hover += std::to_string(
 | 
					        hover += std::to_string(TD->getInitVal().getZExtValue());
 | 
				
			||||||
          clang_getEnumConstantDeclUnsignedValue(cursor.cx_cursor));
 | 
					 | 
				
			||||||
      else
 | 
					      else
 | 
				
			||||||
      hover += std::to_string(clang_getEnumConstantDeclValue(cursor.cx_cursor));
 | 
					        hover += std::to_string(TD->getInitVal().getSExtValue());
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
    def.detailed_name = std::move(qualified_name);
 | 
					    def.detailed_name = std::move(qualified_name);
 | 
				
			||||||
    def.qual_name_offset = 0;
 | 
					    def.qual_name_offset = 0;
 | 
				
			||||||
    def.hover = hover;
 | 
					    def.hover = hover;
 | 
				
			||||||
@ -1518,13 +1521,19 @@ void OnIndexDeclaration(CXClientData client_data, const CXIdxDeclInfo* decl) {
 | 
				
			|||||||
                .def.vars.push_back(var.usr);
 | 
					                .def.vars.push_back(var.usr);
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
          case SymbolKind::Type:
 | 
					          case SymbolKind::Type: {
 | 
				
			||||||
            if (decl->semanticContainer->cursor.kind != CXCursor_EnumDecl) {
 | 
					            CXCursor parent = decl->semanticContainer->cursor;
 | 
				
			||||||
            long offset = clang_Cursor_getOffsetOfField(cursor.cx_cursor);
 | 
					            long offset = clang_Cursor_getOffsetOfField(cursor.cx_cursor);
 | 
				
			||||||
              db->ToType(decl->semanticContainer->cursor)
 | 
					            while (parent.kind != CXCursor_EnumDecl) {
 | 
				
			||||||
                  .def.vars.emplace_back(var.usr, offset);
 | 
					              IndexType& type = db->ToType(parent);
 | 
				
			||||||
 | 
					              type.def.vars.emplace_back(var.usr, offset);
 | 
				
			||||||
 | 
					              if (!clang_Cursor_isAnonymous(parent)) break;
 | 
				
			||||||
 | 
					              parent = clang_getCursorSemanticParent(parent);
 | 
				
			||||||
 | 
					              offset = -1;
 | 
				
			||||||
 | 
					              if (GetSymbolKind(parent.kind) != SymbolKind::Type) break;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
          default:
 | 
					          default:
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
				
			|||||||
@ -190,8 +190,8 @@ bool Indexer_Parse(DiagnosticsPublisher* diag_pub,
 | 
				
			|||||||
      on_indexed->PushBack(std::move(update), request.is_interactive);
 | 
					      on_indexed->PushBack(std::move(update), request.is_interactive);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    for (const auto& dep : dependencies)
 | 
					    for (const auto& dep : dependencies)
 | 
				
			||||||
      if (vfs->Mark(dep.first().str(), 0, 2)) {
 | 
					      if (vfs->Mark(dep.first().str(), 0, 2) &&
 | 
				
			||||||
        prev = RawCacheLoad(dep.first().str());
 | 
					          (prev = RawCacheLoad(dep.first().str()))) {
 | 
				
			||||||
        IndexUpdate update = IndexUpdate::CreateDelta(nullptr, prev.get());
 | 
					        IndexUpdate update = IndexUpdate::CreateDelta(nullptr, prev.get());
 | 
				
			||||||
        on_indexed->PushBack(std::move(update), request.is_interactive);
 | 
					        on_indexed->PushBack(std::move(update), request.is_interactive);
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user