Example #1
0
		void FixIndentationForceNewLine(AstNode node)
		{
			var directive = node as PreProcessorDirective;
			if (node.GetPrevNode () is NewLineNode) {
				if (directive != null && !policy.IndentPreprocessorDirectives) {
					var startNode = node.GetPrevNode ();
					var startOffset = document.GetOffset(startNode.EndLocation);
					int endOffset = document.GetOffset(node.StartLocation);
					AddChange(startOffset, endOffset - startOffset, "");
					return;
				} else {
					FixIndentation(node);
				}
			} else {
				// if no new line preceeds an #endif directive it's excluded
				if (directive != null) {
					if (directive.Type == PreProcessorDirectiveType.Endif)
						return;
				}
				var startNode = node.GetPrevSibling(n => !(n is WhitespaceNode)) ?? node;
				var startOffset = document.GetOffset(startNode.EndLocation);
				int endOffset = document.GetOffset(node.StartLocation);
				if (startOffset >= endOffset)
					return;
				if (directive != null && !policy.IndentPreprocessorDirectives) {
					AddChange(startOffset, endOffset - startOffset, "");
					return;
				}

				AddChange(startOffset, endOffset - startOffset, curIndent.IndentString);
			}
		}