public bool IsEventHandler([NotNull] IMethod declaredElement) { var sourceFiles = declaredElement.GetSourceFiles(); // The methods and property setters that we are interested in will only have a single source file if (sourceFiles.Count != 1) { return(false); } foreach (var assetGuid in myShortNameToAssetGuid[declaredElement.ShortName]) { var invokedType = UnityObjectPsiUtil.GetTypeElementFromScriptAssetGuid(mySolution, assetGuid); if (invokedType != null) { var members = invokedType.GetAllClassMembers(declaredElement.ShortName); foreach (var member in members) { if (Equals(member.Element, declaredElement)) { return(true); } } } } return(false); }
public override ISymbolTable GetReferenceSymbolTable(bool useReferenceName) { var assetGuid = myFileID.guid; var targetType = UnityObjectPsiUtil.GetTypeElementFromScriptAssetGuid(myOwner.GetSolution(), assetGuid); if (targetType == null) { return(EmptySymbolTable.INSTANCE); } // We don't need to do anything about useReferenceName, we only ever have one candidate var symbolTable = new SymbolTable(myOwner.GetPsiServices()); symbolTable.AddSymbol(assetGuid, targetType); return(symbolTable); }
public override ISymbolTable GetReferenceSymbolTable(bool useReferenceName) { var assetGuid = GetScriptAssetGuid(); var targetType = UnityObjectPsiUtil.GetTypeElementFromScriptAssetGuid(myOwner.GetSolution(), assetGuid); if (targetType == null) { return(EmptySymbolTable.INSTANCE); } var symbolTable = ResolveUtil.GetSymbolTableByTypeElement(targetType, SymbolTableMode.FULL, myOwner.GetPsiModule()); if (useReferenceName) { var name = GetName(); return(symbolTable.Filter(name, IsMethodFilter.INSTANCE, OverriddenFilter.INSTANCE, new ExactNameFilter(name), new StaticFilter(new NonStaticAccessContext(myOwner)), new EventHandlerSymbolFilter(myMode, myType, targetType.Module))); } return(symbolTable); }
public override ISymbolTable GetReferenceSymbolTable(bool useReferenceName) { var assetGuid = GetScriptAssetGuid(); var targetType = UnityObjectPsiUtil.GetTypeElementFromScriptAssetGuid(myOwner.GetSolution(), assetGuid); if (targetType == null) { return(EmptySymbolTable.INSTANCE); } var symbolTable = ResolveUtil.GetSymbolTableByTypeElement(targetType, SymbolTableMode.FULL, myOwner.GetPsiModule()); if (useReferenceName) { var name = GetName(); return(symbolTable.Filter(name, new ExactNameFilter(name))); } return(symbolTable); }