PowerShell을 사용하여 bSpell 맞춤법 검사의 현재 잘못된 줄에 대한 Checkstyle 소스 파일 내용을 캡처합니다.

2629 단어 powershell

== ps1 ==
function go{
    $gbk = [System.Text.Encoding]::GetEncoding("GBK")
    $utf8 = [System.Text.Encoding]::UTF8

    $result = 'spell-filter.txt'
    $encoding = [System.Text.Encoding]::GetEncoding("GBK")
    rm $result -ea SilentlyContinue
    $xml = cat checkstyle.xml
    $xml = [xml]$xml  #  
    $xml.checkstyle.file|%{$_.error}|?{$_.source -match 'SpellCheck'}|
    %{
      $fileContent = cat $_.parentNode.name -total $_.line -ea SilentlyContinue #  , 【 】
      $word = (($_.message -replace 'The Spelling of word ', '') -replace 'may be illegal. .*', '') #  

      if ($fileContent -ne $Null){
        $code = $gbk.GetBytes($fileContent[-1]) #  
        $code = $utf8.GetString($code)
        ' : ' + $_.parentNode.name + ' , :' + $_.line + ' , :' +  $word + ' , :' + $code>> $result
      }else{
        ' : ' + $_.parentNode.name + ' , ' + $_.line + ' , ' +  $word 
      }
    }
}

go

== checkstyle.xml ==
<?xml version="1.0" encoding="UTF-8"?>
<checkstyle version="5.0">
<file name="package_zh_CN.properties">
<error line="114" column="81" severity="error" message="The Spelling of word &quot;pageing&quot; may be illegal. The suggestion(s) include(s): [paging, ageing, panging, pugging, pegging]" source="SpellCheck"/>
<error line="117" column="84" severity="error" message="The Spelling of word &quot;pageing&quot; may be illegal. The suggestion(s) include(s): [paging, ageing, panging, pugging, pegging]" source="SpellCheck"/>
</file>
<file name="addOrDel.js">
<error line="1" severity="info" message="File length is 2,373 lines (max allowed is 2,000)." source="com.puppycrawl.tools.checkstyle.checks.sizes.FileLengthCheck"/>
</file>
<file name="showDataDictDetail.jsp">
<error line="10" column="19" severity="error" message="The Spelling of word &quot;stylesheet&quot; may be illegal. The suggestion(s) include(s): [StyleSheet]" source="SpellCheck"/>
</file>
</checkstyle>











좋은 웹페이지 즐겨찾기