idx
int64
0
165k
question
stringlengths
73
5.81k
target
stringlengths
5
918
120,900
public void handleDebugEvents ( DebugEvent [ ] events ) { for ( int i = 0 ; i < events . length ; i ++ ) { DebugEvent event = events [ i ] ; if ( event . getSource ( ) . equals ( getProcess ( ) ) ) { if ( event . getKind ( ) == DebugEvent . TERMINATE ) { closeStreams ( ) ; DebugPlugin . getDefault ( ) . removeDebugEven...
Notify listeners when name changes .
120,901
private void resetName ( ) { UIJob job = new UIJob ( "Activating Console" ) { public IStatus runInUIThread ( IProgressMonitor monitor ) { warnOfContentChange ( ) ; return Status . OK_STATUS ; } } ; job . setSystem ( true ) ; job . schedule ( ) ; }
resets the name of this console to the original computed name
120,902
private void warnOfContentChange ( ) { IConsole [ ] consoles = ConsolePlugin . getDefault ( ) . getConsoleManager ( ) . getConsoles ( ) ; for ( IConsole iConsole : consoles ) { if ( iConsole instanceof VdmDebugConsole ) { VdmDebugConsole vdmC = ( VdmDebugConsole ) iConsole ; vdmC . activate ( ) ; } } }
send notification of a change of content in this console
120,903
protected LexNameToken idToName ( LexIdentifierToken id ) { LexNameToken name = new LexNameToken ( reader . currentModule , id ) ; return name ; }
Convert an identifier into a name . A name is an identifier that has a module name qualifier so this method uses the current module to convert the identifier passed in .
120,904
protected void checkFor ( VDMToken tok , int number , String message ) throws LexException , ParserException { if ( lastToken ( ) . is ( tok ) ) { nextToken ( ) ; } else { throwMessage ( number , message ) ; } }
If the last token is as expected advance else raise an error .
120,905
protected boolean ignore ( VDMToken tok ) throws LexException { if ( lastToken ( ) . is ( tok ) ) { nextToken ( ) ; return true ; } else { return false ; } }
If the last token is the one passed advance by one else do nothing .
120,906
protected void report ( LocatedException error , VDMToken [ ] after , VDMToken [ ] upto ) { VDMError vdmerror = new VDMError ( error ) ; errors . add ( vdmerror ) ; if ( errors . size ( ) >= MAX - 1 ) { errors . add ( new VDMError ( 9 , "Too many syntax errors" , error . location ) ) ; throw new InternalException ( 9 ,...
Raise a syntax error and attempt to recover . The error is added to the errors list and if this exceeds 100 errors the parser is aborted . The after and upto lists of token types are then used to control the advance of the parser to skip beyond the error . Tokens are read until one occurs in either list or EOF is reach...
120,907
protected void warning ( int no , String msg , ILexLocation location ) { VDMWarning vdmwarning = new VDMWarning ( no , msg , location ) ; warnings . add ( vdmwarning ) ; if ( warnings . size ( ) >= MAX - 1 ) { errors . add ( new VDMError ( 9 , "Too many warnings" , location ) ) ; throw new InternalException ( 9 , "Too ...
Report a warning . Unlike errors this does no token recovery .
120,908
public void printErrors ( PrintWriter out ) { for ( VDMError e : getErrors ( ) ) { out . println ( e . toString ( ) ) ; } }
Print errors and warnings to the PrintWriter passed .
120,909
public < T > void contextSet ( Class < T > key , T value ) { synchronized ( TypeCheckInfo . class ) { Stack < T > contextStack = lookupListForType ( key ) ; if ( contextStack == null ) { contextStack = new Stack < T > ( ) ; context . put ( key , contextStack ) ; } contextStack . push ( value ) ; } }
Associates the given key with the given value .
120,910
public < T > T contextRem ( Class < T > key ) { synchronized ( TypeCheckInfo . class ) { Stack < T > contextStack = lookupListForType ( key ) ; if ( contextStack != null ) { return contextStack . pop ( ) ; } } return null ; }
Returns the value associated with key and removes that binding from the context .
120,911
private boolean isSelectionCommented ( ISelection selection ) { if ( ! ( selection instanceof ITextSelection ) ) return false ; ITextSelection textSelection = ( ITextSelection ) selection ; if ( textSelection . getStartLine ( ) < 0 || textSelection . getEndLine ( ) < 0 ) return false ; IDocument document = getTextEdito...
Is the given selection single - line commented?
120,912
public String getFullPredString ( ) { if ( valuetree . getPredicate ( ) == null ) { return "" ; } String result = valuetree . getPredicate ( ) . toString ( ) ; return result ; }
string as it exists in the current version
120,913
protected PMultipleBind getMultipleSetBind ( PExp setExp , ILexNameToken ... patternNames ) { ASetMultipleBind setBind = new ASetMultipleBind ( ) ; List < PPattern > patternList = new Vector < PPattern > ( ) ; for ( ILexNameToken patternName : patternNames ) { AIdentifierPattern pattern = new AIdentifierPattern ( ) ; p...
Create a multiple set bind with a varargs list of pattern variables like a b c in set S . This is used by several obligations .
120,914
protected AEqualsBinaryExp getEqualsExp ( PExp left , PExp right ) { return AstExpressionFactory . newAEqualsBinaryExp ( left . clone ( ) , right . clone ( ) ) ; }
Generate an AEqualsBinaryExp
120,915
protected AVariableExp getVarExp ( ILexNameToken name ) { AVariableExp var = new AVariableExp ( ) ; var . setName ( name . clone ( ) ) ; var . setOriginal ( name . getFullName ( ) ) ; return var ; }
Generate an AVariableExp
120,916
protected AVariableExp getVarExp ( ILexNameToken name , PType type ) { AVariableExp var = getVarExp ( name ) ; var . setType ( type . clone ( ) ) ; return var ; }
Generate a Var Exp with associated type .
120,917
protected AVariableExp getVarExp ( ILexNameToken name , PDefinition vardef ) { AVariableExp var = new AVariableExp ( ) ; var . setName ( name . clone ( ) ) ; var . setOriginal ( name . getFullName ( ) ) ; var . setVardef ( vardef . clone ( ) ) ; return var ; }
Generate AVariableExp with corresponding definition
120,918
protected AVariableExp getVarExp ( ILexNameToken name , PDefinition vardef , PType type ) { AVariableExp var = getVarExp ( name , vardef ) ; var . setType ( type ) ; return var ; }
Generate Var Exp with everything!
120,919
protected AApplyExp getApplyExp ( PExp root , PExp ... arglist ) { return getApplyExp ( root , Arrays . asList ( arglist ) ) ; }
Generate an AApplyExp with varargs arguments
120,920
protected AApplyExp getApplyExp ( PExp root , List < PExp > arglist ) { AApplyExp apply = new AApplyExp ( ) ; apply . setRoot ( root . clone ( ) ) ; List < PExp > args = new Vector < PExp > ( ) ; for ( PExp arg : arglist ) { args . add ( arg . clone ( ) ) ; } apply . setArgs ( args ) ; return apply ; }
Generate an AApplyExp
120,921
protected AIntLiteralExp getIntLiteral ( long i ) { AIntLiteralExp number = new AIntLiteralExp ( ) ; ILexIntegerToken literal = new LexIntegerToken ( i , null ) ; number . setValue ( literal ) ; return number ; }
Generate an AIntLiteral from a long .
120,922
protected PExp makeAnd ( PExp root , PExp e ) { if ( root != null ) { AAndBooleanBinaryExp a = new AAndBooleanBinaryExp ( ) ; a . setLeft ( root . clone ( ) ) ; a . setOp ( new LexKeywordToken ( VDMToken . AND , null ) ) ; a . setType ( new ABooleanBasicType ( ) ) ; a . setRight ( e . clone ( ) ) ; return a ; } else { ...
Chain an AND expression onto a root or just return the new expression if the root is null . Called in a loop this left - associates an AND tree .
120,923
protected PExp makeOr ( PExp root , PExp e ) { if ( root != null ) { AOrBooleanBinaryExp o = new AOrBooleanBinaryExp ( ) ; o . setLeft ( root . clone ( ) ) ; o . setOp ( new LexKeywordToken ( VDMToken . OR , null ) ) ; o . setType ( new ABooleanBasicType ( ) ) ; o . setRight ( e . clone ( ) ) ; return o ; } else { retu...
Chain an OR expression onto a root or just return the new expression if the root is null . Called in a loop this left - associates an OR tree .
120,924
private Object readResolve ( ) throws ObjectStreamException { LexLocation existing = uniqueLocations . get ( this ) ; if ( existing == null ) { return this ; } else { return existing ; } }
Method to resolve existing locations during de - serialise - as used during deep copy . This is to avoid problems with coverage .
120,925
public String toProblemString ( ) { StringBuilder sb = new StringBuilder ( ) ; sb . append ( message ) ; sb . append ( "." ) ; for ( String d : details ) { sb . append ( " " ) ; sb . append ( d ) ; } return sb . toString ( ) ; }
view with details but without the file location and number .
120,926
protected String autoFillBaseSettings ( ) { ISelection selection = PlatformUI . getWorkbench ( ) . getActiveWorkbenchWindow ( ) . getSelectionService ( ) . getSelection ( ) ; if ( selection instanceof TreeSelection ) { TreeSelection tSelection = ( TreeSelection ) selection ; if ( tSelection . getFirstElement ( ) != nul...
Gets the last selected project in the platform if selection is tree selection
120,927
public void processExports ( AModuleModules m ) { if ( m . getExports ( ) != null ) { m . getExportdefs ( ) . clear ( ) ; if ( ! m . getIsDLModule ( ) ) { m . getExportdefs ( ) . addAll ( getDefinitions ( m . getExports ( ) , m . getDefs ( ) ) ) ; } else { m . getExportdefs ( ) . addAll ( getDefinitions ( m . getExport...
Generate the exportdefs list of definitions . The exports list of export declarations is processed by searching the defs list of locally defined objects . The exportdefs field is populated with the result .
120,928
public SExpIR caseABooleanConstExp ( ABooleanConstExp node , IRInfo question ) throws AnalysisException { PType type = node . getType ( ) ; boolean value = node . getValue ( ) . getValue ( ) ; STypeIR typeCg = type . apply ( question . getTypeVisitor ( ) , question ) ; ABoolLiteralExpIR boolLitCg = new ABoolLiteralExpI...
setValue at the current time of writing .
120,929
private void verifyBufferSize ( int sz ) { if ( sz > buf . length ) { byte [ ] old = buf ; buf = new byte [ Math . max ( sz , 2 * buf . length ) ] ; System . arraycopy ( old , 0 , buf , 0 , old . length ) ; old = null ; } }
Ensures that we have a large enough buffer for the given size .
120,930
public Value execute ( File file ) throws Exception { BufferedReader br = new BufferedReader ( new FileReader ( file ) ) ; StringBuilder sb = new StringBuilder ( ) ; String line = br . readLine ( ) ; while ( line != null ) { sb . append ( line ) ; line = br . readLine ( ) ; } br . close ( ) ; Value result = execute ( s...
Parse the content of the file passed type check it and evaluate it as an expression in the initial context .
120,931
public String getSourceLine ( File file , int line , String sep ) { SourceFile source = sourceFiles . get ( file ) ; if ( source == null ) { try { source = new SourceFile ( file ) ; sourceFiles . put ( file , source ) ; } catch ( IOException e ) { return "Cannot open source file: " + file ; } } return line + sep + sour...
Get a line of a source file by its location .
120,932
public SourceFile getSourceFile ( File file ) throws IOException { SourceFile source = sourceFiles . get ( file ) ; if ( source == null ) { source = new SourceFile ( file ) ; sourceFiles . put ( file , source ) ; } return source ; }
Get an entire source file object .
120,933
public Breakpoint setTracepoint ( PStm stmt , String trace ) throws Exception { BreakpointManager . setBreakpoint ( stmt , new Tracepoint ( stmt . getLocation ( ) , ++ nextbreakpoint , trace ) ) ; breakpoints . put ( nextbreakpoint , BreakpointManager . getBreakpoint ( stmt ) ) ; return BreakpointManager . getBreakpoin...
Set a statement tracepoint . A tracepoint does not stop execution but evaluates and displays an expression before continuing .
120,934
public Breakpoint setTracepoint ( PExp exp , String trace ) throws ParserException , LexException { BreakpointManager . setBreakpoint ( exp , new Tracepoint ( exp . getLocation ( ) , ++ nextbreakpoint , trace ) ) ; breakpoints . put ( nextbreakpoint , BreakpointManager . getBreakpoint ( exp ) ) ; return BreakpointManag...
Set an expression tracepoint . A tracepoint does not stop execution but evaluates an expression before continuing .
120,935
public Breakpoint setBreakpoint ( PStm stmt , String condition ) throws ParserException , LexException { BreakpointManager . setBreakpoint ( stmt , new Stoppoint ( stmt . getLocation ( ) , ++ nextbreakpoint , condition ) ) ; breakpoints . put ( nextbreakpoint , BreakpointManager . getBreakpoint ( stmt ) ) ; return Brea...
Set a statement breakpoint . A breakpoint stops execution and allows the user to query the environment .
120,936
public Breakpoint setBreakpoint ( PExp exp , String condition ) throws ParserException , LexException { BreakpointManager . setBreakpoint ( exp , new Stoppoint ( exp . getLocation ( ) , ++ nextbreakpoint , condition ) ) ; breakpoints . put ( nextbreakpoint , BreakpointManager . getBreakpoint ( exp ) ) ; return Breakpoi...
Set an expression breakpoint . A breakpoint stops execution and allows the user to query the environment .
120,937
public Breakpoint clearBreakpoint ( int bpno ) { Breakpoint old = breakpoints . remove ( bpno ) ; if ( old != null ) { PStm stmt = findStatement ( old . location . getFile ( ) , old . location . getStartLine ( ) ) ; if ( stmt != null ) { BreakpointManager . setBreakpoint ( stmt , new Breakpoint ( stmt . getLocation ( )...
Clear the breakpoint given by the number .
120,938
public static void typeCheck ( INode classdef , Interpreter interpreter , CallSequence test , Environment outer ) throws AnalysisException , Exception { FlatEnvironment env = null ; if ( classdef instanceof SClassDefinition ) { env = new FlatEnvironment ( interpreter . getAssistantFactory ( ) , classdef . apply ( inter...
type check a test
120,939
private int getMaxPartCount ( ) { int max = 0 ; for ( Object k : super . fWords . keySet ( ) ) { String key = k . toString ( ) ; int count = key . split ( "\\s+?" ) . length ; if ( count > max ) { max = count ; } } return max ; }
Calculates the maximum number of parts in the largest word in the rule scanner
120,940
public static String [ ] charArrayToStringArray ( char [ ] [ ] charArrays ) { if ( charArrays == null ) { return null ; } int length = charArrays . length ; if ( length == 0 ) { return NO_STRINGS ; } String [ ] strings = new String [ length ] ; for ( int i = 0 ; i < length ; i ++ ) { strings [ i ] = new String ( charAr...
Returns the char arrays as an array of Strings
120,941
public static final char [ ] [ ] deepCopy ( char [ ] [ ] toCopy ) { int toCopyLength = toCopy . length ; char [ ] [ ] result = new char [ toCopyLength ] [ ] ; for ( int i = 0 ; i < toCopyLength ; i ++ ) { char [ ] toElement = toCopy [ i ] ; int toElementLength = toElement . length ; char [ ] resultElement = new char [ ...
Answers a deep copy of the toCopy array .
120,942
final static public String [ ] toStrings ( char [ ] [ ] array ) { if ( array == null ) { return NO_STRINGS ; } int length = array . length ; if ( length == 0 ) { return NO_STRINGS ; } String [ ] result = new String [ length ] ; for ( int i = 0 ; i < length ; i ++ ) { result [ i ] = new String ( array [ i ] ) ; } return...
Answers an array of strings from the given array of char array .
120,943
public PExp caseARecordPattern ( ARecordPattern node ) throws AnalysisException { AMkTypeExp mkExp = new AMkTypeExp ( ) ; mkExp . setTypeName ( node . getTypename ( ) . clone ( ) ) ; List < PExp > args = new Vector < PExp > ( ) ; for ( PPattern p : node . getPlist ( ) ) { args . add ( p . apply ( this ) . clone ( ) ) ;...
Now compound patterns involve recursive calls to expand their pattern components to expressions .
120,944
public List < PDefinition > checkDuplicatePatterns ( PDefinition d , List < PDefinition > defs ) { Set < PDefinition > noDuplicates = new HashSet < PDefinition > ( ) ; for ( PDefinition d1 : defs ) { for ( PDefinition d2 : defs ) { if ( d1 != d2 && d1 . getName ( ) != null && d2 . getName ( ) != null && d1 . getName ( ...
Check a DefinitionList for incompatible duplicate pattern definitions .
120,945
protected void genIrStatus ( List < IRStatus < PIR > > statuses , INode node ) throws AnalysisException { IRStatus < PIR > status = generator . generateFrom ( node ) ; if ( status != null ) { statuses . add ( status ) ; } }
This method translates a VDM node into an IR status .
120,946
public static List < AModuleModules > getModules ( List < INode > ast ) { List < AModuleModules > modules = new LinkedList < > ( ) ; for ( INode n : ast ) { if ( n instanceof AModuleModules ) { modules . add ( ( AModuleModules ) n ) ; } } return modules ; }
Convenience method for extracting the VDM module definitions from a list of VDM nodes .
120,947
public static List < SClassDefinition > getClasses ( List < INode > ast ) { List < SClassDefinition > classes = new LinkedList < > ( ) ; for ( INode n : ast ) { if ( n instanceof SClassDefinition ) { classes . add ( ( SClassDefinition ) n ) ; } } return classes ; }
Convenience method for extracting the VDM class definitions from a list of VDM nodes .
120,948
public static List < INode > getNodes ( List < ? extends INode > ast ) { List < INode > nodes = new LinkedList < > ( ) ; nodes . addAll ( ast ) ; return nodes ; }
Convenience method for converting a VDM AST into a list of nodes .
120,949
protected List < INode > getUserModules ( List < ? extends INode > ast ) { List < INode > userModules = new LinkedList < INode > ( ) ; for ( INode node : ast ) { if ( ! getInfo ( ) . getDeclAssistant ( ) . isLibrary ( node ) ) { userModules . add ( node ) ; } } return userModules ; }
This method extracts the user modules or classes from a VDM AST .
120,950
protected void removeUnreachableStms ( List < ? extends INode > ast ) throws AnalysisException { UnreachableStmRemover remover = new UnreachableStmRemover ( ) ; for ( INode node : ast ) { node . apply ( remover ) ; } }
This method removes unreachable statements from the VDM AST .
120,951
protected void simplifyLibrary ( INode module ) { List < PDefinition > defs = null ; if ( module instanceof SClassDefinition ) { defs = ( ( SClassDefinition ) module ) . getDefinitions ( ) ; } else if ( module instanceof AModuleModules ) { defs = ( ( AModuleModules ) module ) . getDefs ( ) ; } else { return ; } for ( P...
Simplifies a VDM standard library class or module by removing sub - nodes that are likely not to be of interest during the generation of the IR .
120,952
protected void handleOldNames ( List < ? extends INode > vdmAst ) throws AnalysisException { OldNameRenamer oldNameRenamer = new OldNameRenamer ( ) ; for ( INode module : vdmAst ) { module . apply ( oldNameRenamer ) ; } }
Processes old names by replacing the tilde sign ~ with an underscore .
120,953
protected boolean shouldGenerateVdmNode ( INode vdmNode ) { DeclAssistantIR declAssistant = getInfo ( ) . getDeclAssistant ( ) ; if ( declAssistant . isLibrary ( vdmNode ) ) { return false ; } else { return true ; } }
Determines whether a VDM module or class should be code generated or not .
120,954
protected GeneratedModule genIrModule ( MergeVisitor mergeVisitor , IRStatus < ? extends PIR > status ) throws org . overture . codegen . ir . analysis . AnalysisException { if ( status . canBeGenerated ( ) ) { mergeVisitor . init ( ) ; StringWriter writer = new StringWriter ( ) ; status . getIrNode ( ) . apply ( merge...
This method translates an IR module or class into target language code .
120,955
protected Generated genIrExp ( IRStatus < SExpIR > expStatus , MergeVisitor mergeVisitor ) throws org . overture . codegen . ir . analysis . AnalysisException { StringWriter writer = new StringWriter ( ) ; SExpIR expCg = expStatus . getIrNode ( ) ; if ( expStatus . canBeGenerated ( ) ) { mergeVisitor . init ( ) ; expCg...
Translates an IR expression into target language code .
120,956
public static void emitCode ( File outputFolder , String fileName , String code ) { emitCode ( outputFolder , fileName , code , "UTF-8" ) ; }
Emits generated code to a file . The file will be encoded using UTF - 8 .
120,957
public static void emitCode ( File outputFolder , String fileName , String code , String encoding ) { try { File javaFile = new File ( outputFolder , File . separator + fileName ) ; javaFile . getParentFile ( ) . mkdirs ( ) ; javaFile . createNewFile ( ) ; PrintWriter writer = new PrintWriter ( new OutputStreamWriter (...
Emits generated code to a file .
120,958
protected GeneratedData genVdmToTargetLang ( List < IRStatus < PIR > > statuses ) throws AnalysisException { GeneratedData r = new GeneratedData ( ) ; try { for ( IRStatus < PIR > status : statuses ) { StateInit stateInit = new StateInit ( getInfo ( ) ) ; generator . applyPartialTransformation ( status , stateInit ) ; ...
Main entry point into the Isabelle Translator component . Takes an AST and returns corresponding Isabelle Syntax .
120,959
private static boolean hasBreakpointAtCurrentPosition ( VdmThread thread ) { try { thread . updateStack ( ) ; if ( thread . hasStackFrames ( ) ) { final IStackFrame top = thread . getTopStackFrame ( ) ; if ( top instanceof IVdmStackFrame && top . getLineNumber ( ) > 0 ) { final IVdmStackFrame frame = ( IVdmStackFrame )...
Tests if the specified thread has breakpoint at the same line
120,960
private static boolean isValidStack ( VdmThread thread ) { final IDebugOptions debugOptions = thread . getDbgpSession ( ) . getDebugOptions ( ) ; if ( debugOptions . get ( DebugOption . ENGINE_VALIDATE_STACK ) ) { thread . updateStack ( ) ; if ( thread . hasStackFrames ( ) ) { return thread . isValidStack ( ) ; } } ret...
Tests if the specified thread has valid current stack . In some cases it is better to skip first internal location .
120,961
public void caseILexLocation ( ILexLocation node ) throws AnalysisException { AstLocation location = new AstLocation ( current , node ) ; if ( reference . contains ( node . getStartOffset ( ) , node . getEndOffset ( ) , node . getFile ( ) ) ) { throw new LocationFound ( location ) ; } else if ( reference . canMatch ( n...
Never called by analysis from super
120,962
protected ValueList generateNumbers ( int min , int max , Context ctxt ) throws ValueException { ValueList list = new ValueList ( ) ; for ( int i = min ; i < max + 1 ; i ++ ) { list . add ( NumericValue . valueOf ( i , ctxt ) ) ; } return list ; }
Generator method for numeric type bindings .
120,963
private List < IDebugTarget > collectTargets ( IProcess process ) { ILaunchManager launchManager = DebugPlugin . getDefault ( ) . getLaunchManager ( ) ; ILaunch [ ] launches = launchManager . getLaunches ( ) ; List < IDebugTarget > targets = new ArrayList < IDebugTarget > ( ) ; for ( int i = 0 ; i < launches . length ;...
Collects targets associated with a process .
120,964
public void addLabelDecorator ( ILabelDecorator decorator ) { if ( fLabelDecorators == null ) { fLabelDecorators = new ArrayList < ILabelDecorator > ( 2 ) ; } fLabelDecorators . add ( decorator ) ; }
Adds a decorator to the label provider
120,965
protected void fireLabelProviderChanged ( final LabelProviderChangedEvent event ) { Object [ ] listeners = fListeners . getListeners ( ) ; for ( int i = 0 ; i < listeners . length ; ++ i ) { final ILabelProviderListener l = ( ILabelProviderListener ) listeners [ i ] ; SafeRunner . run ( new SafeRunnable ( ) { public vo...
Fires a label provider changed event to all registered listeners Only listeners registered at the time this method is called are notified .
120,966
protected Control createContents ( Composite parent ) { Composite top = new Composite ( parent , SWT . LEFT ) ; top . setLayoutData ( new GridData ( GridData . FILL_HORIZONTAL ) ) ; top . setLayout ( new GridLayout ( ) ) ; if ( Platform . getOS ( ) . equalsIgnoreCase ( Platform . OS_MACOSX ) ) { vdmPathMac = new Direct...
DirectoryFieldEditor vicePathMac = null ;
120,967
private void setFileMarkers ( IFile file , ParseResult result ) throws CoreException { if ( file != null ) { FileUtility . deleteMarker ( file , IMarker . PROBLEM , ICoreConstants . PLUGIN_ID ) ; if ( result . hasParseErrors ( ) ) { file . deleteMarkers ( IMarker . PROBLEM , true , IResource . DEPTH_INFINITE ) ; int pr...
Adds markers to a file based on the result . if errors occurred the problem markers are first cleared .
120,968
public synchronized static void leaving ( String classname , int fnr2 ) { int fn = fnr2 ; m . put ( classname , StaticOperationsCounters . fin [ fn ] ++ ) ; m . put ( classname , StaticOperationsCounters . active [ fn ] -- ) ; stateChanged ( ) ; }
this method is registering the termination of a method .
120,969
private synchronized static void waiting ( String classname , int fnr , int offset ) { m . put ( classname , StaticOperationsCounters . waiting [ fnr ] += offset ) ; stateChanged ( ) ; }
The offset defines how many methods of the same name are waiting .
120,970
private void setContext ( IWorkbenchPage page , IVdmStackFrame frame ) { if ( fContextsByPage == null ) { fContextsByPage = new HashMap < IWorkbenchPage , IVdmStackFrame > ( ) ; } fContextsByPage . put ( page , frame ) ; System . setProperty ( DEBUGGER_ACTIVE , "true" ) ; }
Sets the evaluation context for the given page and notes that a valid execution context exists .
120,971
private void removeContext ( IWorkbenchPage page ) { if ( fContextsByPage != null ) { fContextsByPage . remove ( page ) ; if ( fContextsByPage . isEmpty ( ) ) { System . setProperty ( DEBUGGER_ACTIVE , "false" ) ; System . setProperty ( INSTANCE_OF_IJAVA_STACK_FRAME , "false" ) ; System . setProperty ( SUPPORTS_FORCE_R...
Removes an evaluation context for the given page and determines if any valid execution context remain .
120,972
public static long timeToInternal ( TimeUnit unit , Double time ) { return Math . round ( time * unit . getValue ( ) / TimeUnit . nanosecond . getValue ( ) ) ; }
Utility method to convert a value in the given unit to the internal time
120,973
public static Double internalToTime ( TimeUnit unit , long internalTime ) { return Math . round ( internalTime * TimeUnit . nanosecond . getValue ( ) / unit . getValue ( ) * PRECISION ) / PRECISION ; }
Utility method to convert the internal time to the given unit .
120,974
protected void addBreakpoint ( final IDbgpSession session , IVdmBreakpoint breakpoint ) throws CoreException , DbgpException { final IDbgpCoreCommands commands = session . getCoreCommands ( ) ; DbgpBreakpointConfig config = createBreakpointConfig ( breakpoint ) ; String id = null ; URI bpUri = null ; if ( breakpoint in...
Adding removing updating
120,975
public static Value fwriteval ( Value fval , Value tval , Value dval ) { File file = getFile ( fval ) ; String fdir = dval . toString ( ) ; StringBuffer text = new StringBuffer ( ) ; if ( tval instanceof SeqValue ) { for ( Value val : ( ( SeqValue ) tval ) . values ) { text . append ( val . toString ( ) ) ; text . appe...
Writes a seq of ? in a CSV format to the file specified
120,976
public static Value freadval ( Value fval , Value indexVal ) { ValueList result = new ValueList ( ) ; try { File file = getFile ( fval ) ; long index = indexVal . intValue ( null ) ; SeqValue lineCells = new SeqValue ( ) ; boolean success = false ; try { CsvParser parser = new CsvParser ( new CsvValueBuilder ( ) { publ...
Read a CSV live as a seq of ? in VDM
120,977
public static Value flinecount ( Value fval ) { ValueList result = new ValueList ( ) ; try { File file = getFile ( fval ) ; long count = getLineCount ( file ) ; result . add ( new BooleanValue ( true ) ) ; result . add ( new IntegerValue ( count ) ) ; } catch ( Exception e ) { lastError = e . toString ( ) ; result = ne...
Gets the line count of the CSV file
120,978
public synchronized void syncBuildPath ( IVdmProject project ) throws CoreException { List < IVdmSourceUnit > syncedVdmSourceUnits = project . getSpecFiles ( ) ; List < IFile > removedFiles = new Vector < IFile > ( ) ; IProject p = ( IProject ) project . getAdapter ( IProject . class ) ; for ( IFile file : vdmSourceUni...
Sync existing IVdmSource files with the build path of the project . This is used when the build path changed and the project should be updated . This method removed old IVdmSource files which no longer is withing the build path .
120,979
public synchronized void setState ( DebugState newState ) { if ( ! states . contains ( newState ) ) { switch ( newState ) { case Disconnected : Assert . isLegal ( canChange ( DebugState . Disconnected ) , "Cannot disconnect a terminated state" ) ; case Terminated : Assert . isLegal ( canChange ( DebugState . Terminated...
Sets a new state an Assert . IsLegal is asserted if the given state is not valid based on the current state
120,980
public synchronized boolean canChange ( DebugState newState ) { switch ( newState ) { case Disconnected : return ! inState ( DebugState . Terminated ) && ! inState ( DebugState . Disconnected ) ; case Terminated : return ! inState ( DebugState . Terminated ) ; case Suspended : return inState ( DebugState . Resumed ) ; ...
Checks if a change to the newState is allowed
120,981
public byte [ ] getGraph ( String dot_source , String type ) throws GraphVizException { File dot ; byte [ ] img_stream = null ; try { dot = writeDotSourceToFile ( dot_source ) ; if ( dot != null ) { img_stream = get_img_stream ( dot , type ) ; if ( ! dot . delete ( ) ) { throw new GraphVizException ( "Warning: " + dot ...
Returns the graph as an image in binary format .
120,982
private byte [ ] get_img_stream ( File dot , String type ) throws GraphVizException { File img ; byte [ ] img_stream = null ; try { img = File . createTempFile ( "graph_" , "." + type ) ; Runtime rt = Runtime . getRuntime ( ) ; String [ ] args = { dotPath , "-T" + type , dot . getAbsolutePath ( ) , "-o" , img . getAbso...
It will call the external dot program and return the image in binary format .
120,983
private File writeDotSourceToFile ( String str ) throws java . io . IOException , GraphVizException { File temp ; try { temp = File . createTempFile ( "graph_" , ".dot.tmp" ) ; FileWriter fout = new FileWriter ( temp ) ; fout . write ( str ) ; fout . close ( ) ; } catch ( Exception e ) { throw new GraphVizException ( "...
Writes the source of the graph in a file and returns the written file as a File object .
120,984
public void readSource ( String input ) throws GraphVizException { StringBuilder sb = new StringBuilder ( ) ; try { FileInputStream fis = new FileInputStream ( input ) ; DataInputStream dis = new DataInputStream ( fis ) ; BufferedReader br = new BufferedReader ( new InputStreamReader ( dis ) ) ; String line ; while ( (...
Read a DOT graph from a text file .
120,985
public AEqualsBinaryExp readDefEqualsExpression ( ) throws ParserException , LexException { PExp exp = readEvaluatorP1Expression ( ) ; LexToken token = lastToken ( ) ; if ( readToken ( ) . is ( VDMToken . EQUALS ) ) { return AstFactory . newAEqualsBinaryExp ( exp , token , readEvaluatorP1Expression ( ) ) ; } throwMessa...
Relations Family ...
120,986
private PExp readEvaluatorP1Expression ( ) throws ParserException , LexException { PExp exp = readEvaluatorP2Expression ( ) ; boolean more = true ; while ( more ) { LexToken token = lastToken ( ) ; switch ( token . type ) { case PLUS : nextToken ( ) ; exp = AstFactory . newAPlusNumericBinaryExp ( exp , token , readEval...
Evaluator Family ...
120,987
private void xcmdOvertureResponse ( DBGPXCmdOvertureCommandType overtureCmd , StringBuilder hdr , StringBuilder body ) throws IOException { StringBuilder sb = new StringBuilder ( ) ; sb . append ( "<xcmd_overture_response command=\"" ) ; sb . append ( command ) ; sb . append ( "\"" ) ; sb . append ( " overtureCmd=\"" )...
Send a xcmd Overture Response
120,988
protected StringBuilder propertyResponse ( NameValuePairMap vars , DBGPContextType context ) throws UnsupportedEncodingException { StringBuilder sb = new StringBuilder ( ) ; for ( Entry < ILexNameToken , Value > e : vars . entrySet ( ) ) { if ( ! e . getKey ( ) . getName ( ) . equals ( "self" ) ) { if ( isDebugVisible ...
Overrides super class by filtering all entries against isDebugVisible
120,989
private Integer getChildCount ( Value value ) { if ( value instanceof NumericValue || value instanceof CharacterValue || value instanceof NilValue || value instanceof TokenValue ) { return 0 ; } else if ( value instanceof SetValue ) { return ( ( SetValue ) value ) . values . size ( ) ; } else if ( value instanceof SeqV...
Calculates if a value has children and returns the child count
120,990
private Value deref ( Value value ) { if ( value instanceof ReferenceValue || value instanceof UpdatableValue || value instanceof TransactionValue ) { return value . deref ( ) ; } else { return value ; } }
Deref Value of Reference and Updatable Value types
120,991
private boolean isDebugVisible ( Value v ) { return v instanceof ReferenceValue || v instanceof NumericValue || v instanceof CharacterValue || v instanceof BooleanValue || v instanceof SetValue || v instanceof SeqValue || v instanceof MapValue || v instanceof TokenValue || v instanceof RecordValue || v instanceof Objec...
Determines if a value should be shown in the debug client
120,992
protected void processLog ( DBGPCommand c ) throws IOException { StringBuilder out = new StringBuilder ( ) ; try { if ( c . data == null ) { if ( RTLogger . getLogSize ( ) > 0 ) { out . append ( "Flushing " + RTLogger . getLogSize ( ) + " RT events\n" ) ; } RTLogger . setLogfile ( RTTextLogger . class , null ) ; RTLogg...
Overrides processLog to support URI file format and xcmdOvertureResponse as reply
120,993
public static TypeCompatibilityObligation newInstance ( PExp exp , PType etype , PType atype , IPOContextStack ctxt , IPogAssistantFactory assistantFactory ) throws AnalysisException { TypeCompatibilityObligation sto = new TypeCompatibilityObligation ( exp , etype , atype , ctxt , assistantFactory ) ; if ( sto . getVal...
Factory Method since we need to return null STOs ( which should be discarded
120,994
public void enterDebugger ( Context ctxt ) { ISchedulableThread th = BasicSchedulableThread . getThread ( Thread . currentThread ( ) ) ; if ( th != null ) { th . suspendOthers ( ) ; } if ( Settings . usingDBGP ) { ctxt . threadState . dbgp . stopped ( ctxt , this ) ; } else { new DebuggerReader ( Interpreter . getInsta...
Actually stop and enter the debugger . The method returns when the user asks to continue or step the specification .
120,995
public boolean catchReturn ( Context ctxt ) { ThreadState state = ctxt . threadState ; return state . stepline != null && state . nextctxt == null && state . outctxt == null ; }
Test for whether an apply expression or operation call ought to catch a breakpoint after the return from the call . This only happens if we step into the call so that when we step out it is clear where we re unwinding too rather than jumping down the stack some considerable distance .
120,996
private boolean isAboveNext ( Context current ) { Context c = current . outer ; while ( c != null ) { if ( c == current . threadState . nextctxt ) { return true ; } c = c . outer ; } return false ; }
True if the context passed is above nextctxt . That means that the current context must have an outer chain that reaches nextctxt .
120,997
private boolean isOutOrBelow ( Context current ) { Context c = current . threadState . outctxt ; while ( c != null ) { if ( c == current ) { return true ; } c = c . outer ; } return false ; }
True if the context passed is equal to or below outctxt . That means that outctxt must have an outer chain that reaches current context .
120,998
private boolean containsSeverity ( IMarker [ ] markers , int severity ) { for ( int i = 0 ; i < markers . length ; i ++ ) { try { Object tmp = markers [ i ] . getAttribute ( IMarker . SEVERITY ) ; if ( tmp == null && ! ( tmp instanceof Integer ) ) { continue ; } if ( tmp != null && ( ( Integer ) tmp & severity ) != 0 )...
Checks if any marker in the array has a defined severity which is set to the
120,999
public ABlockStmIR consComplexCompIterationBlock ( List < SMultipleBindIR > multipleSetBinds , ITempVarGen tempGen , IIterationStrategy strategy , IterationVarPrefixes iteVarPrefixes ) throws AnalysisException { ABlockStmIR outerBlock = new ABlockStmIR ( ) ; ABlockStmIR nextMultiBindBlock = outerBlock ; for ( SMultiple...
FIXME make this method work on generic PMUltipleBinds