Eclipse 3M7
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / corext / util / JavaModelUtil.java
index 5fc7858..a2e6fcc 100644 (file)
  *******************************************************************************/
 package net.sourceforge.phpdt.internal.corext.util;
 
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
+import java.util.StringTokenizer;
 
 import net.sourceforge.phpdt.core.Flags;
 import net.sourceforge.phpdt.core.ICompilationUnit;
 import net.sourceforge.phpdt.core.IField;
 import net.sourceforge.phpdt.core.IJavaElement;
-import net.sourceforge.phpdt.core.IJavaProject;
 import net.sourceforge.phpdt.core.IMember;
 import net.sourceforge.phpdt.core.IMethod;
 import net.sourceforge.phpdt.core.IPackageFragment;
@@ -31,13 +26,9 @@ import net.sourceforge.phpdt.core.Signature;
 import net.sourceforge.phpdt.core.compiler.CharOperation;
 import net.sourceforge.phpeclipse.phpeditor.EditorUtility;
 
-import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.IResource;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.SubProgressMonitor;
 
 
 
@@ -696,4 +687,43 @@ public class JavaModelUtil {
                return false;
        }       
        
+
+       private static final String ARGUMENTS_DELIMITER = "#"; //$NON-NLS-1$
+       private static final String EMPTY_ARGUMENT = "   "; //$NON-NLS-1$
+       
+       /**
+        * Copied from org.eclipse.jdt.internal.core.Util;
+        */
+       public static String[] getProblemArgumentsFromMarker(String argumentsString){
+               if (argumentsString == null) return null;
+               int index = argumentsString.indexOf(':');
+               if(index == -1)
+                       return null;
+               
+               int length = argumentsString.length();
+               int numberOfArg;
+               try{
+                       numberOfArg = Integer.parseInt(argumentsString.substring(0 , index));
+               } catch (NumberFormatException e) {
+                       return null;
+               }
+               argumentsString = argumentsString.substring(index + 1, length);
+               
+               String[] args = new String[length];
+               int count = 0;
+               
+               StringTokenizer tokenizer = new StringTokenizer(argumentsString, ARGUMENTS_DELIMITER);
+               while(tokenizer.hasMoreTokens()) {
+                       String argument = tokenizer.nextToken();
+                       if(argument.equals(EMPTY_ARGUMENT))
+                               argument = "";  //$NON-NLS-1$
+                       args[count++] = argument;
+               }
+               
+               if(count != numberOfArg)
+                       return null;
+               
+               System.arraycopy(args, 0, args = new String[count], 0, count);
+               return args;
+       }
 }