Package editor
Class SmartFixManager
- java.lang.Object
-
- editor.SmartFixManager
-
- All Implemented Interfaces:
java.awt.event.KeyListener,java.awt.event.MouseMotionListener,java.util.EventListener
public class SmartFixManager extends java.lang.Object implements java.awt.event.MouseMotionListener, java.awt.event.KeyListenerHandles state and functions relating to smart-fix functionality in the Gosu editor
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classSmartFixManager.CtorCellRendererstatic classSmartFixManager.ReplaceChunkprivate classSmartFixManager.SmartFixHighlightPainterstatic classSmartFixManager.SmartFixModeprivate static classSmartFixManager.TypeNameComparator
-
Field Summary
Fields Modifier and Type Field Description (package private) static boolean_allowUnusedParameterFixprivate javax.swing.text.JTextComponent_editorprivate GosuEditor_gosuEditorprivate IParsedElement_javaStyleCastprivate int_lengthprivate SmartFixPopup_managerPopupprivate SmartFixManager.SmartFixMode_modeprivate int_obsoleteCtorEndprivate int_obsoleteCtorStartprivate int_offsetprivate IParsedElement_peToFixWithAsStatementprivate java.lang.String_possibleDisplayKeyprivate java.util.Set<java.lang.String>_possibleTypesToImport(package private) SelectClassToImportPopup_selectionPopupprivate IParsedElement_sourceOfIssueprivate IParseTree_stringLiteralLocationToReplaceprivate javax.swing.Timer_timerprivate java.lang.String_typeToCoerceToprivate static java.lang.StringDISPLAYKEY_STARTstatic java.lang.StringSHORTCUTprivate static java.awt.ColorSMARTFIX_HIGHLIGHT_COLORprivate static java.awt.RectangleTEST_RECTANGLE
-
Constructor Summary
Constructors Constructor Description SmartFixManager(GosuEditor gosuEditor)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidaddMissingOverride()private voidbufferShowPopup(boolean restartIfActive)private java.util.List<IParseIssue>findParseIssuesOrderedByDistanceFromCaret(int maxLines)private voidfixCase()private voidfixConstructorSyntax()private voidfixImplicitCast()private voidfixImport()private voidfixJavaStyleCast()private voidfixReturnType()private voidfixUnusedElement()private voidgenerateConstructors()private voidgenerateSuperCall()private voidgenerateSuperCall(IConstructorInfo constructor)private doublegetDistanceFromPosition(IParseIssue pi, int line, int col)Returns the cartesian distance of this parse issue from the given column/line in column/line unitsjavax.swing.text.JTextComponentgetEditor()private intgetEndOffsetOfUnused()GosuEditorgetGosuEditor()IParsedElementgetJavaStyleCast()intgetLength()private java.awt.RectanglegetLocationFromOffset(int i)SmartFixManager.SmartFixModegetMode()intgetOffset()private intgetOverrideTarget(int offset)IParsedElementgetPeToFixWithAsStatement()java.util.Set<java.lang.String>getPossibleTypesToImport()static SmartFixManager.ReplaceChunkgetReplaceChunk(IParsedElement sourceOfIssue, java.lang.String gosuSource)private ITypegetReturnTypeFromPartialStatement(IParsedElement source)IParsedElementgetSourceOfIssue()private intgetStartOffsetOfUnused()private java.awt.RectanglegetTargetBounds()java.lang.StringgetTypeToCoerceTo()private booleanhandlePossibleImportFix(IParsedElement source, ITypeUsesMap typeUses, java.util.Set<java.lang.String> processed)private voidhidePopup()private booleanisCaseIssue(IParseIssue parseIssue)static booleanisCaseParseIssue(IParseIssue parseIssue)private booleanisImplictCoercion(IParseIssue parseIssue)private booleanisJavaStyleCast(IParseIssue parseIssue)private booleanisMissingConstructor(IParseIssue parseIssue)private booleanisMissingOverride(IParseIssue parseIssue)private booleanisMissingSuperCall(IParseIssue parseIssue)private booleanisModeAvailable(SmartFixManager.SmartFixMode mode)private booleanisObsoleteConstructor(IParseIssue parseIssue)private booleanisOtherPopupShowing()private booleanisVoidReturnTypeIssue(IParseIssue parseIssue)voidkeyPressed(java.awt.event.KeyEvent e)voidkeyReleased(java.awt.event.KeyEvent e)voidkeyTyped(java.awt.event.KeyEvent e)voidmouseDragged(java.awt.event.MouseEvent e)voidmouseMoved(java.awt.event.MouseEvent e)private booleanofferPassiveFix()voidperformFix()voidresetSmartHelpState()voidsetEditor(javax.swing.text.JTextComponent editor)voidsetGosuEditor(GosuEditor gosuEditor)voidsetLength(int length)private voidsetMode(SmartFixManager.SmartFixMode mode)voidsetOffset(int offset)voidsetSourceOfIssue(IParsedElement sourceOfIssue)private voidshowPopup()voidshowSmartFix(int offset, int length, java.lang.String displayText)private voidshowSmartFix(IParsedElement source, java.lang.String displayText)voidupdateState()Updates the state of the SmartFixManager, which may display tool tips and offer to fix issues in the gosu program.
-
-
-
Field Detail
-
TEST_RECTANGLE
private static final java.awt.Rectangle TEST_RECTANGLE
-
DISPLAYKEY_START
private static final java.lang.String DISPLAYKEY_START
- See Also:
- Constant Field Values
-
SHORTCUT
public static final java.lang.String SHORTCUT
- See Also:
- Constant Field Values
-
_timer
private javax.swing.Timer _timer
-
_gosuEditor
private GosuEditor _gosuEditor
-
_editor
private javax.swing.text.JTextComponent _editor
-
_mode
private SmartFixManager.SmartFixMode _mode
-
_possibleTypesToImport
private java.util.Set<java.lang.String> _possibleTypesToImport
-
_peToFixWithAsStatement
private IParsedElement _peToFixWithAsStatement
-
_javaStyleCast
private IParsedElement _javaStyleCast
-
_obsoleteCtorStart
private int _obsoleteCtorStart
-
_obsoleteCtorEnd
private int _obsoleteCtorEnd
-
_possibleDisplayKey
private java.lang.String _possibleDisplayKey
-
_stringLiteralLocationToReplace
private IParseTree _stringLiteralLocationToReplace
-
_sourceOfIssue
private IParsedElement _sourceOfIssue
-
_typeToCoerceTo
private java.lang.String _typeToCoerceTo
-
_managerPopup
private SmartFixPopup _managerPopup
-
_offset
private int _offset
-
_length
private int _length
-
SMARTFIX_HIGHLIGHT_COLOR
private static final java.awt.Color SMARTFIX_HIGHLIGHT_COLOR
-
_allowUnusedParameterFix
static boolean _allowUnusedParameterFix
-
_selectionPopup
SelectClassToImportPopup _selectionPopup
-
-
Constructor Detail
-
SmartFixManager
public SmartFixManager(GosuEditor gosuEditor)
-
-
Method Detail
-
performFix
public void performFix()
-
getEditor
public javax.swing.text.JTextComponent getEditor()
-
setEditor
public void setEditor(javax.swing.text.JTextComponent editor)
-
getSourceOfIssue
public IParsedElement getSourceOfIssue()
-
setSourceOfIssue
public void setSourceOfIssue(IParsedElement sourceOfIssue)
-
getOffset
public int getOffset()
-
setOffset
public void setOffset(int offset)
-
getLength
public int getLength()
-
setLength
public void setLength(int length)
-
getGosuEditor
public GosuEditor getGosuEditor()
-
setGosuEditor
public void setGosuEditor(GosuEditor gosuEditor)
-
fixUnusedElement
private void fixUnusedElement()
-
getStartOffsetOfUnused
private int getStartOffsetOfUnused()
-
getEndOffsetOfUnused
private int getEndOffsetOfUnused()
-
addMissingOverride
private void addMissingOverride()
-
fixCase
private void fixCase()
-
fixReturnType
private void fixReturnType()
-
generateConstructors
private void generateConstructors()
-
generateSuperCall
private void generateSuperCall()
-
generateSuperCall
private void generateSuperCall(IConstructorInfo constructor)
-
getOverrideTarget
private int getOverrideTarget(int offset)
-
offerPassiveFix
private boolean offerPassiveFix()
-
setMode
private void setMode(SmartFixManager.SmartFixMode mode)
-
fixImplicitCast
private void fixImplicitCast()
-
fixConstructorSyntax
private void fixConstructorSyntax()
-
fixJavaStyleCast
private void fixJavaStyleCast()
-
fixImport
private void fixImport()
-
updateState
public void updateState()
Updates the state of the SmartFixManager, which may display tool tips and offer to fix issues in the gosu program.
-
isMissingConstructor
private boolean isMissingConstructor(IParseIssue parseIssue)
-
isMissingSuperCall
private boolean isMissingSuperCall(IParseIssue parseIssue)
-
isCaseIssue
private boolean isCaseIssue(IParseIssue parseIssue)
-
isVoidReturnTypeIssue
private boolean isVoidReturnTypeIssue(IParseIssue parseIssue)
-
getReturnTypeFromPartialStatement
private IType getReturnTypeFromPartialStatement(IParsedElement source)
-
isModeAvailable
private boolean isModeAvailable(SmartFixManager.SmartFixMode mode)
-
isMissingOverride
private boolean isMissingOverride(IParseIssue parseIssue)
-
isOtherPopupShowing
private boolean isOtherPopupShowing()
-
isImplictCoercion
private boolean isImplictCoercion(IParseIssue parseIssue)
-
isObsoleteConstructor
private boolean isObsoleteConstructor(IParseIssue parseIssue)
-
isJavaStyleCast
private boolean isJavaStyleCast(IParseIssue parseIssue)
-
resetSmartHelpState
public void resetSmartHelpState()
-
handlePossibleImportFix
private boolean handlePossibleImportFix(IParsedElement source, ITypeUsesMap typeUses, java.util.Set<java.lang.String> processed)
-
getLocationFromOffset
private java.awt.Rectangle getLocationFromOffset(int i) throws javax.swing.text.BadLocationException- Throws:
javax.swing.text.BadLocationException
-
showSmartFix
private void showSmartFix(IParsedElement source, java.lang.String displayText)
-
showSmartFix
public void showSmartFix(int offset, int length, java.lang.String displayText)
-
findParseIssuesOrderedByDistanceFromCaret
private java.util.List<IParseIssue> findParseIssuesOrderedByDistanceFromCaret(int maxLines)
-
getDistanceFromPosition
private double getDistanceFromPosition(IParseIssue pi, int line, int col)
Returns the cartesian distance of this parse issue from the given column/line in column/line units
-
getMode
public SmartFixManager.SmartFixMode getMode()
-
getPossibleTypesToImport
public java.util.Set<java.lang.String> getPossibleTypesToImport()
-
getPeToFixWithAsStatement
public IParsedElement getPeToFixWithAsStatement()
-
getJavaStyleCast
public IParsedElement getJavaStyleCast()
-
getTypeToCoerceTo
public java.lang.String getTypeToCoerceTo()
-
mouseDragged
public void mouseDragged(java.awt.event.MouseEvent e)
- Specified by:
mouseDraggedin interfacejava.awt.event.MouseMotionListener
-
mouseMoved
public void mouseMoved(java.awt.event.MouseEvent e)
- Specified by:
mouseMovedin interfacejava.awt.event.MouseMotionListener
-
hidePopup
private void hidePopup()
-
bufferShowPopup
private void bufferShowPopup(boolean restartIfActive)
-
keyTyped
public void keyTyped(java.awt.event.KeyEvent e)
- Specified by:
keyTypedin interfacejava.awt.event.KeyListener
-
keyPressed
public void keyPressed(java.awt.event.KeyEvent e)
- Specified by:
keyPressedin interfacejava.awt.event.KeyListener
-
keyReleased
public void keyReleased(java.awt.event.KeyEvent e)
- Specified by:
keyReleasedin interfacejava.awt.event.KeyListener
-
showPopup
private void showPopup()
-
getTargetBounds
private java.awt.Rectangle getTargetBounds()
-
isCaseParseIssue
public static boolean isCaseParseIssue(IParseIssue parseIssue)
-
getReplaceChunk
public static SmartFixManager.ReplaceChunk getReplaceChunk(IParsedElement sourceOfIssue, java.lang.String gosuSource)
-
-