1 11 package org.eclipse.jdt.apt.core.internal.env; 12 13 import org.eclipse.core.resources.IFile; 14 import org.eclipse.jdt.apt.core.internal.AptPlugin; 15 import org.eclipse.jdt.apt.core.internal.env.MessagerImpl.Severity; 16 import org.eclipse.jdt.apt.core.util.EclipseMessager; 17 import org.eclipse.jdt.core.compiler.CategorizedProblem; 18 import org.eclipse.jdt.core.compiler.IProblem; 19 20 class APTProblem extends CategorizedProblem implements IProblem 21 { 22 private static final String [] NO_ARGS = new String [0]; 23 private final Severity _severity; 24 private int _startingOffset; 25 private int _endingOffset; 26 private int _line; 27 private IFile _resource; 28 private final String _message; 29 30 private final String [] _arguments; 32 33 APTProblem(final String msg, 34 final Severity severity, 35 final IFile file, 36 final int startingOffset, 37 final int endingOffset, 38 final int line, 39 final String [] arguments){ 40 _message = msg; 41 _severity = severity; 42 _startingOffset = startingOffset; 43 _endingOffset = endingOffset; 44 _line = line; 45 _resource = file; 46 _arguments = arguments; 47 } 48 49 public int getID() { 50 if (_arguments != null) { 52 return EclipseMessager.APT_QUICK_FIX_PROBLEM_ID; 53 } 54 else { 55 return EclipseMessager.APT_PROBLEM_ID; 56 } 57 } 58 59 public String [] getArguments() { 60 return _arguments == null ? NO_ARGS : (String [])_arguments.clone(); 61 } 62 63 public String getMessage() { 64 return _message; 65 } 66 67 public char[] getOriginatingFileName() { 68 return _resource.getName().toCharArray(); 69 } 70 71 public int getSourceStart() { 72 return _startingOffset; 73 } 74 75 public int getSourceEnd() { 76 return _endingOffset; 77 } 78 79 public int getSourceLineNumber() { 80 return _line; 81 } 82 83 public void setSourceStart(int sourceStart) { 84 _startingOffset = sourceStart; 85 } 86 87 public void setSourceEnd(int sourceEnd) { 88 _endingOffset = sourceEnd; 89 } 90 91 public void setSourceLineNumber(int lineNumber) { 92 _line = lineNumber; 93 } 94 95 public boolean isError() { 96 return _severity == Severity.ERROR; 97 } 98 99 public boolean isWarning() { 100 return _severity == Severity.WARNING; 101 } 102 103 public String toString() 104 { 105 return _message == null ? "<null message>" : _message ; } 107 108 @Override 109 public int getCategoryID() { 110 return 0; 112 } 113 114 @Override 115 public String getMarkerType() { 116 return AptPlugin.APT_COMPILATION_PROBLEM_MARKER; 117 } 118 } 119 | Popular Tags |