[ooo-build-commit] ooeclipse: Branch 'master'

Cédric Bosdonnat cbosdo at kemper.freedesktop.org
Mon Sep 13 01:05:37 PDT 2010


 core/source/org/openoffice/ide/eclipse/core/builders/IdlcErrorReader.java        |  102 +++++-----
 core/source/org/openoffice/ide/eclipse/core/editors/idl/UnoidlConfiguration.java |   32 ++-
 core/source/org/openoffice/ide/eclipse/core/internal/model/UnoidlProject.java    |    2 
 3 files changed, 78 insertions(+), 58 deletions(-)

New commits:
commit e5a7e65ea5675b78124b306d4fd036bdae7c4f42
Author: Cédric Bosdonnat <cedricbosdo at openoffice.org>
Date:   Mon Sep 13 10:02:33 2010 +0200

    Error markers in idl editor use idlc offset values
    
     * Use the characters offset introduced by go-oo idlc-error-offset.diff
     * Fix the project-level marker definition at startup
     * Added annotation hovers to idl editor

diff --git a/core/source/org/openoffice/ide/eclipse/core/builders/IdlcErrorReader.java b/core/source/org/openoffice/ide/eclipse/core/builders/IdlcErrorReader.java
index 707d2c1..8311dae 100755
--- a/core/source/org/openoffice/ide/eclipse/core/builders/IdlcErrorReader.java
+++ b/core/source/org/openoffice/ide/eclipse/core/builders/IdlcErrorReader.java
@@ -47,8 +47,6 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.LineNumberReader;
-import java.util.HashMap;
-import java.util.Map;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
@@ -78,12 +76,16 @@ public class IdlcErrorReader {
     /**
      * Syntax error expression.
      *  
-     * <p><em>&lt;file&gt; (&lt;line number&gt;) : &lt;message&gt;</em></p>
+     * <p><em>&lt;file&gt;:&lt;line number&gt; [&lt;offsetStart&gt;,&lt;offsetEnd&gt;] : &lt;message&gt;</em></p>
      */
-    private static final String R_IDLC_ERROR  = "(.*)\\(([0-9]+)\\) : (WARNING, )?(.*)"; //$NON-NLS-1$
-
-    private static final int IDLC_ERROR_MESSAGE_GROUP = 3;
+    private static final String R_IDLC_ERROR  = "(.*):([0-9]+) \\[([0-9]+):([0-9]+)\\] :" +
+        " (WARNING, )?(.*)"; //$NON-NLS-1$
 
+    private static final int IDLC_ERROR_LINE_GROUP = 2;
+    private static final int IDLC_ERROR_OFFSET_START_GROUP = 3;
+    private static final int IDLC_ERROR_OFFSET_END_GROUP = 4;
+    private static final int IDLC_ERROR_MESSAGE_GROUP = 5;
+    
     private static final int IDLCPP_INCLUDE_PATH_GROUP = 4;
 
     private static final int IDLCPP_OPTIONAL_GROUP = 3;
@@ -136,11 +138,7 @@ public class IdlcErrorReader {
                     marker = analyseIdlcError(line);
                 } 
                 
-                if (null == marker) {
-                    PluginLogger.debug("Error line: " + line); //$NON-NLS-1$
-                    
-                } else {
-                    
+                if (null != marker) {
                     // Keep only the markers for the errors concerning the 
                     // file which is compiled
                     if (IResource.FILE == marker.getResource().getType() && 
@@ -195,7 +193,9 @@ public class IdlcErrorReader {
             
             // HELP the groups are indexed from 1. 0 is the whole string
             String filePath = mSyntax.group(1);
-            int lineNo = Integer.parseInt(mSyntax.group(2));
+            int lineNo = Integer.parseInt(mSyntax.group(IDLC_ERROR_LINE_GROUP));
+            int offsetStart = Integer.parseInt(mSyntax.group(IDLC_ERROR_OFFSET_START_GROUP));
+            int offsetEnd = Integer.parseInt(mSyntax.group(IDLC_ERROR_OFFSET_END_GROUP));
             String message = mSyntax.group(mSyntax.groupCount());
             
             // Get a handle on the bad file
@@ -227,11 +227,10 @@ public class IdlcErrorReader {
                 // But afterwards, pay attention when the marker should be located under 
                 // the bad words
                 
-                // Try to find the line or word that causes the error
-//                Map positions = getWrongWord(lineNo, message);
-//                
-//                marker.setAttribute(IMarker.CHAR_START, ((Integer)positions.get(IMarker.CHAR_START)).intValue());
-//                marker.setAttribute(IMarker.CHAR_END,  ((Integer)positions.get(IMarker.CHAR_END)).intValue());
+                int lineOffset = getLineOffset( lineNo );
+                
+                marker.setAttribute(IMarker.CHAR_START, lineOffset + offsetStart - 1);
+                marker.setAttribute(IMarker.CHAR_END,  lineOffset + offsetEnd);
                 
             } catch (CoreException e) {
                 PluginLogger.error(
@@ -262,7 +261,7 @@ public class IdlcErrorReader {
             IProject project = mCompiledFile.getProject();
 
             String errorFilePath = mInclude.group(1);
-            int lineNo = Integer.parseInt(mInclude.group(2));
+            int lineNo = Integer.parseInt(mInclude.group(IDLC_ERROR_LINE_GROUP));
             String badIncludePath = mInclude.group(IDLCPP_INCLUDE_PATH_GROUP);
             
             if (null == mInclude.group(IDLCPP_OPTIONAL_GROUP)) {
@@ -287,13 +286,10 @@ public class IdlcErrorReader {
                     marker.setAttribute(IMarker.LINE_NUMBER, lineNo);
                     marker.setAttribute(IMarker.PRIORITY, IMarker.PRIORITY_HIGH);
                     
-                    // Try to find the line or Word that causes the error
-                    Map<String, Integer> positions = getWrongWord(lineNo, message);
+                    int lineOffset = getLineOffset( lineNo );
                     
-                    marker.setAttribute(IMarker.CHAR_START,
-                            positions.get(IMarker.CHAR_START).intValue());
-                    marker.setAttribute(IMarker.CHAR_END,  
-                            positions.get(IMarker.CHAR_END).intValue());
+                    marker.setAttribute(IMarker.CHAR_START, lineOffset);
+                    marker.setAttribute(IMarker.CHAR_END, lineOffset + getLineLength(lineNo));
                     
                 } catch (CoreException e) {
                     // Nothing to do. Do not create noise in the logs
@@ -305,46 +301,56 @@ public class IdlcErrorReader {
     }
     
     /**
-     * Computes the offset of the first and last characters of the word
-     * to underline.
+     * Get the offset of the line relatively to the document beginning.
      * 
-     * @param pLine the number of the line where the error is located
-     * @param pMessage the error message
+     * @param pLine the line number
      * 
-     * @return a map containing the offset of the first and last characters of the
-     *          word causing the error. 
+     * @return the computed offset
      */
-    private Map<String, Integer> getWrongWord(int pLine, String pMessage) {
-        HashMap<String, Integer> map = new HashMap<String, Integer>();
-        int start = 0;
-        int end = 0;
+    private int getLineOffset( int pLine ) {
+        int offset = 0;
         
         try {
-            
             // Get the line offset.
             LineNumberReader fileReader = new LineNumberReader(
                     new InputStreamReader(mCompiledFile.getContents()));
-            int offset = 0;
             
-            for (int i = 0, length = pLine; i < length; i++) {
+            for (int i = 0, length = pLine - 1; i < length; i++) {
                 String tmpLine = fileReader.readLine();
-                offset += tmpLine.length();
+                offset += tmpLine.length() + 1;
             }
+        } catch (Exception e) {
+            // Nothing to report: the marker will be bad placed perhaps...
+        }
+        
+        return offset;
+    }
+    
+    /**
+     * Get the length of the line.
+     * 
+     * @param pLine the line number
+     * 
+     * @return the length
+     */
+    private int getLineLength( int pLine ) {
+        int lineLen = 0;
+        
+        try {
+            // Get the line offset.
+            LineNumberReader fileReader = new LineNumberReader(
+                    new InputStreamReader(mCompiledFile.getContents()));
             
-            // TODO Get the character offset in the line
-            // The last character should be found using the next blank.
+            for (int i = 0, length = pLine - 1; i < length; i++) {
+                fileReader.readLine();
+            }
             
-            start = offset;
-            end = offset;
+            String line = fileReader.readLine();
+            lineLen = line.length();
         } catch (Exception e) {
             // Nothing to report: the marker will be bad placed perhaps...
         }
         
-        // Create the map content
-        map.put(IMarker.CHAR_START, new Integer(start));
-        map.put(IMarker.CHAR_END, new Integer(end));
-        
-        return map;
+        return lineLen;
     }
-    
 }
\ No newline at end of file
diff --git a/core/source/org/openoffice/ide/eclipse/core/editors/idl/UnoidlConfiguration.java b/core/source/org/openoffice/ide/eclipse/core/editors/idl/UnoidlConfiguration.java
index beba65e..0594baa 100755
--- a/core/source/org/openoffice/ide/eclipse/core/editors/idl/UnoidlConfiguration.java
+++ b/core/source/org/openoffice/ide/eclipse/core/editors/idl/UnoidlConfiguration.java
@@ -43,15 +43,17 @@
  ************************************************************************/
 package org.openoffice.ide.eclipse.core.editors.idl;
 
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ITextDoubleClickStrategy;
-import org.eclipse.jface.text.TextAttribute;
-import org.eclipse.jface.text.presentation.IPresentationReconciler;
-import org.eclipse.jface.text.presentation.PresentationReconciler;
-import org.eclipse.jface.text.rules.DefaultDamagerRepairer;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.ITextDoubleClickStrategy;
+import org.eclipse.jface.text.TextAttribute;
+import org.eclipse.jface.text.presentation.IPresentationReconciler;
+import org.eclipse.jface.text.presentation.PresentationReconciler;
+import org.eclipse.jface.text.rules.DefaultDamagerRepairer;
 import org.eclipse.jface.text.rules.Token;
-import org.eclipse.jface.text.source.ISourceViewer;
-import org.eclipse.jface.text.source.SourceViewerConfiguration;
+import org.eclipse.jface.text.source.DefaultAnnotationHover;
+import org.eclipse.jface.text.source.IAnnotationHover;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.jface.text.source.SourceViewerConfiguration;
 import org.openoffice.ide.eclipse.core.editors.syntax.NonRuleBasedDamagerRepairer;
 import org.openoffice.ide.eclipse.core.editors.syntax.UnoidlDocScanner;
 import org.openoffice.ide.eclipse.core.editors.syntax.UnoidlPartitionScanner;
@@ -93,8 +95,20 @@ public class UnoidlConfiguration extends SourceViewerConfiguration {
             mDoubleClickStrategy = new UnoidlDoubleClickStrategy();
         }
         return mDoubleClickStrategy;
-    }
+    }
+    
 
+    @Override
+    public IAnnotationHover getAnnotationHover(ISourceViewer pSourceViewer) {
+        return new DefaultAnnotationHover(false);
+    }
+    
+    @Override
+    public IAnnotationHover getOverviewRulerAnnotationHover(ISourceViewer pSourceViewer) {
+        return new DefaultAnnotationHover(true);
+    }
+    
+    
     //--------------------------------------------- Syntax highlighting support
     
     /**
diff --git a/core/source/org/openoffice/ide/eclipse/core/internal/model/UnoidlProject.java b/core/source/org/openoffice/ide/eclipse/core/internal/model/UnoidlProject.java
index 258e889..f7e073e 100755
--- a/core/source/org/openoffice/ide/eclipse/core/internal/model/UnoidlProject.java
+++ b/core/source/org/openoffice/ide/eclipse/core/internal/model/UnoidlProject.java
@@ -764,7 +764,7 @@ public class UnoidlProject implements IUnoidlProject, IProjectNature {
                 marker.setAttribute(IMarker.MESSAGE, 
                     Messages.getString("UnoidlProject.NoOOoSdkError")); //$NON-NLS-1$
             } else {
-                prjRes.deleteMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE);
+                prjRes.deleteMarkers(IMarker.PROBLEM, true, IResource.DEPTH_ZERO);
             }
         } catch (CoreException e) {
             if (pSet) {


More information about the ooo-build-commit mailing list