public override T VisitInclude(BoundIncludeEx x) { // check arguments return(base.VisitRoutineCall(x)); // do not check the TargetMethod }
public override T VisitInclude(BoundIncludeEx x) { // check arguments base.VisitRoutineCall(x); // check the target was not resolved if (x.TargetMethod == null) { foreach (var arg in x.ArgumentsInSourceOrder) { // in case the include is in form (__DIR__ . LITERAL) // it should get resolved if (arg.Value is BoundConcatEx concat && concat.ArgumentsInSourceOrder.Length == 2 && concat.ArgumentsInSourceOrder[0].Value is BoundPseudoConst pc && pc.ConstType == PseudoConstUse.Types.Dir && concat.ArgumentsInSourceOrder[1].Value.ConstantValue.TryConvertToString(out var relativePath) && relativePath.Length != 0) { // WARNING: Script file '{0}' could not be resolved if (_routine != null) { relativePath = PhpFileUtilities.NormalizeSlashes(_routine.ContainingFile.DirectoryRelativePath + relativePath); if (Roslyn.Utilities.PathUtilities.IsAnyDirectorySeparator(relativePath[0])) { relativePath = relativePath.Substring(1); // trim leading slash } _diagnostics.Add(_routine, concat.PhpSyntax ?? x.PhpSyntax, ErrorCode.WRN_CannotIncludeFile, relativePath); } } } } // return default; }
public override object VisitInclude(BoundIncludeEx x) { return(x.Update( (BoundExpression)Accept(x.ArgumentsInSourceOrder[0].Value), x.InclusionType)); }