本文整理汇总了C#中EnvDTE.CreateEditPoint方法的典型用法代码示例。如果您正苦于以下问题:C# EnvDTE.CreateEditPoint方法的具体用法?C# EnvDTE.CreateEditPoint怎么用?C# EnvDTE.CreateEditPoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EnvDTE
的用法示例。
在下文中一共展示了EnvDTE.CreateEditPoint方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetBlockContainingPoint
/**
* Determines if a block contains the given point, and is fo returns the
* CommentBlock and MatchedBlockData for the match.
*/
public static bool GetBlockContainingPoint(
ParameterSet pset,
string fileName,
EnvDTE.TextPoint pt,
out CommentBlock retblock,
out MatchedBlockData bdata)
{
retblock = null;
bdata = new MatchedBlockData();
bdata.mEndLine = 0;
bdata.mStartLine = 0;
bdata.mIndentation = 0;
EnvDTE.EditPoint ep = pt.CreateEditPoint();
EnvDTE.EditPoint enddoc = pt.CreateEditPoint();
enddoc.EndOfDocument();
string line = GetUntabbedLine(enddoc,ep.Line);
foreach (CommentBlock block in pset.getBlocksForFileName(fileName))
{
if (block.lineHasBlockPattern(line,out bdata.mIndentation))
{
int currentLineNumber = ep.Line;
// scan up for block start
bool foundStart = false;
for ( ;currentLineNumber >= 1; currentLineNumber--)
{
string currentLine = GetUntabbedLine(enddoc, currentLineNumber);
string previousLine = GetUntabbedLine(enddoc, currentLineNumber-1);
string nextLine = GetUntabbedLine(enddoc, currentLineNumber+1);
if (block.lineIsStartOfBlock(currentLine,
previousLine,
bdata.mIndentation,
out bdata.mMatchedBlockStart,
out bdata.mSpacesTrimmedOffBlockStart))
{
bdata.mStartLine = currentLineNumber;
foundStart = true;
break;
}
else if (!block.lineIsBlockContinuation(currentLine,bdata.mIndentation) &&
!block.lineIsEndOfBlock(currentLine,nextLine,bdata.mIndentation,out bdata.mMatchedBlockEnd))
{
break;
}
}
if (foundStart)
{
bool foundEnd = false;
for ( ; currentLineNumber <= enddoc.Line ; currentLineNumber++)
{
string currentLine = GetUntabbedLine(enddoc, currentLineNumber);
string nextLine = GetUntabbedLine(enddoc, currentLineNumber+1);
if (block.lineIsEndOfBlock(currentLine, nextLine,bdata.mIndentation,out bdata.mMatchedBlockEnd))
{
bdata.mEndLine = currentLineNumber;
foundEnd = true;
break;
}
else if ((currentLineNumber != bdata.mStartLine) &&
(!block.lineIsBlockContinuation(currentLine,bdata.mIndentation)))
{
break;
}
}
if (foundEnd)
{
retblock = block;
return true;
}
// else try next block
}
// else try next block
}
}
return false;
}
示例2: WrapBlock
private static void WrapBlock(
ParameterSet pset,
CommentBlock block,
MatchedBlockData bdata,
EnvDTE.TextPoint pt)
{
int blockTabSize = pt.Parent.TabSize;
if (!pset.mUseTabsToIndent)
{
blockTabSize = 0;
}
bool isInPreformmatedBlock = false;
bool isLastLine = false;
bool isStartOnSeparateLine = false;
EnvDTE.EditPoint curPoint = pt.CreateEditPoint();
curPoint.MoveToLineAndOffset(bdata.mStartLine,1);
// seems we have to pick the reight line ending ourselves
string eol = "\r\n";
if (curPoint.GetText(-1).Length == 1)
{
eol = "\n";
}
EnvDTE.EditPoint endPoint = pt.CreateEditPoint();
endPoint.MoveToLineAndOffset(bdata.mEndLine,1);
if ((block.mBlockEndType == StartEndBlockType.OnOwnLineIfBlockIsMoreThanOne) ||
(block.mBlockEndType == StartEndBlockType.NeverOnOwnLine))
{
// delete the end block string
endPoint.StartOfLine();
SkipColumns(endPoint, bdata.mIndentation);
if (GetTextOnLine(endPoint, bdata.mMatchedBlockEnd.Length) == bdata.mMatchedBlockEnd)
{
// delete the whole line
endPoint.EndOfLine();
EnvDTE.EditPoint secondLastLinePoint = endPoint.CreateEditPoint();
secondLastLinePoint.LineUp(1);
secondLastLinePoint.EndOfLine();
secondLastLinePoint.Delete(endPoint);
}
else
{
// delete just the string
EnvDTE.EditPoint eolPoint = endPoint.CreateEditPoint();
eolPoint.EndOfLine();
int endOffset = endPoint.GetText(eolPoint).LastIndexOf(bdata.mMatchedBlockEnd);
endPoint.CharRight(endOffset);
endPoint.Delete(eolPoint);
}
}
else if (block.mBlockEndType == StartEndBlockType.AlwaysOnOwnLine)
{
// just move up al line as there is nothing interesting on it
endPoint.LineUp(1);
}
endPoint.EndOfLine();
// now loop down the lines
while (!isLastLine)
{
if (curPoint.Line >= endPoint.Line)
{
isLastLine = true;
}
curPoint.StartOfLine();
if ((curPoint.Line == bdata.mStartLine) &&
(block.mBlockStartType == StartEndBlockType.AlwaysOnOwnLine))
{
curPoint.LineDown(1);// simply go to the next line
continue;
}
else if ((curPoint.Line == bdata.mStartLine) &&
(block.mBlockStartType == StartEndBlockType.NeverOnOwnLine))
{
SkipColumns(curPoint, bdata.mIndentation);
SkipString(curPoint, bdata.mMatchedBlockStart);
}
else if ((curPoint.Line == bdata.mStartLine) &&
(block.mBlockStartType == StartEndBlockType.OnOwnLineIfBlockIsMoreThanOne))
{
// we will automatically pull up the next line if we can. We
// also haqndle the case where traling spaces from the block
// start have been removed
SkipColumns(curPoint, bdata.mIndentation);
SkipString(curPoint, bdata.mMatchedBlockStart);
if ((!AtLineEndIgnoringWhiteSpace(curPoint)) || isLastLine)
{
isStartOnSeparateLine = false;
}
else if (LineJustContainsContinuation(curPoint.Line+1,bdata.mIndentation,block.mLineStart, pset, pt))
{
isStartOnSeparateLine = true;
}
else
//.........这里部分代码省略.........
示例3: LineJustContainsContinuation
private static bool LineJustContainsContinuation(
int lineNum,
int indentation,
string lineStart,
ParameterSet pset,
EnvDTE.TextPoint pt)
{
EnvDTE.EditPoint temp = pt.CreateEditPoint();
temp.MoveToLineAndOffset(lineNum,1);
SkipColumns(temp, indentation);
SkipString(temp, lineStart.TrimEnd());// note the trim here, which
// allows the match of blank
// lines
return AtLineEndIgnoringWhiteSpace(temp) ||
pset.matchesBreakFlowString(GetRestOfLine(temp),false) ||
pset.matchesBulletPoint(GetRestOfLine(temp));
}
示例4: AtLineEndIgnoringWhiteSpace
private static bool AtLineEndIgnoringWhiteSpace(
EnvDTE.EditPoint pt)
{
EnvDTE.EditPoint temp = pt.CreateEditPoint();
while ((!temp.AtEndOfLine) &&
((temp.GetText(1) == " ") ||
(temp.GetText(1) == "\t")))
{
temp.CharRight(1);
}
return temp.AtEndOfLine;
}
示例5: WrapAllBlocksInSelection
/**
* Wraps all blocks that have any part between the two given text points
* Returns if any blocks found.
*/
public static bool WrapAllBlocksInSelection(
ParameterSet pset,
string fileName,
EnvDTE.TextPoint selectionStart,
EnvDTE.TextPoint selectionEnd)
{
bool blockFound = false;
EnvDTE.EditPoint selStart = selectionStart.CreateEditPoint();
selStart.StartOfLine();
while (selStart.LessThan(selectionEnd))
{
CommentBlock block;
MatchedBlockData bdata;
if (GetBlockContainingPoint(pset,
fileName,
selStart,
out block,
out bdata))
{
blockFound = true;
selStart.LineDown((bdata.mEndLine-bdata.mStartLine)+1);
WrapBlock(pset,block,bdata,selectionStart);
}
else
{
selStart.LineDown(1);
}
}
return blockFound;
}
示例6: go
public static bool go(
EnvDTE.TextPoint searchPt,
out EnvDTE.EditPoint finishPt
/*,
bool pullupIfLineShortEnough,
int lengthToPutOnOneLine,
bool forceOneParamPerLine,
bool recurseOnSubCalls*/)
{
finishPt = null;
EnvDTE.EditPoint curPt = searchPt.CreateEditPoint();
// search right first for bracket
// FIXME: "(" can't be in a string
if ((curPt.GetText(1) != " ") && (curPt.GetText(1) != "\t"))
{
while ((!curPt.AtEndOfLine) && (curPt.GetText(1) != "("))
{
curPt.CharRight(1);
}
}
// now try back left if right did not succeed
// FIXME: ";" and "(" can't be in a string
if ((curPt.GetText(1) != "("))
{
curPt = searchPt.CreateEditPoint();
while ((!curPt.AtStartOfDocument) &&
(curPt.GetText(1) != ";") &&
(curPt.GetText(1) != "("))
{
curPt.CharLeft(1);
}
}
// if no bracket then fail
if (curPt.GetText(1) != "(")
{
return false;
}
curPt.CharRight(1);
// Fixed 23 Mar 2010: skip whitespace between "(" and first char
while ((curPt.GetText(1) == " ") ||
(curPt.GetText(1) == "\t")) {
curPt.CharRight(1);
}
int indentPoint = curPt.LineCharOffset;
bool isFirstLineOfParameter = false;// note this is processed at the
// start of the next line, so
// unless the first line finishes
// with a comma then the second
// will not be the first line of
// a parameter.
int lineShiftRight = 0;
bool inCBlockComment = false;
bool inCppBlockComment = false;
bool done = false;
while (!done)
{
// skip any whitespace on the current line
while ((curPt.GetText(1) == " ") ||
(curPt.GetText(1) == "\t"))
{
curPt.CharRight(1);
}
if (curPt.AtEndOfDocument)
{
throw new System.ArgumentException("Unexpected eod processing parameters");
}
else if (curPt.AtEndOfLine)
{
curPt.LineDown(1);
curPt.StartOfLine();
while ((curPt.GetText(1) == " ") ||
(curPt.GetText(1) == "\t"))
{
curPt.CharRight(1);
}
if (curPt.AtEndOfLine)
{
continue;
}
if ((inCppBlockComment) && (curPt.GetText(2) != "//"))
{
inCppBlockComment = false;
isFirstLineOfParameter = true;
}
if (isFirstLineOfParameter)
{
lineShiftRight = indentPoint - curPt.LineCharOffset;
}
isFirstLineOfParameter = false;
// delete or insert spaces to meet indentation
int finalPosition = curPt.LineCharOffset + lineShiftRight;
while (curPt.LineCharOffset > finalPosition)
//.........这里部分代码省略.........