public bool IsAvailable(IUserDataHolder cache) { var invocation = _provider.GetSelectedElement<IInvocationExpression>(false, false); if (invocation == null || invocation.Reference == null) return false; var referenceExpression = invocation.InvokedExpression as IReferenceExpression; if (referenceExpression == null) return false; switch (referenceExpression.Reference.GetName()) { case "Stub": case "Expect": case "AssertWasCalled": case "AssertWasNotCalled": return false; } var qualifierExpression = referenceExpression.QualifierExpression as IReferenceExpression; if (qualifierExpression == null) return false; var qualifierType = qualifierExpression.Type(); if (!qualifierType.GetPresentableName(CSharpLanguage.Instance).StartsWith("I")) return false; return true; }
public override sealed bool IsAvailable(IUserDataHolder cache) { using (ReadLockCookie.Create()) { if (Provider.SelectedElement != null) { var catelArgumentType = TypeHelper.CreateTypeByCLRName(CatelCore.Argument, Provider.PsiModule, Provider.SelectedElement.GetResolveContext()); _parameterDeclaration = null; _methodDeclaration = null; if (catelArgumentType.GetTypeElement() != null) { if (Provider.SelectedElement != null && Provider.SelectedElement.Parent is IRegularParameterDeclaration) { _parameterDeclaration = Provider.SelectedElement.Parent as IRegularParameterDeclaration; if (_parameterDeclaration.Parent != null && _parameterDeclaration.Parent != null && _parameterDeclaration.Parent.Parent is ICSharpFunctionDeclaration) { _methodDeclaration = _parameterDeclaration.Parent.Parent as ICSharpFunctionDeclaration; } } } } } return _parameterDeclaration != null && IsArgumentTypeTheExpected(_parameterDeclaration.Type) && _methodDeclaration != null && !IsArgumentChecked(_methodDeclaration, _parameterDeclaration); }
public override bool IsAvailable(IUserDataHolder cache) { callMethod = error?.Reference?.Resolve().DeclaredElement as IParametersOwner; if (callMethod == null) { return(false); } // ReSharper disable once PossibleNullReferenceException var callTreeNode = error?.Reference.GetTreeNode(); classDeclaration = callTreeNode.FindParent <IClassDeclaration>(); if (classDeclaration == null) { return(false); } // ReSharper disable once AssignNullToNotNullAttribute file = callTreeNode.GetContainingFile() as ICSharpFile; if (file == null) { return(false); } superTypes = classDeclaration.SuperTypes.SelectMany(x => x.GetAllSuperTypes()).Concat(classDeclaration.SuperTypes).ToArray(); return(superTypes.Any(x => x.GetClassType()?.Methods.Any(y => y.ShortName == "NewMock") ?? false)); }
public override bool IsApplicable(IObjectValueRole <TValue> valueRole, IMetadataTypeLite instanceType, IPresentationOptions options, IUserDataHolder dataHolder) { return(myUnityOptions.ExtensionsEnabled && instanceType.Is("UnityEditor.SerializedProperty")); }
public ImmutableSwitchExpressionNode(IQsiTreeNode parent, IQsiExpressionNode value, IQsiSwitchCaseExpressionNode[] cases, IUserDataHolder userData) { Parent = parent; Value = value; Cases = cases; UserData = userData; }
public override sealed bool IsAvailable(IUserDataHolder cache) { if (!_provider.IsValidForContractContextActions()) return false; return DoIsAvailable(); }
public ImmutableHanaDerivedTableNode( IQsiTreeNode parent, IQsiTableDirectivesNode directives, IQsiColumnsDeclarationNode columns, IQsiTableNode source, IQsiAliasNode alias, IQsiWhereExpressionNode @where, IQsiGroupingExpressionNode grouping, IQsiMultipleOrderExpressionNode order, IQsiLimitExpressionNode limit, QsiExpressionNode top, HanaResultSetOperation?operation, QsiExpressionFragmentNode sampling, HanaTableBehaviorNode behavior, QsiExpressionFragmentNode timeTravel, QsiExpressionFragmentNode hint, IUserDataHolder userData) { Parent = parent; Directives = directives; Columns = columns; Source = source; Alias = alias; Where = @where; Grouping = grouping; Order = order; Limit = limit; Top = top; Operation = operation; Sampling = sampling; Behavior = behavior; TimeTravel = timeTravel; Hint = hint; UserData = userData; }
public override bool IsAvailable(IUserDataHolder cache) { var testProjectProvider = ComponentResolver.GetComponent <ITestProjectProvider>(_dataProvider); _selectedElement = _dataProvider.GetSelectedElement <IObjectCreationExpression>(false, false); _csharpMemberProvider = ComponentResolver.GetComponent <ICsharpMemberProvider>(_dataProvider); if (!(_selectedElement?.TypeReference?.Resolve().DeclaredElement is IClass c)) { return(false); } var parameterCount = _selectedElement.ArgumentList?.Arguments.Count(x => x.Kind != ParameterKind.UNKNOWN); _constructor = c.Constructors.FirstOrDefault(x => !x.IsParameterless && x.Parameters.Count > parameterCount && x.Parameters.All(_csharpMemberProvider.IsAbstractOrInterface)); if (_constructor == null) { return(false); } var isAvailable = testProjectProvider.IsTestProject(_dataProvider.PsiModule) && _selectedElement != null && _selectedElement.Arguments.Count == 0; if (isAvailable) { cache.PutKey(AnchorKey.FillWithMockContextActionKey); } return(isAvailable); }
public override bool IsAvailable(IUserDataHolder cache) { var propertyDeclaration = myDataProvider.GetSelectedElement <IPropertyDeclaration>(); if (propertyDeclaration == null) { return(false); } if (InterfaceDeclarationNavigator.GetByPropertyDeclaration(propertyDeclaration) != null) { return(false); } if (!CSharpAutoPropertyUtil.IsPropertyHeaderSelected(propertyDeclaration, myDataProvider.SelectedTreeRange)) { return(false); } if (!CSharpAutoPropertyUtil.IsEmptyOrNotImplemented(propertyDeclaration)) { return(false); } return(IsAvailable(propertyDeclaration)); }
public override bool IsAvailable(IUserDataHolder cache) { var testProjectProvider = ComponentResolver.GetComponent <ITestProjectProvider>(_dataProvider); _parameterProvider = ComponentResolver.GetComponent <IParameterProvider>(_dataProvider); _selectedElement = _dataProvider.GetSelectedElement <IObjectCreationExpression>(false, false); _block = _dataProvider.GetSelectedElement <IBlock>(); _classBody = _dataProvider.GetSelectedElement <IClassBody>(); _classDeclaration = _classBody?.GetContainingTypeDeclaration() as IClassLikeDeclaration; if (_classDeclaration == null || _block == null || _selectedElement == null) { return(false); } if (!(_selectedElement.TypeReference?.Resolve().DeclaredElement is IClass c)) { return(false); } _parameterNumber = _selectedElement.ArgumentList.Arguments.Count(x => x.Kind != ParameterKind.UNKNOWN); _constructor = c.Constructors.ToArray().FirstOrDefault(x => !x.IsParameterless && x.Parameters.Count > _parameterNumber); if (_constructor == null) { return(false); } return(testProjectProvider.IsTestProject(_dataProvider.PsiModule)); }
private bool TryCacheDebuggerDisplay(IObjectValueRole <TValue> valueRole, IMetadataTypeLite instanceType, IUserDataHolder userDataHolder) { // If the (key) name of the reference is the same as its actual name, don't display the name in the value. // Replace with a second dictionary or whatever if we need to handle more types if (valueRole.ValueReference is CalculatedValueReferenceDecorator <TValue> reference && !reference.AllowNameInValue && instanceType.FullName == "UnityEngine.GameObject") { userDataHolder.PutData(ourDebuggerDisplayStringKey, GameObjectDebuggerDisplayStringWithoutName); return(true); } // DebuggerDisplayAttribute is inherited. This is important for applying a debug string on Behaviour, and // having it used in custom MonoBehaviour classes var current = instanceType; while (current != null) { if (myDebuggerDisplayValues.TryGetValue(current.GetGenericTypeDefinition().FullName, out var displayString)) { userDataHolder.PutData(ourDebuggerDisplayStringKey, displayString); return(true); } current = current.BaseType; } return(false); }
//Namespace.SubNamespace.PageClass = function/*{caret}*/(contentUrl) { // this._needInit = false; //}; //Namespace.SubNamespace.PageClass.prototype = { // getIsMobile: function () { // return true; // }, // getSystemSwitcher: function () { // return this._needInit; // } //} // //ITsExpressionStatement - constructor // CompoundExpression // BinaryExpression // ReferenceExpression - Namespace.SubNamespace.PageClass // ReferenceExpression - Namespace.SubNamespace // ReferenceExpression - Namespace // WhiteSpace // EqTokenElement // WhiteSpace // FunctionExpression function(contentUrl) {this._needInit = false;} // FunctionExpressionSignature function(contentUrl) // FunctionKeywordTokenElement function // Whitespace // ITsBlock // LbraceTokenElement // RbraceTokenElement //ITsExpressionStatement - prototype // CompoundExpression // BinaryExpression // ReferenceExpression // ITsObjectLiteral // ITsObjectPropertyInitializer // IPropertyNameIdentifier // WhiteSpace // Block // FunctionExpression public override bool IsAvailable(IUserDataHolder cache) { //JetBrains.ReSharper.Psi.JavaScript.Tree.ITsFunctionExpression //JetBrains.ReSharper.Psi.JavaScript.Tree.IFunctionStatement //JetBrains.ReSharper.Psi.JavaScript.Tree.ITsFunctionExpressionSignature var index = _provider.GetSelectedElement<ITsSimpleAssignmentExpression>(true, true); _indexExpression = null; _indexDeclaration = null; if (index != null && index.IsValid() && index.Source is ITsFunctionExpression && index.Dest is ITsReferenceExpression) { _indexExpression = index; _replacement = "Convert to ES6 Class"; return true; } if (index != null && index.IsValid() && index.Source is ITsObjectLiteral && index.Dest is ITsReferenceExpression) { _indexExpression = index; _replacement = "Convert to ES6 Static Class"; return true; } var indexDeclaration = _provider.GetSelectedElement<ITsFunctionStatement>(true, true); if (indexDeclaration != null && indexDeclaration.IsValid()) { _indexDeclaration = indexDeclaration; _replacement = "Convert to ES6 Class"; return true; } return false; }
public bool IsAvailable(IUserDataHolder cache) { if (!myDataProvider.Project.IsUnityProject()) { return(false); } var unityApi = myDataProvider.Solution.GetComponent <UnityApi>(); var fieldDeclaration = myDataProvider.GetSelectedElement <IFieldDeclaration>(); if (fieldDeclaration == null || !unityApi.IsSerialisedField(fieldDeclaration.DeclaredElement)) { return(false); } var existingAttribute = AttributeUtil.GetAttribute(fieldDeclaration, AttributeTypeName); if (existingAttribute != null && !IsRemoveActionAvailable) { return(false); } // Only for UnityObject types, not [Serialized] types var classDeclaration = fieldDeclaration.GetContainingTypeDeclaration(); var classElement = classDeclaration?.DeclaredElement; return(unityApi.IsDescendantOfMonoBehaviour(classElement) || unityApi.IsDescendantOfScriptableObject(classElement)); }
public override bool IsAvailable(IUserDataHolder cache) { var literal = _provider.GetSelectedElement <ILiteralExpression>(true, true); //var processor = new YC.ReSharper.AbstractAnalysis.Plugin.Core.Processor(_provider); //var parserRes = processor.Process(); //parserRes. ////var style = new TextStyle(FontStyle.Italic, Color.Aqua, Color.Bisque); ////var t = CSharpHighlightingConsumerExtension.AddHighlighting() ////t. ////ITextControl ////var t = _provider.Document. // TextControl; ////t.Document. ////var h = new TextControlMarkup.HighlighterProcessor(); ////var gg = HighlighterLayer. ////var tt = highli ////ITextControl. //Console.WriteLine(parserRes); if (literal != null && literal.IsConstantValue() && literal.ConstantValue.IsString()) { var s = literal.ConstantValue.Value as string; if (!string.IsNullOrEmpty(s)) { _stringLiteral = literal; return(true); } } return(false); }
public override bool IsAvailable(IUserDataHolder cache) { var nodeText = _nodeUnderCaret?.DeclaredName; var containsUpperCase = nodeText != null && nodeText.Any(char.IsUpper); return(containsUpperCase); }
/// <summary> /// Process clean-up on file. /// </summary> /// <param name="projectFile"> /// The project file to process. /// </param> /// <param name="rangeMarker"> /// The range marker to process. /// </param> /// <param name="profile"> /// The code cleanup settings to use. /// </param> /// <param name="progressIndicator"> /// The progress indicator. /// </param> public void Process(IPsiSourceFile projectFile, IRangeMarker rangeMarker, CodeCleanupProfile profile, IProgressIndicator progressIndicator, IUserDataHolder cache) { if (!this.IsAvailable(projectFile)) { return; } ISolution solution = projectFile.GetSolution(); ICSharpFile file = projectFile.GetDominantPsiFile <CSharpLanguage>() as ICSharpFile; if (file == null) { return; } if (!profile.GetSetting(FIX_VIOLATIONS)) { return; } var services = solution.GetPsiServices(); services.Transactions.Execute("Code cleanup", () => this.InternalProcess(projectFile.ToProjectFile(), file, profile.GetSetting(CREATE_XML_DOC_STUB))); StyleCopTrace.Out(); }
public override bool IsAvailable(IUserDataHolder cache) { var literal = _provider.GetSelectedElement<ILiteralExpression>(true, true); //var processor = new YC.ReSharper.AbstractAnalysis.Plugin.Core.Processor(_provider); //var parserRes = processor.Process(); //parserRes. ////var style = new TextStyle(FontStyle.Italic, Color.Aqua, Color.Bisque); ////var t = CSharpHighlightingConsumerExtension.AddHighlighting() ////t. ////ITextControl ////var t = _provider.Document. // TextControl; ////t.Document. ////var h = new TextControlMarkup.HighlighterProcessor(); ////var gg = HighlighterLayer. ////var tt = highli ////ITextControl. //Console.WriteLine(parserRes); if (literal != null && literal.IsConstantValue() && literal.ConstantValue.IsString()) { var s = literal.ConstantValue.Value as string; if (!string.IsNullOrEmpty(s)) { _stringLiteral = literal; return true; } } return false; }
public override bool IsAvailable(IUserDataHolder cache) { myMethodDeclaration = myProvider.GetSelectedElement<IMethodDeclaration>(true, true); if (myMethodDeclaration == null) return false; // only on non-generic methods var method = myMethodDeclaration.DeclaredElement; if (method == null || method.TypeParameters.Any()) return false; if (!method.IsStatic) { // only on non-generic types myClassDeclaration = method.GetContainingType() as IClass; if (myClassDeclaration == null || myClassDeclaration.HasTypeParameters()) return false; // with default constructor if (!myClassDeclaration.IsStatic || (!myClassDeclaration.Constructors.IsEmpty() && !myClassDeclaration.Constructors.Any(c => c.Parameters.IsEmpty()))) return false; } return !method.Parameters.Any(); }
public override bool IsAvailable(IUserDataHolder cache) { try { IMethodDeclaration method = Provider.GetSelectedElement<IMethodDeclaration>(); bool insideOfMethod = method != null; if (insideOfMethod) { bool returnsNull = ReturnsNullOrEmpty(); bool isGenericList = CorrectReturnType(method); return returnsNull && isGenericList; } return false; } catch (Exception e) { Debug.WriteLine(e.ToString()); throw; } }
public override bool IsAvailable(IUserDataHolder cache) { myClassDeclaration = myProvider.GetSelectedElement<IClassDeclaration>(true, true); // this context action is available on every class at the moment // TODO: add some constraints, like: there is already a test for this class return myClassDeclaration != null; }
public override bool IsAvailable(IUserDataHolder cache) { var parameterType = error.ParameterType; if (!parameterType.IsGenericTask()) { return(false); } var scalarType = parameterType.GetScalarType(); if (scalarType == null) { return(false); } var substitution = scalarType.GetSubstitution(); if (substitution.IsEmpty()) { return(false); } var firstGenericParameterType = substitution.Apply(substitution.Domain[0]); var argumentType = error.ArgumentType.ToIType(); if (argumentType == null) { return(false); } return(argumentType.IsSubtypeOf(firstGenericParameterType)); }
protected override bool IsApplicable(IMetadataTypeLite type, IPresentationOptions options, IUserDataHolder dataHolder) { // Check debugger type proxy settings to avoid recursion while rendering Raw View. See GetChildren return(myUnityOptions.ExtensionsEnabled && options.EvaluateDebuggerTypeProxy && type.Is("UnityEditor.SerializedProperty")); }
protected override IEnumerable <IValueEntity> GetChildren(IObjectValueRole <TValue> valueRole, IMetadataTypeLite instanceType, IPresentationOptions options, IUserDataHolder dataHolder, CancellationToken token) { yield return(new ChildrenGroup(valueRole, ValueServices, myLogger)); }
public ImmutableColumnsDeclarationNode(IQsiTreeNode parent, IQsiColumnNode[] columns, IUserDataHolder userData) { Parent = parent; Count = columns?.Length ?? 0; Columns = columns; IsEmpty = Count == 0; UserData = userData; }
public override bool IsApplicable(IObjectValueRole <TValue> valueRole, IMetadataTypeLite instanceType, IPresentationOptions options, IUserDataHolder dataHolder) { // Note that DebuggerDisplayObjectPresenter checks options.AllowTargetInvoke here return(myUnityOptions.ExtensionsEnabled && options.AllowDebuggerDisplayEvaluation && TryCacheDebuggerDisplay(valueRole, instanceType.GetGenericTypeDefinition(), dataHolder)); }
public override bool IsAvailable(IUserDataHolder cache) { var returnType = error.ReturnType; var valueType = error.ValueType.ToIType(); return(returnType.IsGenericTaskOf(valueType)); }
public ImmutableColumnExpressionNode( IQsiTreeNode parent, IQsiColumnNode column, IUserDataHolder userData) { Parent = parent; Column = column; UserData = userData; }
public ImmutableWhereExpressionNode( IQsiTreeNode parent, IQsiExpressionNode expression, IUserDataHolder userData) { Parent = parent; Expression = expression; UserData = userData; }
public ImmutableTableReferenceNode( IQsiTreeNode parent, QsiQualifiedIdentifier identifier, IUserDataHolder userData) { Parent = parent; Identifier = identifier; UserData = userData; }
public virtual bool IsAvailable(IUserDataHolder cache) { var parameterDeclaration = FindParameterDeclaration(); if (parameterDeclaration == null || !parameterDeclaration.Language.IsLanguage(Language)) return false; Context.Initialize(parameterDeclaration); if (!Context.IsValid) return false; return !HasNamingConflicts(Context.Constructor.GetContainingType(), Context.SuggestedPropertyName); }
public override bool IsAvailable(IUserDataHolder cache) { var testProjectProvider = ComponentResolver.GetComponent <ITestProjectProvider>(_dataProvider); _selectedElement = _dataProvider.GetSelectedElement <IObjectCreationExpression>(false, false); _parameterProvider = ComponentResolver.GetComponent <IParameterProvider>(_dataProvider); return(testProjectProvider.IsTestProject(_dataProvider.PsiModule) && _selectedElement != null && _selectedElement.Arguments.Count == 0); }
public override bool IsAvailable(IUserDataHolder cache) { if (_range == null || !ValidUtils.Valid(_range.First) || !ValidUtils.Valid(_range.Last)) return false; var treeRange = AdjustTreeRange(_range); if (treeRange != null) return treeRange.First.Parent == treeRange.Last.Parent; return false; }
public ImmutableChangeSearchPathActionNode( IQsiTreeNode parent, QsiIdentifier[] identifiers, IUserDataHolder userData) { Parent = parent; Identifiers = identifiers; UserData = userData; }
public bool IsAvailable(IUserDataHolder cache) { if (!myWarning.Argument.IsValid()) { return(false); } return(GetEditorBuildSettings(GetUnityModule(myWarning.Argument.GetSolution())) != null); }
public override bool IsAvailable(IUserDataHolder cache) { var topLevelNode = myProvider.GetTopLevelNode(); if (topLevelNode == null) return false; myChainedInvocation = FindInvocationChain(topLevelNode); return myChainedInvocation != null; }
public ImmutableMultipleOrderExpressionNode( IQsiTreeNode parent, IQsiOrderExpressionNode[] orders, IUserDataHolder userData) { Parent = parent; Orders = orders; UserData = userData; }
public bool IsAvailable(IUserDataHolder cache) { return(_myReferenceExpression != null && _anchor != null && !IsInvocationExpression(_myReferenceExpression) && !InsideConstantExpression && IsUnqualifiedExpression && IsUnresolvedOrWrongNameCase()); }
public override bool IsAvailable(IUserDataHolder cache) { using (ReadLockCookie.Create()) { this._selectedDocCommentNode = GetSelectedExpression <IDocCommentNode>(); return(this._selectedDocCommentNode != null); } }
public ImmutableMultipleExpressionNode( IQsiTreeNode parent, IQsiExpressionNode[] elements, IUserDataHolder userData) { Parent = parent; Elements = elements; UserData = userData; }
public override sealed bool IsAvailable(IUserDataHolder cache) { if (!_provider.IsValidForContractContextActions()) { return(false); } return(DoIsAvailable()); }
public override bool IsAvailable(IUserDataHolder cache) { // Quick fix should be available only for exceptions, declared in the same project. // I.e. fix would be unavailable for internal exeptions visible because of InternalVisibleTo var project = _highlighting.PreconditionContainer.DeclaredElement .With(x => x.GetContainingType()) .With(x => x.GetSingleOrDefaultSourceFile()) .With(x => x.GetProject()); var exceptionProject = _highlighting.ExceptionClass .With(x => x.GetDeclarations().FirstOrDefault()) .With(x => x.GetProject()); // Fix is available only when exception declared in the same project!! if (project == null || exceptionProject == null || project.Guid != exceptionProject.Guid) return false; var exceptionDeclaration = (IClassDeclaration) _highlighting.ExceptionClass.GetDeclarations().FirstOrDefault(); if (exceptionDeclaration == null) return false; // TODO: terrible approach, but can't find better! using (var workflow = GeneratorWorkflowFactory.CreateWorkflowWithoutTextControl( GeneratorStandardKinds.Constructor, exceptionDeclaration, exceptionDeclaration)) { Contract.Assert(workflow != null); var ctors = workflow.Context.ProvidedElements .OfType<GeneratorDeclaredElement<IConstructor>>() .Select(c => c.DeclaredElement) .ToList(); // TODO: refine me later!! if (ctors.Any(ContractUtils.HasTwoStringArgument)) { _missedConstructorPredicate = ContractUtils.HasTwoStringArgument; _missedConstructor = "ctor(string, string)"; return true; } if (ctors.Any(ContractUtils.HasOneStringArgument)) { _missedConstructorPredicate = ContractUtils.HasOneStringArgument; _missedConstructor = "ctor(string)"; return true; } return false; } }
public override bool IsAvailable(IUserDataHolder cache) { var isAvailable = base.IsAvailable(cache); if (isAvailable) { cache.PutData(InstanceKey, this); } return(isAvailable); }
public override bool IsAvailable(IUserDataHolder cache) { return myReference .If(x => x.IsValid()) .With(x => x.GetTreeNode() as ICSharpArgument) .If(x => x.Value is ICSharpLiteralExpression) .With(x => x.MatchingParameter) .With(x => x.Element) .With(x => myReference.GetReferenceSymbolTable(false).Names().Any()); }
public override bool IsAvailable(IUserDataHolder cache) { var index = _provider.GetSelectedElement<IIndexExpression>(true, true); if (index != null && index.IsValid() && index.AccessedPropertyName != null) { _indexExpression = index; _replacement = string.Format("{0}.{1}", index.IndexedExpression.GetText(), index.AccessedPropertyName); return true; } return false; }
public sealed override bool IsAvailable(IUserDataHolder cache) { myOuterInvocation = null; myExistingLambdaParameterName = null; var topLevelNode = myProvider.GetTopLevelNode(); if (topLevelNode == null) return false; myOuterInvocation = FindChain(topLevelNode); return myOuterInvocation != null; }
//angular.controller("UserProfileCtrl", function ($scope, mainFormModel, dataAccess) { // $scope.logout = function () {} //}); // //ExpressionStatement // CompaundExpression // ITsInvocationExpression //angular.controller(...) // ITsReferenceExpression //angular.controller // ITsLiteralExpression //"UserProfileCtrl" // FunctionExpression <OR ITsArrayLiteral> //function ($scope, mainFormModel, dataAccess) {...} // FunctionExpressionSignature // ParametersList ($scope, mainFormModel, dataAccess) // ITsBlock // LbraceTokenElement // ExpressionStatement //FOR-EACH // CompaundExpression // ITsSimpleAssignmentExpression // ITsReferenceExpression //$scope.changeUserProfile // FunctionExpression //function (profileId) {} // ITsFunctionStatementSignature // ITsBlock // RbraceTokenElement //angular.controller("UserProfileCtrl", ["$scope", "mainFormModel", "dataAccess", function ($scope, mainFormModel, dataAccess) { // $scope.logout = function () { // AppConnection.logout().done(function () { // window.location.href = "logout.html"; // }); // } // } //]); // ITsArrayLiteral // ITsLiteralExpression //FOR-EACH // FunctionExpression //function ($scope, mainFormModel, dataAccess) {...} public override bool IsAvailable(IUserDataHolder cache) { var index = _provider.GetSelectedElement<ITsReferenceExpression>(true, true); if (index != null && index.IsValid() && index.GetText().EndsWith(".controller") && index.Parent is ITsInvocationExpression) { _indexInvocation = index.Parent as ITsInvocationExpression; _replacement = "Convert NG Controller to ES6 Class"; return true; } return false; }
public override bool IsAvailable(IUserDataHolder cache) { using (ReadLockCookie.Create()) { _selectedExpression = GetSelectedExpression(); if (_selectedExpression != null) return !IsConstantExpression(_selectedExpression) && IsIntMaxValue(_selectedExpression); return false; } }
//(function ($scope, mainFormModel, dataAccess) { // $scope.logout = function () {} // var f1 = function() { } // var f_private = function() { } // var dataService = { // f1: f1, // f2:f2 // }; // return dataService; // // function f2() { f_private();} //})(window['$scope'], window['mainFormModel'], window['dataAccess']); // //ExpressionStatement // CompaundExpression // ITsInvocationExpression //angular.controller(...) // ITsReferenceExpression //angular.controller // ITsLiteralExpression //"UserProfileCtrl" // FunctionExpression <OR ITsArrayLiteral> //function ($scope, mainFormModel, dataAccess) {...} // FunctionExpressionSignature // ParametersList ($scope, mainFormModel, dataAccess) // ITsBlock // LbraceTokenElement // ExpressionStatement //FOR-EACH // CompaundExpression // ITsSimpleAssignmentExpression // ITsReferenceExpression //$scope.changeUserProfile // FunctionExpression //function (profileId) {} // ITsFunctionStatementSignature // ITsBlock // RbraceTokenElement public override bool IsAvailable(IUserDataHolder cache) { var index = _provider.GetSelectedElement<ITsFunctionExpression>(true, true); if (index != null && index.IsValid()) { _index = index; _replacement = "Convert Closure to ES6 Class"; return true; } return false; }
public bool IsAvailable(IUserDataHolder cache) { var item = _provider.GetSelectedElement<IArgument>(false, false); if (item == null) return false; var owner = item.GetContainingNode<IArgumentsOwner>(); if (owner == null) return false; var ownerOfOwner = owner.GetContainingNode<IArgumentsOwner>(); if (ownerOfOwner == null) return false; var invocation = ownerOfOwner as IInvocationExpression; if (invocation == null || invocation.Reference == null) return false; switch (invocation.Reference.GetName()) { case "Stub": case "AssertWasCalled": case "AssertWasNotCalled": break; default: return false; } if (item.Expression is IInvocationExpression) { var argInvocation = (IInvocationExpression)item.Expression; var expression = argInvocation.InvokedExpression as IReferenceExpression; if (expression != null) { var qualifier = expression.QualifierExpression as IReferenceExpression; if (qualifier != null && qualifier.GetText().StartsWith("Arg<")) return false; return true; } } if (item.Expression is IReferenceExpression) { var refExpression = (IReferenceExpression)item.Expression; var qualifier = refExpression.QualifierExpression as IReferenceExpression; if (qualifier != null && qualifier.GetText().StartsWith("Arg<")) return false; } return true; }
public bool IsAvailable(IUserDataHolder cache) { var literal = _provider.GetSelectedElement<ILiteralExpression>(true, true); if (literal != null && literal.IsConstantValue() && literal.ConstantValue.IsString()) { var s = literal.ConstantValue.Value as string; if (!string.IsNullOrEmpty(s)) { _stringLiteral = literal; return true; } } return false; }
public bool IsAvailable(IUserDataHolder cache) { var item = _provider.GetSelectedElement<IMethodDeclaration>(false, true); if (item != null) { var accessRights = item.GetAccessRights(); if (accessRights == AccessRights.PUBLIC && !item.IsStatic && !item.IsVirtual && !item.IsOverride) { return true; } } return false; }
public override bool IsAvailable(IUserDataHolder cache) { if (_highlighing.ReferingFieldOrProperty == null) { _generateProperty = true; return true; } // Let's disable quick fix for fields. It sounds crazy to fix visibility of one field instead of another! if (_highlighing.ReferingFieldOrProperty is IFieldDeclaration) return false; _changeVisibility = true; return true; }
public override bool IsAvailable(IUserDataHolder cache) { var reference = _provider.GetSelectedElement<IReferenceExpression>(true, true); if (reference != null && reference.IsValid()) { var qualifier = reference.Qualifier; var nameIdentifier = reference.NameIdentifier; if (qualifier != null && nameIdentifier != null) { _referenceExpression = reference; _replacement = string.Format("{0}['{1}']", qualifier.GetText(), nameIdentifier.GetText()); return true; } } return false; }
/// <summary>The is available.</summary> /// <param name="cache">The cache.</param> /// <returns>The <see cref="bool"/>.</returns> public override bool IsAvailable(IUserDataHolder cache) { var literal = this.provider.GetSelectedElement<ILiteralExpression>(true, true); if (literal == null || !literal.IsConstantValue() || !literal.ConstantValue.IsString()) { return false; } if (ActiveContext.ActiveContentTree == null) { return false; } var text = literal.ConstantValue.Value as string; if (string.IsNullOrEmpty(text)) { return false; } if (!text.StartsWith("{")) { return false; } Guid guid; if (!Guid.TryParse(text, out guid)) { return false; } var project = this.provider.GetProject(); if (project == null) { return false; } var site = project.Site; if (site == null) { return false; } this.Site = site; this.Guid = guid; return true; }
public override bool IsAvailable(IUserDataHolder cache) { using (ReadLockCookie.Create()) { if (Provider.SelectedElement != null) { _superType = TypeHelper.CreateTypeByCLRName(SuperTypeName, Provider.PsiModule, Provider.SelectedElement.GetResolveContext()); if (_superType.GetTypeElement() != null) { _classDeclaration = Provider.SelectedElement.Parent as IClassDeclaration; } } } // !_classDeclaration.IsStatic doesn't work, IsStatic is returns true return _classDeclaration != null && !_classDeclaration.IsStaticEx() && _classDeclaration.SuperTypes.IsEmpty(); }
public bool IsAvailable(IUserDataHolder cache) { _propertyAssignment = null; _dllImportAttribute = null; Func<IAttribute, bool> isDllImportAttribute = a => { var typeReference = a.TypeReference; if (typeReference != null) { var typeElement = typeReference.Resolve().DeclaredElement as ITypeElement; if (typeElement != null && Equals(typeElement.GetClrName(), DllImportMissingAnalyzer.DllImportAttribute)) { return true; } } return false; }; var method = _provider.GetSelectedElement<IMethodDeclaration>(true, true); if (method == null) { return false; } var attribute = method.Attributes.FirstOrDefault(isDllImportAttribute); if (attribute == null || !attribute.IsValid()) { return false; } _dllImportAttribute = attribute; var entryPoint = attribute.PropertyAssignments.FirstOrDefault(pa => pa.PropertyNameIdentifier.Name == "EntryPoint"); if (entryPoint == null) { return true; } _propertyAssignment = entryPoint; var literal = entryPoint.Source as ICSharpLiteralExpression; if (literal != null) { if (!literal.IsConstantValue()) { return true; } var value = literal.ConstantValue.Value as string; return value != method.NameIdentifier.Name; } return false; }
public override bool IsAvailable(IUserDataHolder cache) { var selection = myProvider.DocumentSelection.TextRange; if (!DocumentHelper.IsWholeStatementRangeSelected(selection, myProvider.Document)) return false; var block = myProvider.GetSelectedElement<IBlock>(); var statementsRange = block?.GetStatementsRange(myProvider.SelectedTreeRange); if (statementsRange == null || statementsRange.Statements.Count < 2) return false; var statements = statementsRange.Statements; if (!AreDeclarationsBeforeLastStatement(statements)) return false; if (!AreDeclarationsFollowPattern(statements)) return false; if (!IsNoOtherVariableReferences(statements, block)) return false; return true; }
/// <summary>The is available.</summary> /// <param name="cache">The cache.</param> /// <returns>The <see cref="bool"/>.</returns> public override bool IsAvailable(IUserDataHolder cache) { this.InvocationExpression = null; var invocationExpression = this.provider.GetSelectedElement<IInvocationExpression>(true, true); if (invocationExpression == null) { return false; } var referenceExpression = invocationExpression.InvokedExpression as IReferenceExpression; if (referenceExpression == null) { return false; } var declaredElement = referenceExpression.Reference.Resolve().DeclaredElement; if (declaredElement == null) { return false; } if (declaredElement.ShortName != "GetItem") { return false; } var containingType = this.GetContainingTypeName(declaredElement); if (containingType == null) { return false; } if (containingType != "Sitecore.Data.Database") { return false; } this.InvocationExpression = invocationExpression; return true; }
/// <summary> /// Determines whether the specified action is available for execution. /// </summary> /// <param name="cache">Ignored.</param> public override bool IsAvailable(IUserDataHolder cache) { // Check that the caret is within method declaration var methodDeclaration = _provider.GetSelectedElement<IMethodDeclaration>(true, true); if (null == methodDeclaration) return false; // Check that the caret is exactly on the method name ITreeNode selectedElement = _provider.SelectedElement; if (null == selectedElement) return false; if (!methodDeclaration.GetNameDocumentRange().Contains(selectedElement.GetDocumentRange())) return false; // Cache method declaration for reuse in the execute method _methodDeclaration = methodDeclaration; return true; }
public override bool IsAvailable(IUserDataHolder cache) { // Quick fix should be available only for exceptions, declared in the same project. // I.e. fix would be unavailable for internal exeptions visible because of InternalVisibleTo var project = _highlighting.PreconditionContainer.DeclaredElement .With(x => x.GetContainingType()) .With(x => x.GetSingleOrDefaultSourceFile()) .With(x => x.GetProject()); var exceptionProject = _highlighting.ExceptionClass .With(x => x.GetDeclarations().FirstOrDefault()) .With(x => x.GetProject()); if (project == null || exceptionProject == null) return false; return project.Guid == exceptionProject.Guid; }